Repository navigation
208 lines (206 loc) · 7.39 KB
/
Copy pathci.yml
File metadata and controls
208 lines (206 loc) · 7.39 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# 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 install a prebuilt Ruby version, install dependencies, and
# run tests and linters.
name: "Lint & Tests"
permissions:
contents: read
pull-requests: write
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
lint:
# This is Ubuntu 24.04 currently: https://github.com/actions/runner-images/blob/ubuntu24/20250907.24/images/ubuntu/Ubuntu2404-Readme.md
# Building an own image is not worth it, pulling it in gh actions
# is about as slow as installing the dependencies and it blocks using cached gems
runs-on: ubuntu-latest
#container:
# image: ghcr.io/mapforge-org/mapforge-ci-runner:latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update package lists
run: sudo apt-get update
- name: Disable mandb updates
run: |
sudo mv /usr/bin/mandb /usr/bin/mandb.bak
echo -e '#!/bin/sh\nexit 0' | sudo tee /usr/bin/mandb > /dev/null
sudo chmod +x /usr/bin/mandb
- name: Install dependencies
run: sudo apt-get install --no-install-recommends -y libimlib2-dev
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
# caches by Gemfile.lock checksum
bundler-cache: true
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install npm dependencies
run: npm ci --ignore-scripts
- name: Security audit dependencies
run: bin/bundler-audit --update
- name: Security audit application code
run: bin/brakeman -q -w2
- name: Lint Ruby files
run: bin/rubocop --parallel
- name: Lint Javascript
run: npm run lint:js
- name: Lint CSS
run: npm run lint:css
test:
runs-on: ubuntu-latest
# The runner is too weak for more than 2 headless Chrome instances, so every job
# keeps 2 processes and the fan out happens over jobs. All jobs must compute the
# same 6 groups, so they must read the same runtime log. Only the coverage job
# writes that cache.
strategy:
fail-fast: false
matrix:
include:
- part: 1
groups: "1,2"
- part: 2
groups: "3,4"
- part: 3
groups: "5,6"
#container:
# image: ghcr.io/mapforge-org/mapforge-ci-runner:latest
services:
mongodb:
image: mongo:8.3
ports:
- 27017:27017
# credentials are only needed when not running on ubuntu-latest VM
# credentials:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_TOKEN }}
env:
RAILS_ENV: test
COVERAGE: true
CI_PART: ${{ matrix.part }} # turns off the per job coverage minimum
SE_AVOID_STATS: true # skip Selenium stats
SE_DISABLE_REMOTE_MANAGER: true # skip Selenium plausible telemetry
# MONGO_URL is only needed when not running on ubuntu-latest VM
# MONGO_URL: "mongodb:27017"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update package lists
run: sudo apt-get update
- name: Disable mandb updates
run: |
sudo mv /usr/bin/mandb /usr/bin/mandb.bak
echo -e '#!/bin/sh\nexit 0' | sudo tee /usr/bin/mandb > /dev/null
sudo chmod +x /usr/bin/mandb
- name: Install dependencies
# run: sudo apt-get install -y ruby-dev build-essential git libvips pkg-config libimlib2 libimlib2-dev imagemagick
run: sudo apt-get install --no-install-recommends -y libimlib2 libimlib2-dev imagemagick
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
# caches by Gemfile.lock checksum
bundler-cache: true
# Share test run timings across CI runs for optimal distribution
- name: Restore spec runtimes
uses: actions/cache/restore@v4
with:
path: tmp/parallel_runtime_rspec.log
key: rspec-runtime-${{ github.run_id }}
restore-keys: rspec-runtime-
- name: Run tests
id: rspec
#run: |
# bin/rspec --pattern "spec/**/*_spec.rb,engines/**/*_spec.rb"
run: |
# --group-by runtime reads the log without a rescue, so it must exist
mkdir -p tmp && touch tmp/parallel_runtime_rspec.log
bin/parallel_rspec spec engines -n 6 \
--group-by runtime --allowed-missing 100 --only-group ${{ matrix.groups }}
shell: bash
# The coverage job needs this artifact, so a failed upload must fail this job.
# Otherwise "re-run failed jobs" only re-runs coverage and never regenerates it.
- name: Upload partial results
if: always()
uses: actions/upload-artifact@v6
with:
name: part-${{ matrix.part }}
include-hidden-files: true
path: |
coverage/.resultset.json
tmp/parallel_runtime_rspec.log
# Diagnostic uploads only. The artifact backend returns transient 403s on
# finalize, which must not change the job result.
- name: Upload screenshots
if: failure()
continue-on-error: true
uses: actions/upload-artifact@v6
with:
name: screenshots-${{ matrix.part }}
path: ./tmp/capybara
- name: Upload logs
if: failure()
continue-on-error: true
uses: actions/upload-artifact@v6
with:
name: rails-logs-${{ matrix.part }}
path: ./log/test.log
coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update package lists
run: sudo apt-get update
- name: Install dependencies
run: sudo apt-get install --no-install-recommends -y libimlib2-dev
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
# caches by Gemfile.lock checksum
bundler-cache: true
- name: Download partial results
uses: actions/download-artifact@v4
with:
pattern: part-*
path: parts
# Every job only knows the coverage of its own groups. The minimum in
# spec/rails_helper.rb therefore cannot apply. Enforce it over the merged data.
- name: Check merged coverage
run: |
bundle exec ruby -e '
require "simplecov"
SimpleCov.collate Dir["parts/*/coverage/.resultset.json"], "rails" do
minimum_coverage 100
skip "app/jobs/application_job.rb"
skip "lib/tasks"
end
'
- name: Upload coverage
if: always()
continue-on-error: true
uses: actions/upload-artifact@v6
with:
name: coverage
path: ./coverage
- name: Merge spec runtimes
run: |
mkdir -p tmp
cat parts/*/tmp/parallel_runtime_rspec.log > tmp/parallel_runtime_rspec.log
- name: Save spec runtimes
uses: actions/cache/save@v4
with:
path: tmp/parallel_runtime_rspec.log
key: rspec-runtime-${{ github.run_id }}
# - name: Coveralls
# uses: coverallsapp/github-action@v2
# with:
# fail-on-error: false