File tree Expand file tree Collapse file tree 14 files changed +170
-156
lines changed Expand file tree Collapse file tree 14 files changed +170
-156
lines changed Original file line number Diff line number Diff line change
1
+ # Source: https://github.com/panubo/reference-github-actions/blob/master/github-release.yml
2
+
3
+ on :
4
+ push :
5
+ tags :
6
+ - ' *'
7
+
8
+ name : GitHub Release
9
+
10
+ jobs :
11
+ build :
12
+ name : Create GitHub Release
13
+ runs-on : ubuntu-latest
14
+ steps :
15
+
16
+ - name : Checkout code
17
+ uses : actions/checkout@v2
18
+ with :
19
+ fetch-depth : 0
20
+
21
+ - name : Get Release Notes
22
+ id : get_release_notes
23
+ run : |
24
+ NOTES=$(git log --pretty=format:%s $(git tag --sort=-refname | head -1)...$(git tag --sort=-refname | head -2 | tail -1) | awk '{ print "-", $0 }')
25
+ NOTES="${NOTES//'%'/'%25'}"
26
+ NOTES="${NOTES//$'\n'/'%0A'}"
27
+ NOTES="${NOTES//$'\r'/'%0D'}"
28
+ echo "NOTES: ${NOTES}"
29
+ echo "::set-output name=notes::${NOTES}"
30
+
31
+ - name : Create Release
32
+ id : create_release
33
+ uses : actions/create-release@v1
34
+ env :
35
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
36
+ with :
37
+ tag_name : ${{ github.ref }}
38
+ release_name : ${{ github.ref }}
39
+ body : |
40
+ Changes since last release:
41
+
42
+ ${{ steps.get_release_notes.outputs.notes }}
43
+
44
+ draft : true
45
+ prerelease : false
Original file line number Diff line number Diff line change
1
+ on :
2
+ push :
3
+
4
+ name : Run Tests
5
+
6
+ jobs :
7
+ build :
8
+ name : Tests
9
+ runs-on : ubuntu-latest
10
+ steps :
11
+
12
+ - name : Setup BATS
13
+ uses : mig4/setup-bats@v1
14
+ with :
15
+ bats-version : 1.3.0
16
+
17
+ - name : Checkout code
18
+ uses : actions/checkout@v2
19
+ with :
20
+ fetch-depth : 0
21
+
22
+ - name : Build image
23
+ run : |
24
+ make build
25
+
26
+ - name : Tests
27
+ run : |
28
+ make test
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ build-quick:
11
11
docker build -t $(IMAGE_NAME ) :$(TAG ) .
12
12
13
13
test :
14
- ./ tests/dind-runner.sh
14
+ bats -r tests/
15
15
16
16
push :
17
17
docker push $(IMAGE_NAME ) :$(TAG )
Original file line number Diff line number Diff line change
1
+ load test_functions.bash
2
+
3
+ @test " smoke test - select 1" {
4
+ run docker run --rm \
5
+ -e DATABASE_HOST=${postgres_container_ip} \
6
+ -e DATABASE_USERNAME=postgres \
7
+ -e DATABASE_PASSWORD=password \
8
+ panubo/postgres-toolbox psql -- -c ' SELECT 1;'
9
+ diag " ${output} "
10
+ [[ " ${status} " -eq 0 ]]
11
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ load test_functions.bash
2
+
3
+ @test " create-user-db" {
4
+ run docker run --rm \
5
+ -e DATABASE_HOST=${postgres_container_ip} \
6
+ -e DATABASE_USERNAME=postgres \
7
+ -e DATABASE_PASSWORD=password \
8
+ panubo/postgres-toolbox create-user-db myuser myuserpassword
9
+ diag " ${output} "
10
+ [[ " ${status} " -eq 0 ]]
11
+
12
+ run docker run --rm \
13
+ -e DATABASE_HOST=${postgres_container_ip} \
14
+ -e DATABASE_USERNAME=myuser \
15
+ -e DATABASE_PASSWORD=myuserpassword \
16
+ panubo/postgres-toolbox psql -- -c ' SELECT current_database();'
17
+ diag " ${output} "
18
+ [[ " ${status} " -eq 0 ]]
19
+ }
20
+
21
+ # echo "===> Test create-user-db command"
22
+ # docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=password postgres:$POSTGRES_VERSION > /dev/null
23
+ # sleep 5
24
+ # docker run -t -i --name $TEST_NAME --link postgres $TEST_CONTAINER create-user-db foo foopass
25
+ # cleanup postgres $TEST_NAME
Original file line number Diff line number Diff line change
1
+ # echo "===> Test delete-user-db command"
2
+ # docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=password postgres:$POSTGRES_VERSION > /dev/null
3
+ # sleep 5
4
+ # docker run -t -i --name ${TEST_NAME}-create --link postgres $TEST_CONTAINER create-user-db foo
5
+ # docker run -t -i --name ${TEST_NAME}-delete --link postgres $TEST_CONTAINER delete-user-db foo
6
+ # cleanup postgres ${TEST_NAME}-create ${TEST_NAME}-delete
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ # echo "===> Test load command"
2
+ # docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=password postgres:$POSTGRES_VERSION > /dev/null
3
+ # sleep 5
4
+ # docker run -t -i --name ${TEST_NAME}-create1 --link postgres $TEST_CONTAINER create-user-db foo
5
+ # docker run -t -i --name ${TEST_NAME}-save --link postgres -e DUMP_DIR="/srv" -v /srv:/srv $TEST_CONTAINER save
6
+ # docker run -t -i --name ${TEST_NAME}-delete --link postgres $TEST_CONTAINER delete-user-db foo
7
+ # docker run -t -i --name ${TEST_NAME}-create2 --link postgres $TEST_CONTAINER create-user-db foo
8
+ # docker run -t -i --name ${TEST_NAME}-load --link postgres -e DUMP_DIR="/srv" -v /srv:/srv $TEST_CONTAINER load foo
9
+ # cleanup postgres ${TEST_NAME}-create1 ${TEST_NAME}-save ${TEST_NAME}-delete ${TEST_NAME}-load ${TEST_NAME}-create2
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ # echo "===> Test save command"
2
+ # docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=password postgres:$POSTGRES_VERSION > /dev/null
3
+ # sleep 5
4
+ # docker run -t -i --name ${TEST_NAME}-create --link postgres $TEST_CONTAINER create-user-db foo
5
+ # docker run -t -i --name ${TEST_NAME}-save --link postgres -e DUMP_DIR="/srv" $TEST_CONTAINER save
6
+ # cleanup postgres ${TEST_NAME}-create ${TEST_NAME}-save
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ TOOLBOX_IMAGE=" panubo/postgres-toolbox:latest"
2
+ POSTGRES_TARGET_VERSION=" 12.7"
3
+
4
+ diag () {
5
+ echo " $@ " | sed -e ' s/^/# /' >&3 ;
6
+ }
7
+
8
+ setup () {
9
+ # setup runs before each test
10
+ # Important: we aren't exposing port etc so running tests in parallel works
11
+ postgres_container=" $( docker run -d -e POSTGRES_PASSWORD=password postgres:${POSTGRES_TARGET_VERSION} ) "
12
+ postgres_container_ip=" $( docker inspect --format ' {{ .NetworkSettings.IPAddress }}' ${postgres_container} ) "
13
+ docker run --rm -e DATABASE_HOST=${postgres_container_ip} \
14
+ -e DATABASE_USERNAME=postgres \
15
+ -e DATABASE_PASSWORD=password \
16
+ ${TOOLBOX_IMAGE} bash -c ' . /panubo-functions.sh; wait_postgres ${DATABASE_HOST}'
17
+ }
18
+
19
+ teardown () {
20
+ # teardown runs after each test
21
+ docker rm -f " ${postgres_container} "
22
+ }
Original file line number Diff line number Diff line change
1
+ load test_functions.bash
2
+
3
+ @test " vacuum" {
4
+ run docker run --rm \
5
+ -e DATABASE_HOST=${postgres_container_ip} \
6
+ -e DATABASE_USERNAME=postgres \
7
+ -e DATABASE_PASSWORD=password \
8
+ panubo/postgres-toolbox vacuumdb -- --maintenance-db=postgres --all
9
+ diag " ${output} "
10
+ [[ " ${status} " -eq 0 ]]
11
+ }
12
+
13
+ # echo "===> Test vacuum command"
14
+ # docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=password postgres:$POSTGRES_VERSION > /dev/null
15
+ # sleep 5
16
+ # docker run -t -i --name $TEST_NAME --link postgres $TEST_CONTAINER vacuum
17
+ # cleanup postgres $TEST_NAME
You can’t perform that action at this time.
0 commit comments