From 37f59ea017b06ba531f1b27785816459309f6a10 Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Sun, 25 Dec 2022 17:26:57 +1100 Subject: [PATCH 01/15] upgrading bats-core/bats-assert from v0.3.0 to v2.1.0 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d7fc4b5..f98c018 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN mkdir -p /usr/local/lib/bats/bats-support \ # Install bats-assert RUN mkdir -p /usr/local/lib/bats/bats-assert \ - && curl -sSL https://github.com/bats-core/bats-assert/archive/v0.3.0.tar.gz -o /tmp/bats-assert.tgz \ + && curl -sSL https://github.com/bats-core/bats-assert/archive/v2.1.0.tar.gz -o /tmp/bats-assert.tgz \ && tar -zxf /tmp/bats-assert.tgz -C /usr/local/lib/bats/bats-assert --strip 1 \ && printf 'source "%s"\n' "/usr/local/lib/bats/bats-assert/load.bash" >> /usr/local/lib/bats/load.bash \ && rm -rf /tmp/bats-assert.tgz From 92d7a7bccd668ba781524493737861115db1b1da Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Sun, 25 Dec 2022 17:29:24 +1100 Subject: [PATCH 02/15] updating bats/bats to latest 1.8.2 linux/amd64 image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f98c018..f96d0d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM bats/bats:latest@sha256:c707c5b7f9afd49da3e8a94248b03832e8b427f1b8f1ae9ec3cfdc5596d9c9f4 +FROM bats/bats:latest@sha256:c3db40540a4942497a8c7ca1ea9fbbf2faf269381f2761380c29154edf5526c4 RUN apk --no-cache add ncurses curl jq From 3f73e90504b8d703eba8fb13c56d720f5383b26a Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Sun, 25 Dec 2022 17:33:41 +1100 Subject: [PATCH 03/15] upgrading buildkite-plugins/docker-compose from v4.5.0 to v4.9.0 --- .buildkite/pipeline.deploy.yml | 6 +++--- .buildkite/pipeline.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.buildkite/pipeline.deploy.yml b/.buildkite/pipeline.deploy.yml index c091bbf..d6b44d8 100644 --- a/.buildkite/pipeline.deploy.yml +++ b/.buildkite/pipeline.deploy.yml @@ -1,7 +1,7 @@ steps: - label: ":docker: :hammer:" plugins: - docker-compose#v4.5.0: + docker-compose#v4.9.0: run: tests - wait @@ -9,7 +9,7 @@ steps: - label: ":docker: :rocket: Latest" plugins: docker-login#v2.1.0: ~ - docker-compose#v4.5.0: + docker-compose#v4.9.0: push: latest if: | build.branch == 'main' @@ -17,7 +17,7 @@ steps: - label: ":docker: :rocket: Tag" plugins: docker-login#v2.1.0: ~ - docker-compose#v4.5.0: + docker-compose#v4.9.0: push: tag if: | build.tag != null diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 1960fbd..459b54d 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,5 +1,5 @@ steps: - label: ":docker: :hammer:" plugins: - docker-compose#v4.5.0: + docker-compose#v4.9.0: run: tests From 9254a45ccd928247de54507b9a4bd35cbec13d04 Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Sun, 25 Dec 2022 17:40:51 +1100 Subject: [PATCH 04/15] updating to docker-compose spec v3.8 --- README.md | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0cbdcb0..fac617c 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ steps: To test this, you'd add the following `docker-compose.yml` file: ```yml -version: '3.4' +version: '3.8' services: tests: image: buildkite/plugin-tester:v3.0.1 diff --git a/docker-compose.yml b/docker-compose.yml index 09068ed..dc790e5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2' +version: '3.8' services: tests: build: . From b63cd7f6c448826840e4fa02601a595687787823 Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Wed, 28 Dec 2022 11:10:27 +1100 Subject: [PATCH 05/15] trying out variations of test.bats to get it working --- tests/test-plugin/tests/test.bats | 34 ++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/tests/test-plugin/tests/test.bats b/tests/test-plugin/tests/test.bats index 1ac447f..2ea9dee 100644 --- a/tests/test-plugin/tests/test.bats +++ b/tests/test-plugin/tests/test.bats @@ -5,13 +5,41 @@ load "$BATS_PLUGIN_PATH/load.bash" # export FOO_STUB_DEBUG=/dev/tty @test "bats works AOK" { - echo "AOK" + run bash -c "echo 'AOK'" assert_success } @test "bats-mock works" { - stub foo "bar : echo baz" - foo bar + stub foo \ + "bar : echo baz" + run foo bar assert_success unstub foo } + +# # @test 'assert_success() status only' { +# # run bash -c "echo 'Error!'; exit 1" +# # assert_success +# # } + +# # @test 'assert_failure() status only' { +# # run echo 'Success!' +# # assert_failure +# # } + +# @test 'assert success' { +# run bash -c "echo 'this'" +# assert_success +# } + +@test "echoing" { + run echo "AOK" + assert_success +} + +@test "stubbing" { + stub greet "sayhi: echo hello" + run greet sayhi + assert_success + unstub greet +} \ No newline at end of file From 0eb5e9ba56dd37ce93cd0de566dc1b422360f973 Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Wed, 28 Dec 2022 11:27:02 +1100 Subject: [PATCH 06/15] cleanup - pt1 --- tests/test-plugin/tests/test.bats | 41 +++++++------------------------ 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/tests/test-plugin/tests/test.bats b/tests/test-plugin/tests/test.bats index 2ea9dee..232afbb 100644 --- a/tests/test-plugin/tests/test.bats +++ b/tests/test-plugin/tests/test.bats @@ -4,42 +4,19 @@ load "$BATS_PLUGIN_PATH/load.bash" # export FOO_STUB_DEBUG=/dev/tty -@test "bats works AOK" { - run bash -c "echo 'AOK'" +@test "bats-core/bats works AOK" { + run echo 'AOK' assert_success } -@test "bats-mock works" { - stub foo \ - "bar : echo baz" - run foo bar - assert_success - unstub foo +@test "Intentional Failure - Not AOK" { + run bash -c "echo 'Not AOK!'; exit 1" + assert_failure } -# # @test 'assert_success() status only' { -# # run bash -c "echo 'Error!'; exit 1" -# # assert_success -# # } - -# # @test 'assert_failure() status only' { -# # run echo 'Success!' -# # assert_failure -# # } - -# @test 'assert success' { -# run bash -c "echo 'this'" -# assert_success -# } - -@test "echoing" { - run echo "AOK" - assert_success -} - -@test "stubbing" { - stub greet "sayhi: echo hello" - run greet sayhi +@test "buildkite-plugins/bats-mock works" { + stub foo "bar : echo baz" + run foo bar assert_success - unstub greet + unstub foo } \ No newline at end of file From 781eca1100374e84c1cb5a88a79433136569088e Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Wed, 28 Dec 2022 11:30:03 +1100 Subject: [PATCH 07/15] cleanup - pt2 --- tests/test-plugin/tests/test.bats | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test-plugin/tests/test.bats b/tests/test-plugin/tests/test.bats index 232afbb..be1c268 100644 --- a/tests/test-plugin/tests/test.bats +++ b/tests/test-plugin/tests/test.bats @@ -4,17 +4,17 @@ load "$BATS_PLUGIN_PATH/load.bash" # export FOO_STUB_DEBUG=/dev/tty -@test "bats-core/bats works AOK" { +@test "bats works AOK" { run echo 'AOK' assert_success } -@test "Intentional Failure - Not AOK" { +@test "bats intentional failure - Not AOK" { run bash -c "echo 'Not AOK!'; exit 1" assert_failure } -@test "buildkite-plugins/bats-mock works" { +@test "bats-mock works" { stub foo "bar : echo baz" run foo bar assert_success From de25168185c4fe763ad4d7161db71da72c65b66e Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Wed, 28 Dec 2022 11:31:47 +1100 Subject: [PATCH 08/15] clarity around expecting failure --- tests/test-plugin/tests/test.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-plugin/tests/test.bats b/tests/test-plugin/tests/test.bats index be1c268..deb5837 100644 --- a/tests/test-plugin/tests/test.bats +++ b/tests/test-plugin/tests/test.bats @@ -9,7 +9,7 @@ load "$BATS_PLUGIN_PATH/load.bash" assert_success } -@test "bats intentional failure - Not AOK" { +@test "bats intentional failure - expects Not AOK" { run bash -c "echo 'Not AOK!'; exit 1" assert_failure } From e4d54ce2d13dc9b38c474a9fbbda4169d7d068d2 Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Wed, 28 Dec 2022 12:09:53 +1100 Subject: [PATCH 09/15] some tests --- tests/test-plugin/tests/test-failure.bats | 30 +++++++++++++++++++ .../tests/{test.bats => test-success.bats} | 5 ---- 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 tests/test-plugin/tests/test-failure.bats rename tests/test-plugin/tests/{test.bats => test-success.bats} (69%) diff --git a/tests/test-plugin/tests/test-failure.bats b/tests/test-plugin/tests/test-failure.bats new file mode 100644 index 0000000..bf1c0ec --- /dev/null +++ b/tests/test-plugin/tests/test-failure.bats @@ -0,0 +1,30 @@ +#!/usr/bin/env bats + +setup() { + load "$BATS_PLUGIN_PATH/load.bash" + + # Uncomment to enable stub debugging + # export BAR_STUB_DEBUG=/dev/tty +} + +@test "bats intentional failure - expects Not AOK" { + run bash -c "echo 'Not AOK!'; exit 1" + assert_failure +} + +@test "bats-mock should throw error" { + stub bar "foo : exit 1" + run bar foo + assert_failure + unstub bar +} + +@test "bats intentional failure - alerts error" { + run echo "error" + + refute_line "success" + assert_line "error" + + run exit 1 + assert_failure +} \ No newline at end of file diff --git a/tests/test-plugin/tests/test.bats b/tests/test-plugin/tests/test-success.bats similarity index 69% rename from tests/test-plugin/tests/test.bats rename to tests/test-plugin/tests/test-success.bats index deb5837..b69a7df 100644 --- a/tests/test-plugin/tests/test.bats +++ b/tests/test-plugin/tests/test-success.bats @@ -9,11 +9,6 @@ load "$BATS_PLUGIN_PATH/load.bash" assert_success } -@test "bats intentional failure - expects Not AOK" { - run bash -c "echo 'Not AOK!'; exit 1" - assert_failure -} - @test "bats-mock works" { stub foo "bar : echo baz" run foo bar From 3215b36c000a8c826de14cad9dde72b39c836e63 Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Thu, 29 Dec 2022 17:12:26 +1100 Subject: [PATCH 10/15] Changing from latest (1.8.2) to latest-no-faccessat2 (1.8.2) linux/amd64 image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f96d0d1..40cfd78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM bats/bats:latest@sha256:c3db40540a4942497a8c7ca1ea9fbbf2faf269381f2761380c29154edf5526c4 +FROM bats/bats:latest-no-faccessat2@sha256:ab8b147d6fd604a25872580db473a61d446370af00addfe0a0d8b4394eae0f6b RUN apk --no-cache add ncurses curl jq From 0bac98c0525fbd471278ffcbdaee23514454d176 Mon Sep 17 00:00:00 2001 From: Frank <88225527+frankpengau@users.noreply.github.com> Date: Wed, 4 Jan 2023 15:07:03 +1100 Subject: [PATCH 11/15] Update Dockerfile to bats/bats:1.8.2-no-faccessat2 Multi-Arch Image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matías Bellone --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 40cfd78..178a2b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM bats/bats:latest-no-faccessat2@sha256:ab8b147d6fd604a25872580db473a61d446370af00addfe0a0d8b4394eae0f6b +FROM bats/bats:1.8.2-no-faccessat2@sha256:ed084f4b241c7e43422ff0a1d624a3a9609ef804ac8953449d2da63d6b8246e0 RUN apk --no-cache add ncurses curl jq From 97a8f047dc69a10640fb285bb501ab863b0569ab Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Wed, 4 Jan 2023 17:43:05 +1100 Subject: [PATCH 12/15] Upgrade buildkite-plugins/bats-mock from v2.0.1 to v2.1.0 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 178a2b3..c3003b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN mkdir -p /usr/local/lib/bats/bats-assert \ # Install lox's fork of bats-mock RUN mkdir -p /usr/local/lib/bats/bats-mock \ - && curl -sSL https://github.com/buildkite-plugins/bats-mock/archive/v2.0.1.tar.gz -o /tmp/bats-mock.tgz \ + && curl -sSL https://github.com/buildkite-plugins/bats-mock/archive/v2.1.0.tar.gz -o /tmp/bats-mock.tgz \ && tar -zxf /tmp/bats-mock.tgz -C /usr/local/lib/bats/bats-mock --strip 1 \ && printf 'source "%s"\n' "/usr/local/lib/bats/bats-mock/stub.bash" >> /usr/local/lib/bats/load.bash \ && rm -rf /tmp/bats-mock.tgz From fb184bbca05ba118678707e0d9d20aa35ed87dba Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Wed, 4 Jan 2023 18:52:16 +1100 Subject: [PATCH 13/15] Dockerfile external frontend --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index c3003b6..1019a4f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1 FROM bats/bats:1.8.2-no-faccessat2@sha256:ed084f4b241c7e43422ff0a1d624a3a9609ef804ac8953449d2da63d6b8246e0 RUN apk --no-cache add ncurses curl jq From 3c8312b1a1462ecab33f7de0c292873dd55d4b07 Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Wed, 4 Jan 2023 18:53:22 +1100 Subject: [PATCH 14/15] changing back to linux/amd64 arch image pinned to 1.8.2-no-faccessat2 --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1019a4f..a5b50ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -# syntax=docker/dockerfile:1 -FROM bats/bats:1.8.2-no-faccessat2@sha256:ed084f4b241c7e43422ff0a1d624a3a9609ef804ac8953449d2da63d6b8246e0 +FROM bats/bats:1.8.2-no-faccessat2@sha256:ab8b147d6fd604a25872580db473a61d446370af00addfe0a0d8b4394eae0f6b RUN apk --no-cache add ncurses curl jq From e125feb8a2bc4e0515bb879adbad9abc16a50c41 Mon Sep 17 00:00:00 2001 From: Frank Peng Date: Thu, 5 Jan 2023 10:39:11 +1100 Subject: [PATCH 15/15] changing docker-compose spec from v3.8 to v3.7 --- README.md | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fac617c..657b50a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ steps: To test this, you'd add the following `docker-compose.yml` file: ```yml -version: '3.8' +version: '3.7' services: tests: image: buildkite/plugin-tester:v3.0.1 diff --git a/docker-compose.yml b/docker-compose.yml index dc790e5..a63543f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.8' +version: '3.7' services: tests: build: .