-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (67 loc) · 2.58 KB
/
test.yml
File metadata and controls
77 lines (67 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
name: Test
on:
workflow_call:
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Rails 8.0 depends on Ruby >= 3.2
ruby-version: ['3.1', '3.2', '3.3']
gemfile: [ rails_6.1, rails_7.0, rails_7.1, rails_7.2, rails_8.0 ]
exclude:
- ruby-version: '3.1'
gemfile: rails_8.0
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
rubygems: 3.4.10
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run linter
if: matrix.ruby-version == '3.3' && matrix.gemfile == 'rails_7.2'
run: bundle exec rubocop
- name: Run tests
run: bundle exec rspec
- name: Archive coverage
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v4
with:
name: code-coverage-report-ruby_${{ matrix.ruby-version }}-${{ matrix.gemfile }}
path: ${{ github.workspace }}/coverage/
include-hidden-files: true
post_coverage:
runs-on: ubuntu-latest
needs: test
permissions:
pull-requests: write
steps:
- uses: actions/download-artifact@v4
with:
name: code-coverage-report-ruby_3.2-rails_7.1
path: coverage/
- name: Install JQ
run: sudo apt-get install -y jq
- name: Determine coverage
id: coverage
run: |
# Check to see if coverage is under `result.line` or under `result.covered_percent` (older versions)
coverage=$(jq -r 'if .result.line then .result.line else .result.covered_percent end' < coverage/.last_run.json)
[ "${coverage}" = "null" ] && coverage="** Failed to determine coverage **"
echo value="${coverage}" >> "$GITHUB_OUTPUT"
- uses: mshick/add-pr-comment@v2
with:
message: |
* GitHub Actions [run \#${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
Test coverage: ${{ steps.coverage.outputs.value }}%