Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support compose version #93

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/__check-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,80 @@ 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: |
const dockerComposeVersion = (await github.rest.repos.getLatestRelease({
owner: "docker",
repo: "compose",
})).data.tag_name.replace("v", "");

core.exportVariable('DOCKER_COMPOSE_VERSION', dockerComposeVersion);

- 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
Loading