File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 2424 runs-on : ubuntu-latest
2525 steps :
2626 - uses : actions/checkout@v4
27- - uses : bazelbuild /setup-bazelisk@95c9bf48d0c570bb3e28e57108f3450cd67c1a44 # v2.0 .0
27+ - uses : bazel-contrib /setup-bazel@0.18 .0
2828 - run : bazel build //...
2929 - run : cd examples && bazel build //...
3030 - run : cd examples && bazel test //...
Original file line number Diff line number Diff line change @@ -53,12 +53,29 @@ if [ $? -eq 0 ]; then
5353 docker_compose_bin=" docker-compose"
5454fi
5555
56- # bring up compose file & get exit status-code from the integration test container
56+ cleanup () {
57+ echo " Cleaning up docker-compose resources..."
58+ docker_compose_down_cmd=" $docker_compose_bin -f $ABSOLUTE_COMPOSE_FILE_PATH down --volumes --remove-orphans"
59+ echo " running: $docker_compose_down_cmd "
60+ echo " $docker_compose_down_cmd " | bash
61+ }
62+
63+ # Ensure cleanup runs on EXIT (covers normal exit, errors, and signals).
64+ # SIGTERM: sent by Bazel on test timeout or cancellation.
65+ # SIGINT: sent on Ctrl+C.
66+ trap cleanup EXIT
67+
68+ # bring up compose file & get exit status-code from the integration test container.
5769docker_compose_up_cmd=" $docker_compose_bin -f $ABSOLUTE_COMPOSE_FILE_PATH up --exit-code-from $DOCKER_COMPOSE_TEST_CONTAINER $EXTRA_DOCKER_COMPOSE_UP_ARGS "
5870echo " running: $docker_compose_up_cmd "
5971echo " $docker_compose_up_cmd " | bash
6072result=$?
6173
62- $docker_compose_bin -f $ABSOLUTE_COMPOSE_FILE_PATH down
74+ # Figure out the exit code of the test container incase it never actually started.
75+ EXIT_CODE=$( docker inspect $( docker compose -f $ABSOLUTE_COMPOSE_FILE_PATH ps -qa $DOCKER_COMPOSE_TEST_CONTAINER ) --format=' {{.State.ExitCode}}' 2> /dev/null)
76+ if [ " $EXIT_CODE " != " 0" ] || [ -z " $EXIT_CODE " ]; then
77+ echo " Error: $DOCKER_COMPOSE_TEST_CONTAINER container failed or never started!"
78+ exit 1
79+ fi
6380
6481exit $result
You can’t perform that action at this time.
0 commit comments