From f7ac24c0d192c0730612600959e874e63e9b0488 Mon Sep 17 00:00:00 2001 From: Emilien Escalle Date: Mon, 17 Jun 2024 19:39:01 +0200 Subject: [PATCH] ci: add test for attach-dependencies Signed-off-by: Emilien Escalle --- .github/workflows/__check-action.yml | 17 +++++++++++++++++ test/docker-compose-fail.yml | 4 ++++ test/docker-compose-with-env.yml | 2 -- test/docker-compose.ci.yml | 2 -- test/docker-compose.yml | 2 -- 5 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 test/docker-compose-fail.yml diff --git a/.github/workflows/__check-action.yml b/.github/workflows/__check-action.yml index f3673c7..195dabc 100644 --- a/.github/workflows/__check-action.yml +++ b/.github/workflows/__check-action.yml @@ -138,3 +138,20 @@ jobs: with: compose-file: "test/docker-compose-web-mysql.yml" up-flags: "--build --abort-on-container-exit --exit-code-from=web" + + test-attach-dependencies-failure: + runs-on: ubuntu-latest + name: Test with --attach-dependencies and service failure + steps: + - uses: actions/checkout@v4 + + - name: Act + uses: ./ + with: + compose-file: "test/docker-compose-fail.yml" + up-flags: "--attach-dependencies" + + - name: Assert + run: | + EXIT_CODE=$(docker compose -f ./test/docker-compose-fail.yml ps service-a --all --format json | jq ".ExitCode") + [ "$EXIT_CODE" == "1" ] || (echo "Service service-a did not exit with code 1" && exit 1) diff --git a/test/docker-compose-fail.yml b/test/docker-compose-fail.yml new file mode 100644 index 0000000..d7e25d0 --- /dev/null +++ b/test/docker-compose-fail.yml @@ -0,0 +1,4 @@ +services: + service-a: + image: busybox + command: ["sh", "-c", "exit 1"] diff --git a/test/docker-compose-with-env.yml b/test/docker-compose-with-env.yml index b938566..1d61806 100644 --- a/test/docker-compose-with-env.yml +++ b/test/docker-compose-with-env.yml @@ -1,5 +1,3 @@ -version: "3.8" - volumes: test_volume: {} diff --git a/test/docker-compose.ci.yml b/test/docker-compose.ci.yml index ad00f0b..583d119 100644 --- a/test/docker-compose.ci.yml +++ b/test/docker-compose.ci.yml @@ -1,5 +1,3 @@ -version: "3.8" - services: service-d: image: busybox diff --git a/test/docker-compose.yml b/test/docker-compose.yml index 7c8dd8e..2ad5bd8 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.8" - services: service-a: image: busybox