mirror of
https://github.com/hoverkraft-tech/compose-action.git
synced 2026-07-03 20:22:51 +08:00
Bumps the github-actions-dependencies group with 14 updates in the / directory: | Package | From | To | | --- | --- | --- | | [docker/setup-docker-action](https://github.com/docker/setup-docker-action) | `5.0.0` | `5.2.0` | | [hoverkraft-tech/ci-github-nodejs](https://github.com/hoverkraft-tech/ci-github-nodejs) | `0.22.0` | `0.24.2` | | [hoverkraft-tech/ci-github-nodejs/.github/workflows/continuous-integration.yml](https://github.com/hoverkraft-tech/ci-github-nodejs) | `0.22.0` | `0.24.2` | | [hoverkraft-tech/ci-github-common/.github/workflows/linter.yml](https://github.com/hoverkraft-tech/ci-github-common) | `0.33.0` | `0.35.4` | | [hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml](https://github.com/hoverkraft-tech/ci-github-common) | `0.33.0` | `0.35.4` | | [hoverkraft-tech/ci-dokumentor](https://github.com/hoverkraft-tech/ci-dokumentor) | `0.2.2` | `0.3.1` | | [actions/create-github-app-token](https://github.com/actions/create-github-app-token) | `3.0.0` | `3.2.0` | | [hoverkraft-tech/ci-github-common](https://github.com/hoverkraft-tech/ci-github-common) | `0.33.0` | `0.35.4` | | [actions/upload-artifact](https://github.com/actions/upload-artifact) | `7.0.0` | `7.0.1` | | [hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml](https://github.com/hoverkraft-tech/public-docs) | `0.3.0` | `0.4.0` | | [hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml](https://github.com/hoverkraft-tech/ci-github-common) | `0.33.0` | `0.35.4` | | [hoverkraft-tech/ci-github-publish/.github/workflows/prepare-release.yml](https://github.com/hoverkraft-tech/ci-github-publish) | `0.22.0` | `0.26.0` | | [hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml](https://github.com/hoverkraft-tech/ci-github-common) | `0.33.0` | `0.35.4` | | [hoverkraft-tech/ci-github-common/.github/workflows/stale.yml](https://github.com/hoverkraft-tech/ci-github-common) | `0.33.0` | `0.35.4` | Updates `docker/setup-docker-action` from 5.0.0 to 5.2.0 - [Release notes](https://github.com/docker/setup-docker-action/releases) - [Commits](1a6edb0ba9...0234bb73cc) Updates `hoverkraft-tech/ci-github-nodejs` from 0.22.0 to 0.24.2 - [Release notes](https://github.com/hoverkraft-tech/ci-github-nodejs/releases) - [Commits](775ce0902c...6b74a8f070) Updates `hoverkraft-tech/ci-github-nodejs/.github/workflows/continuous-integration.yml` from 0.22.0 to 0.24.2 - [Release notes](https://github.com/hoverkraft-tech/ci-github-nodejs/releases) - [Commits](775ce0902c...6b74a8f070) Updates `hoverkraft-tech/ci-github-common/.github/workflows/linter.yml` from 0.33.0 to 0.35.4 - [Release notes](https://github.com/hoverkraft-tech/ci-github-common/releases) - [Commits](4b53189212...b553a69653) Updates `hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml` from 0.33.0 to 0.35.4 - [Release notes](https://github.com/hoverkraft-tech/ci-github-common/releases) - [Commits](4b53189212...b553a69653) Updates `hoverkraft-tech/ci-dokumentor` from 0.2.2 to 0.3.1 - [Release notes](https://github.com/hoverkraft-tech/ci-dokumentor/releases) - [Commits](c46a1a1089...3258ef0de9) Updates `actions/create-github-app-token` from 3.0.0 to 3.2.0 - [Release notes](https://github.com/actions/create-github-app-token/releases) - [Changelog](https://github.com/actions/create-github-app-token/blob/main/CHANGELOG.md) - [Commits](f8d387b68d...bcd2ba4921) Updates `hoverkraft-tech/ci-github-common` from 0.33.0 to 0.35.4 - [Release notes](https://github.com/hoverkraft-tech/ci-github-common/releases) - [Commits](4b53189212...b553a69653) Updates `actions/upload-artifact` from 7.0.0 to 7.0.1 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](bbbca2ddaa...043fb46d1a) Updates `hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml` from 0.3.0 to 0.4.0 - [Release notes](https://github.com/hoverkraft-tech/public-docs/releases) - [Commits](c40c17f7d6...f3c9291760) Updates `hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml` from 0.33.0 to 0.35.4 - [Release notes](https://github.com/hoverkraft-tech/ci-github-common/releases) - [Commits](4b53189212...b553a69653) Updates `hoverkraft-tech/ci-github-publish/.github/workflows/prepare-release.yml` from 0.22.0 to 0.26.0 - [Release notes](https://github.com/hoverkraft-tech/ci-github-publish/releases) - [Commits](b56be562f3...ba941863a6) Updates `hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml` from 0.33.0 to 0.35.4 - [Release notes](https://github.com/hoverkraft-tech/ci-github-common/releases) - [Commits](4b53189212...b553a69653) Updates `hoverkraft-tech/ci-github-common/.github/workflows/stale.yml` from 0.33.0 to 0.35.4 - [Release notes](https://github.com/hoverkraft-tech/ci-github-common/releases) - [Commits](4b53189212...b553a69653) --- updated-dependencies: - dependency-name: actions/create-github-app-token dependency-version: 3.1.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: actions/upload-artifact dependency-version: 7.0.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions-dependencies - dependency-name: docker/setup-docker-action dependency-version: 5.1.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-dokumentor dependency-version: 0.3.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-common dependency-version: 0.35.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml dependency-version: 0.35.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml dependency-version: 0.35.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml dependency-version: 0.35.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml dependency-version: 0.35.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml dependency-version: 0.35.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-nodejs dependency-version: 0.23.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-nodejs/.github/workflows/continuous-integration.yml dependency-version: 0.23.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/ci-github-publish/.github/workflows/prepare-release.yml dependency-version: 0.23.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies - dependency-name: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml dependency-version: 0.4.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions-dependencies ... Signed-off-by: dependabot[bot] <support@github.com>
275 lines
14 KiB
YAML
275 lines
14 KiB
YAML
name: Internal - Tests for action
|
|
|
|
on:
|
|
workflow_call:
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
test-action:
|
|
runs-on: ubuntu-latest
|
|
name: ${{ matrix.name }} - ${{ matrix.assertion-name }}
|
|
permissions:
|
|
contents: read
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- name: Given multiple services when filtering services
|
|
assertion-name: "Then only expected services run"
|
|
compose-file: ./test/docker-compose.yml
|
|
services: |
|
|
service-b
|
|
service-c
|
|
assertion: |
|
|
docker compose -f ./test/docker-compose.yml ps
|
|
|
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-b-1 || (echo "Service service-b is not running" && exit 1)
|
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-c-1 || (echo "Service service-c is not running" && exit 1)
|
|
(docker compose -f ./test/docker-compose.yml ps | grep test-service-a-1 && echo "Unexpected service service-a is running" && exit 1) || true
|
|
|
|
- name: Given compose file when applying down flags
|
|
assertion-name: "Then teardown honors down flags"
|
|
compose-file: ./test/docker-compose.yml
|
|
down-flags: "--volumes"
|
|
assertion: |
|
|
docker compose -f ./test/docker-compose.yml ps
|
|
|
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-a-1 || (echo "Service service-a is not running" && exit 1)
|
|
(docker compose -f ./test/docker-compose.yml ps | grep test-service-b-1 && echo "Service service-b should not be running without profile" && exit 1) || true
|
|
(docker compose -f ./test/docker-compose.yml ps | grep test-service-c-1 && echo "Service service-c should not be running without profile" && exit 1) || true
|
|
|
|
- name: Given compose profile when passing compose flags
|
|
assertion-name: "Then the requested profile is active"
|
|
compose-file: ./test/docker-compose.yml
|
|
compose-flags: "--profile profile-1"
|
|
down-flags: "--volumes"
|
|
assertion: |
|
|
docker compose -f ./test/docker-compose.yml -p profile-1 ps || (echo "Profile not used" && exit 1)
|
|
|
|
- name: Given image supplied via env when running action
|
|
assertion-name: "Then compose uses the provided env"
|
|
compose-file: ./test/docker-compose-with-env.yml
|
|
image-name: busybox
|
|
assertion: |
|
|
docker compose -f ./test/docker-compose-with-env.yml ps
|
|
|
|
docker compose -f ./test/docker-compose-with-env.yml ps | grep test-service-a-1 || (echo "Service service-a is not running" && exit 1)
|
|
|
|
- name: Given multiple compose files when selecting services
|
|
assertion-name: "Then only services from selection run"
|
|
compose-file: |
|
|
./test/docker-compose.yml
|
|
./test/docker-compose.ci.yml
|
|
services: |
|
|
service-b
|
|
service-d
|
|
assertion: |
|
|
docker compose -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml ps
|
|
|
|
docker compose -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml ps | grep test-service-b-1 || (echo "Service service-b is not running" && exit 1)
|
|
docker compose -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml ps | grep test-service-d-1 || (echo "Service service-d is not running" && exit 1)
|
|
(docker compose -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml ps | grep test-service-a-1 && echo "Unexpected service service-a is running" && exit 1) || true
|
|
(docker compose -f ./test/docker-compose.yml -f ./test/docker-compose.ci.yml ps | grep test-service-c-1 && echo "Unexpected service service-c is running" && exit 1) || true
|
|
|
|
- name: Given compose file in subdirectory when setting cwd
|
|
assertion-name: "Then only expected services run"
|
|
compose-file: docker-compose.yml
|
|
cwd: ./test
|
|
services: |
|
|
service-b
|
|
service-c
|
|
assertion: |
|
|
docker compose -f ./test/docker-compose.yml ps
|
|
|
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-b-1 || (echo "Service service-b is not running" && exit 1)
|
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-c-1 || (echo "Service service-c is not running" && exit 1)
|
|
(docker compose -f ./test/docker-compose.yml ps | grep test-service-a-1 && echo "Unexpected service service-a is running" && exit 1) || true
|
|
|
|
- name: Given absolute compose path when running action
|
|
assertion-name: "Then only expected services run"
|
|
compose-file: test/docker-compose.yml
|
|
use-absolute-path: true
|
|
services: |
|
|
service-b
|
|
service-c
|
|
assertion: |
|
|
docker compose -f ./test/docker-compose.yml ps
|
|
|
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-b-1 || (echo "Service service-b is not running" && exit 1)
|
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-c-1 || (echo "Service service-c is not running" && exit 1)
|
|
(docker compose -f ./test/docker-compose.yml ps | grep test-service-a-1 && echo "Unexpected service service-a is running" && exit 1) || true
|
|
|
|
- name: Given compose with multiple services when using abort-on-container-exit
|
|
assertion-name: "Then execution stops on container exit"
|
|
compose-file: test/docker-compose-web-mysql.yml
|
|
up-flags: "--build --abort-on-container-exit --exit-code-from=web"
|
|
assertion: |
|
|
WEB_EXIT_CODE=$(docker compose -f ./test/docker-compose-web-mysql.yml ps web --all --format json | jq ".ExitCode")
|
|
[ "$WEB_EXIT_CODE" == "0" ] || (echo "Web service did not exit successfully" && exit 1)
|
|
|
|
MYSQL_STATE=$(docker compose -f ./test/docker-compose-web-mysql.yml ps mysql --all --format json | jq -r ".State")
|
|
if [ "$MYSQL_STATE" = "running" ]; then
|
|
echo "MySQL service is still running"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Given failing dependency when attaching dependencies
|
|
assertion-name: "Then failing service exits with code 1"
|
|
compose-file: test/docker-compose-fail.yml
|
|
up-flags: "--attach-dependencies"
|
|
assertion: |
|
|
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)
|
|
|
|
- name: Given compose version mismatch when requesting explicit version
|
|
assertion-name: "Then docker compose reports the requested version"
|
|
compose-file: ./test/docker-compose.yml
|
|
compose-version: "2.29.0"
|
|
expected-compose-version: "2.29.0"
|
|
ensure-version-mismatch: true
|
|
assertion: |
|
|
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
|
|
|
|
- name: Given compose version mismatch when requesting latest version
|
|
assertion-name: "Then docker compose reports the requested version"
|
|
compose-file: ./test/docker-compose.yml
|
|
compose-version: latest
|
|
fetch-latest-compose: true
|
|
ensure-version-mismatch: true
|
|
assertion: |
|
|
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
|
|
|
|
- name: Given custom docker context when providing docker flags
|
|
assertion-name: "Then docker compose uses that context"
|
|
compose-file: ./test/docker-compose.yml
|
|
compose-version: latest
|
|
docker-flags: "--context test-context"
|
|
docker-context: test-context
|
|
assertion: |
|
|
CURRENT_CONTEXT=$(docker context show)
|
|
if [ "$CURRENT_CONTEXT" != "test-context" ]; then
|
|
echo "Docker context is '$CURRENT_CONTEXT' instead of 'test-context'"
|
|
exit 1
|
|
fi
|
|
|
|
docker compose -f ./test/docker-compose.yml ps
|
|
|
|
docker compose -f ./test/docker-compose.yml ps | grep test-service-a-1 || (echo "Service service-a is not running under custom context" && exit 1)
|
|
(docker compose -f ./test/docker-compose.yml ps | grep test-service-b-1 && echo "Service service-b should not be running without profile" && exit 1) || true
|
|
|
|
- name: Given OCI compose artifact when running action
|
|
assertion-name: "Then the OCI compose application runs"
|
|
compose-file: oci://localhost:5000/compose-action-test:latest
|
|
publish-oci-artifact: true
|
|
source-compose-file: ./test/docker-compose.yml
|
|
assertion: |
|
|
docker compose -f "$OCI_COMPOSE_FILE" ps service-a | grep service-a | grep "Up" || (echo "Service service-a is not running from the OCI artifact" && exit 1)
|
|
|
|
env:
|
|
DOCKER_COMPOSE_VERSION: ${{ matrix.expected-compose-version || '' }}
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Set up Docker context
|
|
if: ${{ matrix.docker-context }}
|
|
uses: docker/setup-docker-action@0234bb73ccb40f0c430b795634f9247e2b5c2d23 # v5.2.0
|
|
with:
|
|
context: ${{ matrix.docker-context }}
|
|
|
|
- name: Resolve absolute compose path
|
|
if: ${{ matrix.use-absolute-path }}
|
|
id: compose-path
|
|
run: echo "absolute=${GITHUB_WORKSPACE}/${{ matrix.compose-file }}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: "Arrange: retrieve latest version of docker compose"
|
|
if: ${{ matrix.fetch-latest-compose }}
|
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
|
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: start local OCI registry"
|
|
if: ${{ matrix.publish-oci-artifact }}
|
|
# Keep the registry alive until the job ends because the action post hook
|
|
# reuses the OCI reference for docker compose logs and down.
|
|
run: |
|
|
OCI_REGISTRY_IMAGE=registry:2.8.3
|
|
OCI_REGISTRY_MAX_RETRIES=10
|
|
OCI_REGISTRY_RETRY_DELAY_SECONDS=1
|
|
|
|
# Keep the registry on port 5000 so it matches the OCI reference configured in the test matrix.
|
|
OCI_REGISTRY_CONTAINER_ID=$(docker run -d -p 5000:5000 "$OCI_REGISTRY_IMAGE")
|
|
echo "OCI_REGISTRY_CONTAINER_ID=$OCI_REGISTRY_CONTAINER_ID" >> "$GITHUB_ENV"
|
|
|
|
retry_count=0
|
|
while [ "$retry_count" -lt "$OCI_REGISTRY_MAX_RETRIES" ]; do
|
|
if curl --fail --silent http://localhost:5000/v2/ >/dev/null; then
|
|
exit 0
|
|
fi
|
|
|
|
retry_count=$((retry_count + 1))
|
|
sleep "$OCI_REGISTRY_RETRY_DELAY_SECONDS"
|
|
done
|
|
|
|
echo "Local OCI registry did not become ready on localhost:5000"
|
|
exit 1
|
|
|
|
- name: "Arrange: publish compose application as OCI artifact"
|
|
if: ${{ matrix.publish-oci-artifact }}
|
|
run: |
|
|
OCI_REPOSITORY="${{ matrix.compose-file }}"
|
|
OCI_PUBLISH_TARGET="${OCI_REPOSITORY#oci://}"
|
|
docker compose -f "${{ matrix.source-compose-file }}" publish "$OCI_PUBLISH_TARGET"
|
|
|
|
- name: "Arrange: ensure original docker compose version is not the expected one"
|
|
if: ${{ matrix.ensure-version-mismatch }}
|
|
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: ${{ matrix.use-absolute-path && steps.compose-path.outputs.absolute || matrix.compose-file }}
|
|
services: ${{ matrix.services || '' }}
|
|
down-flags: ${{ matrix.down-flags || '' }}
|
|
compose-flags: ${{ matrix.compose-flags || '' }}
|
|
compose-version: ${{ matrix.compose-version || '' }}
|
|
cwd: ${{ matrix.cwd || '' }}
|
|
up-flags: ${{ matrix.up-flags || '' }}
|
|
docker-flags: ${{ matrix.docker-flags || '' }}
|
|
env:
|
|
IMAGE_NAME: ${{ matrix.image-name || '' }}
|
|
|
|
- name: ${{ matrix.assertion-name }}
|
|
if: ${{ matrix.assertion }}
|
|
run: ${{ matrix.assertion }}
|
|
env:
|
|
IMAGE_NAME: ${{ matrix.image-name || '' }}
|
|
OCI_COMPOSE_FILE: ${{ matrix.compose-file || '' }}
|