mirror of
https://github.com/hoverkraft-tech/compose-action.git
synced 2026-01-09 14:13:06 +08:00
158 lines
5.2 KiB
YAML
158 lines
5.2 KiB
YAML
name: Internal - Tests for action
|
|
|
|
on:
|
|
workflow_call:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
test-action-with-services:
|
|
runs-on: ubuntu-latest
|
|
name: Test with services
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Act
|
|
uses: ./
|
|
with:
|
|
compose-file: "./test/docker-compose.yml"
|
|
services: |
|
|
service-b
|
|
service-c
|
|
|
|
- name: "Assert: only expected services are running"
|
|
run: |
|
|
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
|
|
|
|
test-action-with-down-flags:
|
|
runs-on: ubuntu-latest
|
|
name: Test compose action
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Act
|
|
uses: ./
|
|
with:
|
|
compose-file: "./test/docker-compose.yml"
|
|
down-flags: "--volumes"
|
|
|
|
test-action-with-compose-flags:
|
|
runs-on: ubuntu-latest
|
|
name: Test with compose flags
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Act
|
|
uses: ./
|
|
with:
|
|
compose-file: "./test/docker-compose.yml"
|
|
compose-flags: "--profile profile-1"
|
|
down-flags: "--volumes"
|
|
|
|
- name: "Assert: profile is used"
|
|
run: |
|
|
docker compose -f ./test/docker-compose.yml -p profile-1 ps || (echo "Profile not used" && exit 1)
|
|
|
|
test-action-with-env:
|
|
runs-on: ubuntu-latest
|
|
name: Test with env
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Act
|
|
uses: ./
|
|
with:
|
|
compose-file: "./test/docker-compose-with-env.yml"
|
|
env:
|
|
IMAGE_NAME: busybox
|
|
|
|
- name: "Assert: env is used"
|
|
env:
|
|
IMAGE_NAME: busybox
|
|
run: |
|
|
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)
|
|
|
|
test-action-with-multiple-compose-files:
|
|
runs-on: ubuntu-latest
|
|
name: Test with multiple compose files
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Act
|
|
uses: ./
|
|
with:
|
|
compose-file: |
|
|
./test/docker-compose.yml
|
|
./test/docker-compose.ci.yml
|
|
services: |
|
|
service-b
|
|
service-d
|
|
|
|
- name: "Assert: only expected services are running"
|
|
run: |
|
|
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
|
|
|
|
test-action-with-cwd:
|
|
runs-on: ubuntu-latest
|
|
name: Test with cwd
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Act
|
|
uses: ./
|
|
with:
|
|
compose-file: "docker-compose.yml"
|
|
cwd: "./test"
|
|
services: |
|
|
service-b
|
|
service-c
|
|
|
|
- name: "Assert: only expected services are running"
|
|
run: |
|
|
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
|
|
|
|
test-abort-on-container-exit:
|
|
runs-on: ubuntu-latest
|
|
name: Test with --abort-on-container-exit
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Act
|
|
uses: ./
|
|
with:
|
|
compose-file: "test/docker-compose-web-mysql.yml"
|
|
up-flags: "--build --abort-on-container-exit --exit-code-from=web"
|
|
|
|
test-attach-dependencies-failure:
|
|
runs-on: ubuntu-latest
|
|
name: Test with --attach-dependencies and service failure
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Act
|
|
uses: ./
|
|
with:
|
|
compose-file: "test/docker-compose-fail.yml"
|
|
up-flags: "--attach-dependencies"
|
|
|
|
- name: Assert
|
|
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)
|