Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrating openfoodfacts-server with codecov for unit test coverage #8016

Merged
merged 20 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Unit Test Coverage

on: [push]
jobs:
coverage:
name: unit test coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
# Before rebuilding the taxonomies, we do this to restore dates so we don't have to build all taxonomies
# Prior usage in .github/workflows/pull_request.yml
- name: rebuild taxonomies
run: |
git ls-files taxonomies/ | xargs -I{} git log -1 --date=format:%Y%m%d%H%M.%S --format='touch -t %ad "{}"' "{}" | bash
yuktea marked this conversation as resolved.
Show resolved Hide resolved
make build_taxonomies
- uses: actions/checkout@master
- name: generate coverage results
run: make cover
- name: generate text file with results
if: always()
run: make coverage_txt
- name: use codecov
if: always()
run: make codecov
- uses: codecov/codecov-action@v3
if: always()
with:
files: cover_db/codecov.json
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ tail:
@echo "🥫 Reading logs (Apache2, Nginx) …"
tail -f logs/**/*

cover:
@echo "🥫 running …"
${DOCKER_COMPOSE_TEST} up -d memcached postgres mongodb
${DOCKER_COMPOSE_TEST} run --rm backend perl -I/opt/product-opener/lib -I/opt/perl/local/lib/perl5 /opt/product-opener/scripts/build_lang.pl
${DOCKER_COMPOSE_TEST} run --rm -e HARNESS_PERL_SWITCHES="-MDevel::Cover" backend prove -l tests/unit
${DOCKER_COMPOSE_TEST} stop

codecov:
@echo "🥫 running …"
${DOCKER_COMPOSE_TEST} run --rm backend cover -report codecovbash

coverage_txt:
${DOCKER_COMPOSE_TEST} run --rm backend cover

#----------#
# Services #
Expand Down
6 changes: 6 additions & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ on 'test' => sub {
requires 'HTTP::CookieJar::LWP';
requires 'File::Tail';
requires 'Test2::Plugin::UTF8';
requires 'Devel::Cover';
requires 'Devel::Cover::Report::Codecov';
requires 'Devel::Cover::Report::Codecovbash';
};

on 'develop' => sub {
Expand All @@ -104,6 +107,9 @@ on 'develop' => sub {
requires 'Apache::DB', '>= 0.18, < 1.00'; # old non-working version also available as the Debian package libapache-db-perl 0.14
requires 'Perl::Tidy';
requires 'Perl::Critic';
requires 'Devel::Cover';
requires 'Devel::Cover::Report::Codecov';
requires 'Devel::Cover::Report::Codecovbash';
};

feature "off_server_dev_tools", "Optional development tools" => sub {
Expand Down