Skip to content

Commit

Permalink
Merge pull request #1194 from metacpan/oalders/devel-cover
Browse files Browse the repository at this point in the history
Enable code coverage
  • Loading branch information
mickeyn authored Apr 28, 2024
2 parents 29aef23 + 74eb5a4 commit 9e889ac
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference
---
# Use the latest 2.1 version of CircleCI pipeline process engine. See:
# https://circleci.com/docs/2.0/configuration-reference
version: 2.1
# Orchestrate or schedule a set of jobs
workflows:
Expand Down Expand Up @@ -44,10 +46,34 @@ jobs:
pushd metacpan-docker
./src/metacpan-api/wait-for-es.sh http://localhost:9200 elasticsearch_test --
name: wait for ES
# We are running coverage inside the container, but creating the report
# from outside of the container, so Devel::Cover is installed twice. We
# are relying on environment variables from the host to be available when
# we publish the report, so we publish from the host rather than trying
# to propagate env variables to the container. There is a CircleCI orb
# that can publish the report for us, but it is hard to debug. I had to
# set up the following config in order to debug the orb, so we may as
# well keep it around for now.
- run:
command: |
pushd metacpan-docker
docker-compose exec -T api_test prove -lr --jobs 2 t
docker-compose exec -T api_test cpm install -g Devel::Cover
name: install Devel::Cover
- run:
command: |
pushd metacpan-docker
docker-compose exec -T api_test env HARNESS_PERL_SWITCHES="-MDevel::Cover=+ignore,^t/|^test-data/|^etc/" prove -lr --jobs 2 t
name: run tests with coverage
# The report ends up being owned by root. We need to chown it so that
# the cover command can make changes to it.
- run:
command: |
pushd metacpan-docker/src/metacpan-api
sudo apt install cpanminus
sudo cpanm --notest Devel::Cover Devel::Cover::Report::Codecov Devel::Cover::Report::Codecovbash
sudo chown -R circleci.circleci cover_db
cover -report codecov
name: upload coverage report
- run:
command: |
pushd metacpan-docker
Expand Down

0 comments on commit 9e889ac

Please sign in to comment.