GitHub Action
Docker Compose with Tests Action
This GitHub Action allows you to run your docker-compose
files, specify services to bring up, execute tests in containers, and clean up afterward. It simplifies running tests within a containerized environment in your CI/CD pipelines.
Optional - The path to the Docker Compose file(s). Default: "./docker-compose.yml"
.
You can provide a list of files if needed:
compose-file: |
docker-compose.yml
docker-compose.ci.yml
Optional - The specific services to bring up with docker-compose up
. If not specified, all services in the compose file(s) will be started.
Optional - Additional flags to pass to the docker-compose up
command. Default is none. Useful for passing options like --build
or --force-recreate
.
Optional - Flags to pass to the docker-compose down
command during cleanup. Default is none. For example, use --volumes
if you want to remove volumes.
Optional - General flags to pass to the docker-compose
command. Default is none. These can be used to add global options like --compatibility
or other Docker Compose features.
Optional - The name of the container in which to run the tests. If not specified, no tests will be executed.
Optional - The command used to run the tests within the container. For example, npm test
for Node.js projects. If not specified, no tests will be run.
Optional - Whether to show the console output of the test run as GitHub Action annotations. Default: "true"
.
steps:
# Check out the repository
- uses: actions/checkout@v4
# Run Docker Compose Action
- uses: adambirds/[email protected]
with:
compose-file: "./docker/docker-compose.yml"
up-flags: "--build"
down-flags: "--volumes"
test-container: "test-container"
test-command: "npm test"
steps:
- uses: actions/checkout@v4
- uses: adambirds/[email protected]
with:
compose-file: "./docker/docker-compose.yml"
env:
CUSTOM_VARIABLE: "test"
steps:
- uses: actions/checkout@v4
- uses: adambirds/[email protected]
with:
compose-file: "./docker/docker-compose.yml"
test-container: "container1"
test-command: "npm test"
- uses: adambirds/[email protected]
with:
compose-file: "./docker/docker-compose.yml"
test-container: "container2"
test-command: "npm test"
- uses: adambirds/[email protected]
with:
compose-file: "./docker/docker-compose.yml"
test-container: "container3"
test-command: "npm test"