Skip to content

Commit

Permalink
run-tests.sh: determine compose command.
Browse files Browse the repository at this point in the history
Newer compose is a docker builtin command. Try `docker compose`,
then try `docker-compose`, and if neither is found then exit with an
error.

Currently, the Github Actions "ubuntu-latest" host target sometimes has
the newer form and sometimes does not.

In the workflow, always use `docker compose`.
  • Loading branch information
kanaka committed Apr 3, 2024
1 parent fd15211 commit ac5692d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run: npm install

- name: compose build of conlink
run: docker-compose -f examples/test1-compose.yaml build
run: docker compose -f examples/test1-compose.yaml build

- name: "./run-tests.sh"
timeout-minutes: 5
Expand Down
9 changes: 8 additions & 1 deletion run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ declare FAIL=0

die() { echo >&2 "${*}"; exit 1; }
vecho() { [ "${VERBOSE}" ] && echo "${*}" || true; }
dc() { docker-compose "${@}"; }
dc() { ${DOCKER_COMPOSE} "${@}"; }
mdc() { ./mdc "${@}" || die "mdc invocation failed"; }

# Determine compose command
for dc in "docker compose" "docker-compose"; do
${dc} version 2>/dev/null >&2 && DOCKER_COMPOSE="${dc}" && break
done
[ "${DOCKER_COMPOSE}" ] || die "No compose command found"
echo >&2 "Using compose command '${DOCKER_COMPOSE}'"

dc_init() {
local cont="${1}" idx="${2}"
dc down --remove-orphans -t1
Expand Down

0 comments on commit ac5692d

Please sign in to comment.