I'm a bit of a newbie, but I have an Atlassian Bamboo build that builds two services/containers with docker-compose, runs tests with pytest on the services, and in theory should fail the build if the coverage of the tests is under certain threshold.
I have docker-compose.yml file with the 2 services (service_1 and service_2) that have the following commands:
command:
- "pytest"
- "-slvk"
- ""
- "-m"
- "marker_1"
- "--cov=path/submodule"
- "--cov-report"
- "term-missing"
So the sequence of steps is as follows (simplified):
1. docker-compose -f tests/docker-compose.yml up service_1
2. docker-compose -f tests/docker-compose.yml up service_2
3. docker-compose -f tests/docker-compose.yml run --rm service_1 coverage report --fail-under 90
4. docker-compose -f tests/docker-compose.yml run --rm service_2 coverage report --fail-under 90
The tests are executed according to the commands in the docker-compose.yml and I can see the report generated. So steps 1 and 2 are successfully executed.
The problem is that the coverage reports in steps 3 and 4 are generated for identical and created for the last created container, in this case service_2, but if i switch the places of steps 1 and 2, then the coverage would refer to service_1.