-
Notifications
You must be signed in to change notification settings - Fork 258
266 lines (263 loc) · 8.75 KB
/
Copy pathtest_ci.yml
File metadata and controls
266 lines (263 loc) · 8.75 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
name: MarkUs Tests
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
push:
branches:
- master
jobs:
test_rspec:
if: github.event.pull_request.draft == false
runs-on: ubuntu-24.04
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: markus_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--entrypoint redis-server
env:
BUNDLE_WITHOUT: development:production:console:unicorn
COVERAGE: true
RAILS_ENV: test
RSPEC_RENDER_VIEWS: true
permissions:
contents: read
actions: write
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Add PostgreSQL apt repository
run: |
sudo apt-get install -y curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
- name: Install and cache system dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: |
libpq-dev
cmake
pkg-config
ghostscript
pandoc
imagemagick
libmagickwand-dev
git
libgl1
tesseract-ocr
pandoc
poppler-utils
fonts-liberation
libasound2t64
libatk-bridge2.0-0
libatk1.0-0
libatspi2.0-0
libcairo2
libcups2
libdbus-1-3
libdrm2
libegl1
libgbm1
libglib2.0-0
libgtk-3-0
libnspr4
libnss3
libpango-1.0-0
libx11-6
libx11-xcb1
libxcb1
libxcomposite1
libxdamage1
libxext6
libxfixes3
libxrandr2
libxshmfence1
postgresql-client-17
version: 1.0.2
# Packages 'fonts-liberation' and onward are needed for playwright's chromium installation.
# The list was taken from: https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/registry/nativeDeps.ts#L37-L63
# libasound2 renamed to libasound2t64 in Ubuntu 24.04
- name: Set up ruby and cache gems
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby-3.4
bundler-cache: true
- name: Set up node and cache packages
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- name: Install npm packages
run: npm ci
- name: Install python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Get pip cache dir
id: pip-cache
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache pip
uses: actions/cache@v5
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-jupyter.txt') }}-${{ hashFiles('requirements-scanner.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache playwright's installation of Chromium
uses: actions/cache@v5
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('requirements-jupyter.txt') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install python packages and playwright dependencies
run: |
python3.13 -m venv venv
./venv/bin/pip install --extra-index-url https://download.pytorch.org/whl/cpu -r requirements-jupyter.txt -r requirements-scanner.txt
./venv/bin/playwright install chromium
- name: Configure server
run: |
sudo rm -f /etc/localtime
sudo ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime
sudo sed -ri 's/(rights=")none("\s+pattern="PDF")/\1read\2/' /etc/ImageMagick-6/policy.xml
cp config/database.yml.ci config/database.yml
- name: Build assets
run: bundle exec rake javascript:build
- name: Set up databases
run: bundle exec rails parallel:setup
- name: Restore runtime log
uses: actions/cache/restore@v4
with:
key: runtime-cache-all-${{ hashFiles('spec/**/*.rb') }}
restore-keys: runtime-cache-all-
path: tmp/parallel_runtime_rspec.log
- name: Install chromedriver
uses: nanasess/setup-chromedriver@v2
- name: Run chromedriver
run: chromedriver --port=9515 --whitelisted-ips &
- name: Run rspec tests
run: bundle exec rails "parallel:spec[spec/, --exclude-pattern spec/system/**/*_spec.rb]"
env:
MARKUS__PYTHON: ./venv/bin/python3
RECORD_RUNTIME: "true"
- name: Run rspec system tests
run: bundle exec rspec spec/system
env:
MARKUS__PYTHON: ./venv/bin/python3
- name: Save new runtime chunk
uses: actions/cache/save@v4
with:
key: runtime-cache-all-${{ hashFiles('spec/**/*.rb') }}
path: tmp/parallel_runtime_rspec.log
- name: Merge SimpleCov results
run: |
bundle exec ruby -e "
require 'simplecov'
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
c.output_directory = 'coverage'
c.lcov_file_name = 'lcov.info'
end
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::LcovFormatter
])
SimpleCov.merge_timeout 7200
SimpleCov.collate Dir['coverage/worker*/.resultset.json']
"
- name: Coveralls Parallel (rspec)
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: rspec
parallel: true
file: coverage/lcov.info
test_jest:
if: github.event.pull_request.draft == false
runs-on: ubuntu-24.04
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--entrypoint redis-server
permissions:
contents: read
env:
BUNDLE_WITHOUT: development:production:console:unicorn
RAILS_ENV: test
NODE_ENV: test
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Set up ruby and cache gems
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby-3.4
bundler-cache: true
- name: Configure server
run: |
sudo rm -f /etc/localtime
sudo ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime
sudo sed -ri 's/(rights=")none("\s+pattern="PDF")/\1read\2/' /etc/ImageMagick-6/policy.xml
cp config/database.yml.ci config/database.yml
- name: Export i18n translations
run: bundle exec rake i18n:js:export
- name: Build assets
run: |
bundle exec rake javascript:build
- name: Set up node and cache packages
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- name: Install npm packages
run: npm ci
- name: Run jest tests
run: npm run test-cov
- name: Coveralls Parallel (jest)
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: jest
parallel: true
file: coverage/lcov.info
finish:
needs: [test_rspec, test_jest]
if: github.event.pull_request.draft == false
runs-on: ubuntu-24.04
permissions:
pull-requests: write
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
carryforward: "rspec,jest"