-
Notifications
You must be signed in to change notification settings - Fork 45
160 lines (158 loc) · 5.09 KB
/
checks.yml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: checks
on:
pull_request:
paths-ignore:
- .gitignore
- CHANGELOG.md
- CONTRIBUTING.md
- README.md
push:
paths-ignore:
- .gitignore
- CHANGELOG.md
- CONTRIBUTING.md
- README.md
jobs:
linter:
name: Run StandardRB linter
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: gemfiles/activerecord_7.1.gemfile
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Run StandardRB
id: offenses
run: |
echo "LINTER_OFFENSES<<EOF" >> $GITHUB_OUTPUT
echo "$(${{ matrix.env }} bundle exec standardrb)" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Print offenses
if: steps.offenses.outputs.LINTER_OFFENSES
run: |
echo '${{ steps.offenses.outputs.LINTER_OFFENSES }}'
- name: Fail if StandardRB offenses found
if: steps.offenses.outputs.LINTER_OFFENSES
uses: actions/github-script@v6
with:
script: "core.setFailed('StandardRB linter offenses found. Please inspect the details \
of the previous step in the job for more info.')"
tests:
name: Run tests (ruby ${{ matrix.ruby }}, rails ${{ matrix.rails }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- ruby: '3.2'
rails: '7.1'
- ruby: '3.1'
rails: '7.1'
- ruby: '3.0'
rails: '7.1'
- ruby: '2.7'
rails: '7.1'
- ruby: '3.2'
rails: '7.0'
- ruby: '3.1'
rails: '7.0'
- ruby: '3.1'
rails: '6.1'
- ruby: '3.0'
rails: '7.0'
- ruby: '3.0'
rails: '6.1'
- ruby: '2.7'
rails: '7.0'
- ruby: '2.7'
rails: '6.1'
- ruby: '2.7'
rails: '6.0'
- ruby: '2.6'
rails: '6.1'
- ruby: '2.6'
rails: '6.0'
- ruby: '2.5'
rails: '6.1'
- ruby: '2.5'
rails: '6.0'
- ruby: 'jruby'
rails: '7.0'
- ruby: 'jruby'
rails: '6.1'
- ruby: 'truffleruby'
rails: '7.1'
- ruby: 'truffleruby'
rails: '7.0'
- ruby: 'truffleruby'
rails: '6.1'
- ruby: 'truffleruby'
rails: '6.0'
env:
BUNDLE_GEMFILE: gemfiles/activerecord_${{ matrix.rails }}.gemfile
SKIPPED_ADAPTERS: ${{ matrix.skipped_adapters }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup MySQL and PostgreSQL via Docker Compose
run: docker compose up -d --wait
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake spec
- name: Upload code coverage results as artifacts
uses: actions/upload-artifact@v3
with:
name: coverage-ruby-${{ matrix.ruby }}-rails-${{ matrix.rails }}
path: coverage/.resultset.json
coverage:
name: Calculate test coverage
needs: tests
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: gemfiles/activerecord_7.1.gemfile
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: coverage-resultsets
- name: Display structure of downloaded files
run: ls -Rla
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Collate coverage reports
run: ${{ matrix.env }} bundle exec rake ci:coverage:collate
- name: Upload total code coverage result as an artifact
uses: actions/upload-artifact@v3
with:
name: coverage-total
path: coverage/.last_run.json
- name: Fetch total coverage values from simplecov files
id: coverage
run: |
echo "COVERAGE_LINE=$(cat coverage/.last_run.json | jq '.result.line')" >> $GITHUB_OUTPUT
echo "COVERAGE_BRANCH=$(cat coverage/.last_run.json | jq '.result.branch')" >> $GITHUB_OUTPUT
- name: Print total coverage
run: |
echo "Total line test coverage: ${{ steps.coverage.outputs.COVERAGE_LINE }}%"
echo "Total branch test coverage: ${{ steps.coverage.outputs.COVERAGE_BRANCH }}%"
- name: Fail if coverage is less than 100%
if: steps.coverage.outputs.COVERAGE_LINE != 100 || steps.coverage.outputs.COVERAGE_BRANCH != 100
uses: actions/github-script@v6
with:
script: "core.setFailed('Please make sure test coverage is 100%. \
Currently: ${{ steps.coverage.outputs.COVERAGE_LINE }}% (line), \
${{ steps.coverage.outputs.COVERAGE_BRANCH }}% (branch).')"