adambirds / docker-compose-action Goto Github PK
View Code? Open in Web Editor NEWGithub Action for Docker Compose with support for running tests.
Github Action for Docker Compose with support for running tests.
On a failed test, the error annotation is used, which is basically the error stringified.
Line 54 in cf2e51f
Some test runners natively support logging errors to github action annotations, so this extra failure annotation is redundant, and noisy.
It'd be nice if it was optional
Actions run result: https://github.com/harshraj22/smallProjects/actions/runs/4650998949/jobs/8230328773
Not sure what is wrong
the test command test-command: "nc -vz localhost 9092"
pings the kafka server.
tried with both, test-container as "ubuntu" and "broker" (the name given to kafka microservice in docker compose)
For the following:
name: E2E Test Stack
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
timeout-minutes: 60
runs-on:
- self-hosted
- builder
steps:
- uses: actions/checkout@v3
- uses: adambirds/[email protected]
env:
# Isolate different compose projects
COMPOSE_PROJECT_NAME: "e2e-${{ github.run_id }}"
with:
compose-file: |
docker-compose.no-bind.yaml
docker-compose.e2e.yaml
test-container: playwright
test-command: npm run 'test:e2e'
I get the following logs (after creating the whole stack incl. the playwright container)
compose started
testContainer playwright
testCommand npm run 'test:e2e'
Error: tests failed {"exitCode":1,"err":"","out":""}
playwright dockerfile:
FROM mcr.microsoft.com/playwright:v1.44.1-jammy
WORKDIR /app
ADD package.json package-lock.json .
RUN npm ci
ADD playwright.config.ts .
ADD tests ./tests
# docker-compose.e2e.yaml
services:
playwright:
#image: mcr.microsoft.com/playwright:v1.44.1-jammy
build:
context: .
dockerfile: ./Dockerfile.playwright
I suspect its because you use docker.exec for running the test command, and my playwright container doesn't have an ongoing entrypoint, so terminates immediately.
Line 42 in cf2e51f
the test container should not be required to have a running entry point IMO, maybe can use .run
instead or allow config to allow .run
The current version of docker-compose
is 0.23.5 :
docker-compose-action/package.json
Line 18 in cf2e51f
This version only supports the docker-compose
v1
spec.
The latest version of the npm docker-compose supports v2
, since v0.24.0
The compose spec added compose-spec/compose-spec#340 a yaml tag for resetting values in an override, for example
# docker-compose.base.yaml
services:
db:
# ...
build:
context: db
ports:
- "5432:5432"
volumes:
- aggregator-data:/var/lib/postgresql/data
# docker-compose.e2e.yaml
services:
playwright:
build:
context: .
dockerfile: ./Dockerfile.playwright
# Disable ports
db:
ports: !reset []
volumes: !reset []
This is useful in CI, as I want to use my compose stack to run e2e tests, and disable portforwarding + persistence so I can run multiple compose stacks in parallel on the same runner, ie:
name: E2E Test Stack
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
timeout-minutes: 60
runs-on:
- self-hosted
- builder
steps:
- uses: actions/checkout@v3
- uses: adambirds/[email protected]
env:
# Isolate different compose projects
COMPOSE_PROJECT_NAME: "e2e-${{ github.run_id }}"
with:
compose-file: |
docker-compose.base.yaml
docker-compose.e2e.yaml
test-container: playwright
test-command: npx playwright test
Note that in the above, I disabled concurrency within the same branch, but the workflow may run concurrently for different branches.
Currently, I get the following error:
compose up failed {"exitCode":1,"err":"yaml.constructor.ConstructorError: could not determine a constructor for the tag '!reset'\n in \"./docker-compose.e2e.yaml\", line 10, column 14\n","out":""}
I believe that using (or allowing) the v2 bindings may allow us to use new feature from the spec
Update - This can run docker-compose
v2, however, the machine running this needs to alias docker-compose
to the plugin binary.
A good enough way is to symlink it, https://stackoverflow.com/a/76909275/9238801
ln -f -s /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose
::error::compose up failed {"errno":-2,"code":"ENOENT","syscall":"spawn docker-compose","path":"docker-compose","spawnargs":["-f","./docker-compose.yml","up","-d"]}
Here we are trying to spawn docker-compose but as per latest version it's docker compose
Can I run Load/ Integration test on a project hosting multiple microservice with this workflow ?
Say my project is :https://github.com/harshraj22/Dis-Sim
and my test is in test.py or set of tests are in tests/
dir.
If yes, can you share sample code yaml file ?
My test command randomly fails. I have test-command: "yarn run test"
. Which works - but not always. It will fail, then I re-run failed jobs and it passes (with no code change).
When it fails, it says jest is not found (what I run my tests via).
Here's some output:
compose started
testContainer app
testCommand yarn run test
yarn run v1.22.19
$ NODE_ENV=TESTING jest --detectOpenHandles
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
/bin/sh: jest: not found
error Command failed with exit code 127.
Error: tests failed {"exitCode":127,"err":"/bin/sh: jest: not found\nerror Command failed with exit code 127.\n","out":"yarn run v1.22.19\n$ NODE_ENV=TESTING jest --detectOpenHandles\ninfo Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\n"}
And here's my innocuous test script (from within a package.json file):
"test": "NODE_ENV=TESTING jest --detectOpenHandles",
And here's the whole task runner:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: adambirds/[email protected]
with:
compose-file: "./docker-compose-test.yml"
down-flags: "--volumes"
test-container: app
test-command: "yarn run test"
```
Any idea what could be causing this, or how to address?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.