Running tests inside a Docker container is a popular technique, and with one small extra step Codecov will integrate seamlessly. Because of the containerization, reports generated in the container are not retrievable outside of it, but we have two techniques to help Codecov collect reports.
The easiest and most popular technique is to pass environment variables through the container.
# request codecov to detect CI environment to pass through to docker ci_env=`bash <(curl -s https://codecov.io/env)` docker run $ci_env -e CI=true ... |----- inside docker container | # exec tests | # Your Codecov Uploader approach here | # See more at https://docs.codecov.com/docs/codecov-uploader | ./codecov
Pass coverage reports out of the container through a mounted directory, and then run Codecov. This requires you to know the report files and where to put them.
# create a shared folder to store reports in mkdir shared # include shared folder when running docker # make sure you move your reports into the shared folder while in docker docker run -v "$PWD/shared:/shared" ... |----- inside docker container | # run test | mv coverage.txt shared # now run codecov in project directory to discover reports in shared folder # Your Codecov Uploader approach here # See more at https://docs.codecov.com/docs/codecov-uploader ./codecov
Updated about 1 month ago