-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (156 loc) · 4.94 KB
/
ci.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
161
name: Tests & Linting
on: pull_request
permissions:
contents: read
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.0
bundler-cache: true
- name: rubocop
uses: reviewdog/action-rubocop@v2
with:
skip_install: true # use bundler
use_bundler: true
rubocop_flags: '--config .rubocop.yml'
fail_on_error: true
rspec-matrix:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby:
- '3.0'
- '3.1'
- '3.2'
- '3.3'
gemfile:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- '3.13'
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rspec-${{ matrix.gemfile }}.gemfile
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Setup abq
uses: rwx-research/setup-abq@v1
with:
access-token: ${{ secrets.RWX_ACCESS_TOKEN }}
- uses: rwx-research/setup-captain@v1
- name: run rspec & upload to captain
run: |
captain run \
--suite-id rspec-abq \
--test-results tmp/rspec.json \
-- \
bundle exec rspec \
--format json --out tmp/rspec.json \
--format documentation && bin/check_num_tests.rb
if: ${{ matrix.ruby == 3.1 && matrix.gemfile == 3.13 }}
env:
RWX_ACCESS_TOKEN: ${{ secrets.RWX_ACCESS_TOKEN }}
timeout-minutes: 5
- name: run rspec without uploading to captain
run: |
bundle exec rspec \
--format json --out tmp/rspec.json \
--format documentation && bin/check_num_tests.rb
if: ${{ matrix.ruby != 3.1 || matrix.gemfile != 3.13 }}
timeout-minutes: 5
- name: Upload Coverage
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage-${{ matrix.ruby }}-${{ matrix.gemfile }}
path: coverage/.resultset.json
# strategy borrowed from https://brunoscheufler.com/blog/2022-04-09-the-required-github-status-check-that-wasnt
# this is used to summarize the matrix results into a single job (abq-work) that can be used as a required check
collate-coverage:
needs: rspec-matrix
runs-on: ubuntu-latest
if: always()
steps:
- uses: actions/checkout@v3
- name: download coverage reports
uses: actions/download-artifact@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.0
bundler-cache: true
- name: collate coverage
run: |
gem install simplecov
ruby -e 'require "simplecov"; SimpleCov.collate Dir["**/.resultset.json"] { add_filter "/spec/" }'
- name: Upload Coverage
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage/
rspec-github-workflow-wrapup-helper:
needs: rspec-matrix # run after shards
runs-on: ubuntu-latest
if: success() # only run when matrix passed
# store success output flag for ci job
outputs:
success: ${{ steps.setoutput.outputs.success }}
steps:
- id: setoutput
run: echo "success=true" >> "$GITHUB_OUTPUT"
rspec:
runs-on: ubuntu-latest
if: always() # always run, so we never skip the check
needs: rspec-github-workflow-wrapup-helper
steps:
# pass step only when output of previous after-shards job is set
# in case at least one of the shard fails, after-shards is skipped
# and the output will not be set, which will then cause the ci job to fail
- run: |
passed="${{ needs.rspec-github-workflow-wrapup-helper.outputs.success }}"
if [[ $passed == "true" ]]; then
echo "Shards passed"
exit 0
else
echo "Shards failed"
exit 1
fi
nixfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v18
- run: nix fmt -- --check flake.nix
yard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.0
bundler-cache: true
- run: bin/check_yard
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lint github workflows
run: |
echo "::add-matcher::.github/actionlint-matcher.json"
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/3a2f2c755b6442ec7999b28dfd107e1bb9853389/scripts/download-actionlint.bash)
./actionlint -color
shell: bash