Skip to content

Commit

Permalink
feat: support compose version
Browse files Browse the repository at this point in the history
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
  • Loading branch information
neilime committed Oct 23, 2024
1 parent e7df5df commit 6bb7354
Show file tree
Hide file tree
Showing 27 changed files with 10,279 additions and 319 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/__check-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,81 @@ jobs:
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)
test-action-with-compose-version:
runs-on: ubuntu-latest
name: Test with compose version
env:
DOCKER_COMPOSE_VERSION: "2.29.0"
steps:
- uses: actions/checkout@v4

- name: "Arrange: ensure original docker compose version is not the expected one"
run: |
CURRENT_DOCKER_COMPOSE_VERSION=$(docker compose version --short)
echo "Current docker compose version: $CURRENT_DOCKER_COMPOSE_VERSION"
if [ "$CURRENT_DOCKER_COMPOSE_VERSION" == "$DOCKER_COMPOSE_VERSION" ]; then
echo "Docker compose version is already in $DOCKER_COMPOSE_VERSION version"
exit 1
fi
- name: Act
uses: ./
with:
compose-file: "./test/docker-compose.yml"
compose-version: "2.29.0"

- name: "Assert: compose version is used"
run: |
CURRENT_DOCKER_COMPOSE_VERSION=$(docker compose version --short)
echo "Current docker compose version: $CURRENT_DOCKER_COMPOSE_VERSION"
if [ "$CURRENT_DOCKER_COMPOSE_VERSION" != "$DOCKER_COMPOSE_VERSION" ]; then
echo "Docker compose version is not in $DOCKER_COMPOSE_VERSION version"
exit 1
fi
test-action-with-compose-version-latest:
runs-on: ubuntu-latest
name: Test with compose version latest
steps:
- uses: actions/checkout@v4

- name: "Arrange: retrieve latest version of docker compose"
uses: actions/github-script@v7
with:
script: |
core.exportVariable(
'DOCKER_COMPOSE_VERSION',
await github.rest.repos.listReleases({
owner: "docker",
repo: "compose",
})[0].tag_name
);
- name: "Arrange: ensure original docker compose version is not the expected one"
run: |
CURRENT_DOCKER_COMPOSE_VERSION=$(docker compose version --short)
echo "Current docker compose version: $CURRENT_DOCKER_COMPOSE_VERSION"
if [ "$CURRENT_DOCKER_COMPOSE_VERSION" == "$DOCKER_COMPOSE_VERSION" ]; then
echo "Docker compose version is already in $DOCKER_COMPOSE_VERSION version"
exit 1
fi
- name: Act
uses: ./
with:
compose-file: "./test/docker-compose.yml"
compose-version: "latest"

- name: "Assert: compose version is used"
run: |
CURRENT_DOCKER_COMPOSE_VERSION=$(docker compose version --short)
echo "Current docker compose version: $CURRENT_DOCKER_COMPOSE_VERSION"
if [ "$CURRENT_DOCKER_COMPOSE_VERSION" != "$DOCKER_COMPOSE_VERSION" ]; then
echo "Docker compose version is not in $DOCKER_COMPOSE_VERSION version"
exit 1
fi
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ inputs:
description: "Current working directory"
required: false
default: ${{ github.workspace }}
compose-version:
description: |
Compose version to use.
If null (default), it will use the current installed version.
If "latest", it will install the latest version.
required: false
github-token:
description: The GitHub token used to create an authenticated client (to fetch the latest version of docker-compose).
default: ${{ github.token }}
required: false

runs:
using: node20
main: dist/index.js
Expand Down
Loading

0 comments on commit 6bb7354

Please sign in to comment.