From 756b3a6ee59df62ee2125559956d8f170231d944 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 31 Mar 2021 08:56:58 +0200 Subject: [PATCH 1/4] Upload coverage report after every CI job --- .github/workflows/build.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2523d7d42..3f49f389d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,6 +51,9 @@ jobs: - name: Run controller tests run: bundle exec rspec --profile -- spec/controllers spec/serializers + - name: Codecov + uses: codecov/codecov-action@v1.3.1 + test-models: runs-on: ubuntu-18.04 services: @@ -92,6 +95,9 @@ jobs: - name: Run tests run: bundle exec rspec --profile -- spec/models + - name: Codecov + uses: codecov/codecov-action@v1.3.1 + test-admin-features-1: runs-on: ubuntu-18.04 services: @@ -133,6 +139,9 @@ jobs: - name: Run admin feature tests run: bundle exec rspec --profile -- spec/features/admin/[a-o0-9]*_spec.rb + - name: Codecov + uses: codecov/codecov-action@v1.3.1 + test-admin-features-2: runs-on: ubuntu-18.04 services: @@ -174,6 +183,9 @@ jobs: - name: Run admin feature tests run: bundle exec rspec --profile -- spec/features/admin/[p-z]*_spec.rb + - name: Codecov + uses: codecov/codecov-action@v1.3.1 + test-consumer-features: runs-on: ubuntu-18.04 services: @@ -215,6 +227,9 @@ jobs: - name: Run consumer feature tests run: bundle exec rspec --profile -- spec/features/consumer + - name: Codecov + uses: codecov/codecov-action@v1.3.1 + test-engines-etc: runs-on: ubuntu-18.04 services: @@ -299,3 +314,6 @@ jobs: - name: Run admin feature folders, engines, lib run: bundle exec rspec --profile --pattern "engines/*/spec/{,/*/**}/*_spec.rb,spec/features/admin/*/*_spec.rb,spec/lib/{,/*/**}/*_spec.rb" + + - name: Codecov + uses: codecov/codecov-action@v1.3.1 From b2840aaebfd2ad39e328fcc707589d34856c1c74 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 31 Mar 2021 09:21:46 +0200 Subject: [PATCH 2/4] Enable coverage in CI and use Codecov formatter --- .github/workflows/build.yml | 1 + .simplecov | 3 +++ Gemfile | 1 + Gemfile.lock | 3 +++ 4 files changed, 8 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f49f389d1..cd38d3c590 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,7 @@ on: env: DISABLE_KNAPSACK: true TIMEZONE: UTC + COVERAGE: true jobs: test-controllers-and-serializers: diff --git a/.simplecov b/.simplecov index ed6f826b48..f508e4b61f 100644 --- a/.simplecov +++ b/.simplecov @@ -16,3 +16,6 @@ SimpleCov.start 'rails' do add_filter '/log' add_filter '/db' end + +require 'codecov' +SimpleCov.formatter = SimpleCov::Formatter::Codecov diff --git a/Gemfile b/Gemfile index a529d9c0ed..0b69e23018 100644 --- a/Gemfile +++ b/Gemfile @@ -141,6 +141,7 @@ group :test, :development do end group :test do + gem 'codecov', require: false gem 'simplecov', require: false gem 'test-prof' gem 'webmock' diff --git a/Gemfile.lock b/Gemfile.lock index 41b0c72cf3..e913549cd2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -152,6 +152,8 @@ GEM climate_control (0.2.0) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) + codecov (0.5.1) + simplecov (>= 0.15, < 0.22) coderay (1.1.3) coffee-rails (4.2.2) coffee-script (>= 2.2.0) @@ -618,6 +620,7 @@ DEPENDENCIES cancancan (~> 1.15.0) capybara catalog! + codecov coffee-rails (~> 4.2.2) combine_pdf compass-rails From 8a5762afba6fc63a88b28bfcdff742f4217efad4 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 31 Mar 2021 09:35:24 +0200 Subject: [PATCH 3/4] Remove minimum coverage This clashes with Codecov coverage uploading. If the tests fail chances are that they didn't hit the threshold and thus, won't be uploaded to Codecov. --- .simplecov | 2 -- 1 file changed, 2 deletions(-) diff --git a/.simplecov b/.simplecov index f508e4b61f..e1ed14aec0 100644 --- a/.simplecov +++ b/.simplecov @@ -1,8 +1,6 @@ #!/bin/env ruby SimpleCov.start 'rails' do - minimum_coverage 54 - add_filter '/bin/' add_filter '/config/' add_filter '/jobs/application_job.rb' From 7857487bbb6c7e94a3a8e3b167c7dcaad978676a Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 31 Mar 2021 10:39:29 +0200 Subject: [PATCH 4/4] Add coverage badge to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0f84dc3968..605e79b00d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Build](https://github.com/openfoodfoundation/openfoodnetwork/actions/workflows/build.yml/badge.svg)](https://github.com/openfoodfoundation/openfoodnetwork/actions/workflows/build.yml) +[![codecov](https://codecov.io/gh/openfoodfoundation/openfoodnetwork/branch/master/graph/badge.svg?token=FBSOod4qiu)](https://codecov.io/gh/openfoodfoundation/openfoodnetwork) [![Code Climate](https://codeclimate.com/github/openfoodfoundation/openfoodnetwork.png)](https://codeclimate.com/github/openfoodfoundation/openfoodnetwork) # Open Food Network