-
Notifications
You must be signed in to change notification settings - Fork 633
151 lines (140 loc) · 4.19 KB
/
main.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
name: Main
on:
push:
branches: ["main"]
pull_request:
workflow_dispatch:
permissions:
contents: read
env:
CC_TEST_REPORTER_ID: "ac477089fe20ab4fc7e0d304cab75f72d73d58a7596d366935d18fcc7d51f8f9"
# `github.ref` points to the *merge commit* when running tests on a pull request, which will be a commit
# that doesn't exists in our code base. Since this workflow triggers from a PR, we use the HEAD SHA instead.
#
# NOTE: These are both used by Code Climate (cc-test-reporter).
GIT_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
GIT_BRANCH: ${{ github.head_ref }}
jobs:
matrix-test:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allow-failure || false }}
strategy:
fail-fast: false
matrix:
ruby-version:
- "3.1"
- "3.2"
- "3.3"
- "jruby-9.3.10" # oldest supported jruby
- "jruby"
include: # HEAD-versions
- ruby-version: "head"
allow-failure: true
- ruby-version: "jruby-head"
allow-failure: true
- ruby-version: "truffleruby-head"
allow-failure: true
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
rubygems: latest
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: ${{ !startsWith(matrix.ruby-version, 'jruby') }}
- name: Bundler install (JRuby workaround)
if: ${{ startsWith(matrix.ruby-version, 'jruby') }}
run: |
gem install psych
bundle install
- name: Run tests
run: bundle exec rspec
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
rubygems: latest
ruby-version: "ruby"
bundler-cache: true
- name: "Download cc-test-reporter from codeclimate.com"
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- name: "Report to Code Climate that we will send a coverage report."
run: ./cc-test-reporter before-build
- name: Run tests
run: bundle exec rspec
env:
COVERAGE: 1
- name: Upload coverage results
uses: actions/upload-artifact@v4
with:
include-hidden-files: true
name: coverage-results
path: coverage
retention-days: 1
- name: Upload code coverage to Code Climate
run: |
./cc-test-reporter after-build \
--coverage-input-type simplecov \
./coverage/.resultset.json
coverage-check:
permissions:
checks: write
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download coverage results
uses: actions/download-artifact@v4
with:
name: coverage-results
path: coverage
- uses: joshmfrankel/simplecov-check-action@be89e11889202cc59efb14aab2a7091622fa9aad
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
minimum_suite_coverage: 100
minimum_file_coverage: 100
coverage_json_path: coverage/simplecov-check-action.json
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
rubygems: default
ruby-version: "ruby"
bundler-cache: false
- run: bundle install
- name: Run RuboCop
run: bundle exec rubocop
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
rubygems: default
ruby-version: "ruby"
bundler-cache: false
- run: bundle install
- run: rake yard
required-checks:
runs-on: ubuntu-latest
if: ${{ always() }}
needs:
- test
- matrix-test
- docs
- rubocop
steps:
- name: failure
if: ${{ failure() || contains(needs.*.result, 'failure') }}
run: exit 1
- name: success
run: exit 0