Skip to content

Commit 7133fe4

Browse files
committed
chore(ci): report coverage
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent e9ea4e3 commit 7133fe4

4 files changed

Lines changed: 54 additions & 2 deletions

File tree

.github/workflows/ruby.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ on:
1414
# see https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token
1515
permissions: {}
1616

17+
concurrency:
18+
group: '${{ github.workflow }}-${{ github.ref }}'
19+
cancel-in-progress: true
20+
21+
env:
22+
COVERAGE_DIR: coverage
23+
TESTS_COVERAGE_ARTIFACT: coverage
24+
1725
jobs:
1826
test:
1927
name: Ruby ${{ matrix.ruby }}
@@ -39,3 +47,39 @@ jobs:
3947
bundler-cache: true
4048
- name: Run the default task
4149
run: bundle exec rake
50+
- name: Artifact coverage
51+
if: ${{ ! cancelled() }}
52+
# see https://github.com/actions/upload-artifact
53+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
54+
with:
55+
name: '${{ env.TESTS_COVERAGE_ARTIFACT }}_ruby${{ matrix.ruby }}'
56+
path: ${{ env.COVERAGE_DIR }}
57+
if-no-files-found: error
58+
retention-days: 7
59+
report-coverage:
60+
name: Publish test coverage
61+
needs: [ "test" ]
62+
runs-on: ubuntu-latest
63+
timeout-minutes: 5
64+
steps:
65+
- name: fetch test artifacts
66+
# see https://github.com/actions/download-artifact
67+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
68+
with:
69+
pattern: '${{ env.TESTS_COVERAGE_ARTIFACT }}_*'
70+
merge-multiple: false
71+
path: ${{ env.COVERAGE_DIR }}
72+
- run: |
73+
ls -lisah "$COVERAGE_DIR"
74+
tree "$COVERAGE_DIR"
75+
dhjsakdhsad # debug break
76+
- name: Run codacy-coverage-reporter
77+
env:
78+
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
79+
## see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-secrets
80+
if: ${{ env.CODACY_PROJECT_TOKEN != '' }}
81+
# see https://github.com/codacy/codacy-coverage-reporter-action
82+
uses: codacy/codacy-coverage-reporter-action@89d6c85cfafaec52c72b6c5e8b2878d33104c699 # v1
83+
with:
84+
project-token: ${{ env.CODACY_PROJECT_TOKEN }}
85+
coverage-reports: ${{ env.COVERAGE_DIR }}/**/coverage.xml

.simplecov

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# frozen_string_literal: true
22

3+
require 'simplecov-cobertura'
4+
5+
SimpleCov.formatters = [
6+
SimpleCov::Formatter::HTMLFormatter,
7+
SimpleCov::Formatter::CoberturaFormatter
8+
]
9+
310
# Copied from https://github.com/cucumber/aruba/blob/3b1a6cea6e3ba55370c3396eef0a955aeb40f287/.simplecov
411
# Licensed under MIT - https://github.com/cucumber/aruba/blob/3b1a6cea6e3ba55370c3396eef0a955aeb40f287/LICENSE
512

cyclonedx-ruby.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Gem::Specification.new do |spec|
6464
spec.add_development_dependency 'cucumber', '>= 9.2.0', '< 11'
6565
spec.add_development_dependency 'aruba', '~> 2.2'
6666
spec.add_development_dependency 'simplecov', '~> 0.22.0'
67+
spec.add_development_dependency 'simplecov-cobertura'
6768
spec.add_development_dependency 'rubocop', '~> 1.54'
6869
spec.add_development_dependency 'stone_checksums', '~> 1.0', '>= 1.0.3'
6970
end

spec/spec_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
require 'simplecov'
1919
SimpleCov.command_name 'RSpec'
2020

21-
# Run simplecov by default
22-
SimpleCov.start unless ENV.key? 'ARUBA_NO_COVERAGE'
21+
aruba_no_coverage = ENV.fetch('ARUBA_NO_COVERAGE', 'false')
22+
SimpleCov.start unless aruba_no_coverage.casecmp?('true')
2323
end
2424
# End copied from Aruba
2525

0 commit comments

Comments
 (0)