File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 directory : " /"
55 schedule :
66 interval : " daily"
7+ - package-ecosystem : " docker"
8+ directory : " /"
9+ schedule :
10+ interval : " daily"
Original file line number Diff line number Diff line change 77 - ' *'
88
99jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+ permissions :
13+ contents : read
14+ steps :
15+ - uses : actions/checkout@v4
16+ - run : make test
1017 integration-test :
1118 runs-on : ubuntu-latest
1219 permissions :
2734 with :
2835 title : ${{ github.sha }}
2936 tag : ${{ github.run_id }}
30-
3137 release :
3238 runs-on : ubuntu-latest
3339 needs :
Original file line number Diff line number Diff line change 1+ FROM ubuntu:24.04@sha256:99c35190e22d294cdace2783ac55effc69d32896daaa265f0bbedbcde4fbe3e5 as testEnv
2+ RUN apt-get update && apt-get install -y coreutils bats
3+
4+ ADD mock.sh /usr/local/mock/gh
5+ ADD mock.sh /usr/local/mock/cd
6+
7+ ADD entrypoint.sh /entrypoint.sh
8+ ADD test.bats /test.bats
9+
10+ RUN /test.bats
Original file line number Diff line number Diff line change 1+ .EXPORT_ALL_VARIABLES :
2+ DOCKER_BUILDKIT =0# to prevent caching of test results
3+
4+ test :
5+ podman build .
Original file line number Diff line number Diff line change 1- #! /bin/sh
1+ #! /usr/ bin/env sh
22
33if [ ! -z " ${INPUT_WORKDIR} " ]; then
44 cd " ${INPUT_WORKDIR} "
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ binary=" $0 "
3+ parameters=" $@ "
4+
5+ echo " ${binary} ${parameters} " >> mockArgs
6+ stdin=$( cat -)
7+ echo " ${binary} ${stdin} " >> mockStdin
8+
9+ function mockShouldFail() {
10+ [ " ${MOCK_RETURNS[${binary}]} " = " _${parameters} " ]
11+ }
12+
13+ source mockReturns
14+
15+ if [ ! -z " ${MOCK_RETURNS[${binary}]} " ] || [ ! -z " ${MOCK_RETURNS[${binary} $1]} " ]; then
16+ if mockShouldFail ; then
17+ exit 1
18+ fi
19+ if [ ! -z " ${MOCK_RETURNS[${binary} $1]} " ]; then
20+ echo ${MOCK_RETURNS[${binary} $1]}
21+ exit 0
22+ fi
23+ echo ${MOCK_RETURNS[${binary}]}
24+ fi
25+
26+ exit 0
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bats
2+
3+ setup (){
4+ export PATH=" /usr/local/mock:/usr/bin"
5+ cat /dev/null > | mockArgs
6+ cat /dev/null > | mockStdin
7+
8+ declare -A -p MOCK_RETURNS=(
9+ [' /usr/local/mock/gh' ]=" "
10+ [' /usr/local/mock/cd' ]=" "
11+ ) > mockReturns
12+
13+ export INPUT_TITLE=' TITLE'
14+ }
15+
16+ teardown () {
17+ unset INPUT_WORKDIR
18+ unset INPUT_TAG
19+ }
20+
21+ @test " it creates a release" {
22+ run /entrypoint.sh
23+
24+ expectMockCalledIs " /usr/local/mock/gh release create release-$( date +%Y%m%d%H%M%S) -t TITLE --generate-notes"
25+ }
26+
27+ @test " it creates a release with a predefined tag" {
28+ export INPUT_TAG=" TAG"
29+
30+ run /entrypoint.sh
31+
32+ expectMockCalledIs " /usr/local/mock/gh release create ${INPUT_TAG} -t TITLE --generate-notes"
33+ }
34+
35+ @test " it creates a release in a working directory" {
36+ export INPUT_WORKDIR=" WORKDIR"
37+ export INPUT_TAG=" TAG"
38+
39+ run /entrypoint.sh
40+
41+ expectMockCalledIs " /usr/local/mock/gh release create ${INPUT_TAG} -t TITLE --generate-notes"
42+ }
43+
44+ expectMockCalledIs () {
45+ local expected=$( echo " ${1} " | tr -d ' \n' )
46+ local got=$( cat mockArgs | tr -d ' \n' )
47+ echo " Expected: |${expected} |
48+ Got: |${got} |"
49+ [ " ${got} " == " ${expected} " ]
50+ }
You can’t perform that action at this time.
0 commit comments