Skip to content

Commit a95b6d9

Browse files
committed
Add coverage reporting and Qlty integration
- Add SimpleCov + simplecov-json for coverage (96.92%) - Coverage runs on Ruby 3.3 + ActiveModel 8.0, uploads to Qlty - Add Qlty code quality checks and bundle audit security job - Add maintainability and coverage badges to README
1 parent c51291d commit a95b6d9

3 files changed

Lines changed: 80 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ on:
66
pull_request:
77
branches: [main]
88

9+
permissions:
10+
actions: write
11+
contents: read
12+
id-token: write
13+
packages: write
14+
915
jobs:
1016
test:
1117
runs-on: ubuntu-latest
@@ -36,5 +42,64 @@ jobs:
3642
ruby-version: ${{ matrix.ruby }}
3743
bundler-cache: true
3844

39-
- name: Run specs
45+
- name: Run tests with coverage
4046
run: bundle exec rake spec
47+
env:
48+
COVERAGE: ${{ matrix.ruby == '3.3' && matrix.gemfile == 'gemfiles/Gemfile.activemodel-8.0' && 'true' || '' }}
49+
50+
- name: Upload coverage artifact
51+
if: matrix.ruby == '3.3' && matrix.gemfile == 'gemfiles/Gemfile.activemodel-8.0'
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: coverage-report
55+
path: coverage/
56+
retention-days: 1
57+
58+
coverage:
59+
runs-on: ubuntu-latest
60+
needs: test
61+
if: always()
62+
63+
steps:
64+
- uses: actions/checkout@v4
65+
66+
- name: Download coverage artifact
67+
uses: actions/download-artifact@v4
68+
with:
69+
name: coverage-report
70+
path: coverage/
71+
continue-on-error: true
72+
73+
- name: Upload coverage to Qlty
74+
uses: qltysh/qlty-action/coverage@v1
75+
continue-on-error: true
76+
env:
77+
QLTY_COVERAGE_TOKEN: ${{ secrets.QLTY_COVERAGE_TOKEN }}
78+
with:
79+
oidc: true
80+
files: coverage/coverage.json
81+
82+
- name: Run Qlty code quality checks
83+
run: |
84+
curl -sSfL https://qlty.sh | sh
85+
echo "$HOME/.qlty/bin" >> $GITHUB_PATH
86+
~/.qlty/bin/qlty check || true
87+
continue-on-error: true
88+
89+
security:
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- uses: actions/checkout@v4
94+
95+
- name: Set up Ruby
96+
uses: ruby/setup-ruby@v1
97+
with:
98+
ruby-version: "3.3"
99+
bundler-cache: true
100+
101+
- name: Run bundle audit
102+
run: |
103+
gem install bundler-audit
104+
bundle audit --update || true
105+
continue-on-error: true

him.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Gem::Specification.new do |s|
2222

2323
s.add_development_dependency "rake", ">= 13.0"
2424
s.add_development_dependency "rspec", "~> 3.5"
25+
s.add_development_dependency "simplecov"
26+
s.add_development_dependency "simplecov-json"
2527

2628
s.add_runtime_dependency "activemodel", ">= 6.1"
2729
s.add_runtime_dependency "faraday", ">= 2.0"

spec/spec_helper.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
22

3+
if ENV["COVERAGE"]
4+
require "simplecov"
5+
require "simplecov-json"
6+
SimpleCov.start do
7+
add_filter "spec"
8+
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
9+
SimpleCov::Formatter::HTMLFormatter,
10+
SimpleCov::Formatter::JSONFormatter
11+
])
12+
end
13+
end
14+
315
require "rspec"
416
require "him"
517

0 commit comments

Comments
 (0)