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(tests): add code coverage reporting #891

Merged
merged 10 commits into from
Nov 27, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ jobs:
with:
sha: ${{ needs.merge.outputs.sha }}
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}

publish_image:
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
required: false
type: string
secrets:
codecov_token:
description: Codecov token
required: true
rails_master_key:
description: The Rails master key
required: true
Expand Down Expand Up @@ -119,5 +122,21 @@ jobs:
env:
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
run: |
mkdir coverage
docker run -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_HOST=localhost -e \
RAILS_MASTER_KEY --network=host app bin/ci.sh spec
RAILS_MASTER_KEY --network=host -v "$(pwd)"'/coverage:/app/coverage' app bin/ci.sh spec

- name: Upload coverage report to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload coverage report artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: coverage
path: coverage/
if-no-files-found: error
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ group :test do
gem 'rubocop-rails'
gem 'rubocop-rspec'
gem 'simplecov', require: false
gem 'simplecov-lcov', '~> 0.8.0', require: false
gem 'terminal-notifier-guard'
gem 'timecop'
end
Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ GEM
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
slack-notifier (2.4.0)
spring (2.1.1)
Expand Down Expand Up @@ -593,6 +594,7 @@ DEPENDENCIES
sidekiq-scheduler (~> 5.0.2)
simple_form (~> 5.1.0)
simplecov
simplecov-lcov (~> 0.8.0)
slack-notifier (~> 2.4.0)
spring
spring-commands-rspec
Expand All @@ -609,4 +611,4 @@ DEPENDENCIES
wkhtmltopdf-binary

BUNDLED WITH
2.2.15
2.4.14
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Alpha SOFIA

[![Continuous Integration](https://github.com/csvalpha/sofia/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/csvalpha/sofia/actions/workflows/continuous-integration.yml)
[![Continuous Delivery](https://github.com/csvalpha/sofia/actions/workflows/continuous-delivery.yml/badge.svg)](https://github.com/csvalpha/sofia/actions/workflows/continuous-delivery.yml)
[![codecov](https://codecov.io/github/csvalpha/sofia/graph/badge.svg?token=RGR5PARLD5)](https://codecov.io/github/csvalpha/sofia)

The source code belonging to Alpha SOFIA. It is a system built with Ruby on Rails with Turbolinks and a little VueJS, used to manage orders in our own bar "Flux". Users authenticate via OAuth API (currently "Alpha AMBER") to see how much credit they got left, or to be able to register new orders and/or payments.

Expand Down
13 changes: 4 additions & 9 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
require 'simplecov'
require 'simplecov-lcov'

SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
SimpleCov.start 'rails' do
add_filter 'app/controllers/'
add_filter 'app/jobs/'
add_filter 'app/mailers/'
add_filter 'app/policies/'
add_filter 'app/views/'
add_filter 'lib/'

minimum_coverage 95
minimum_coverage_by_file 95
# minimum_coverage 95
# minimum_coverage_by_file 95
end

RSpec.configure do |config|
Expand Down
Loading