-
-
Notifications
You must be signed in to change notification settings - Fork 335
241 lines (213 loc) · 8.12 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
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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows running this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build_and_test:
runs-on: ubuntu-24.04
strategy:
# it is helpful to know which sets of tests would have succeeded,
# even when there is a failure.
fail-fast: false
matrix:
python-version: [3.11]
node-version: [22.x]
tests:
- ':lint:python:client:common:smoke:stubs:'
- ':server-1-of-2:'
- ':server-2-of-2:'
- ':gen-server:'
- ':nbrowser-^[A-D]:'
- ':nbrowser-^[E-L]:'
- ':nbrowser-^[M-N]:'
- ':nbrowser-^[O-R]:'
- ':nbrowser-^[^A-R]:'
include:
- tests: ':lint:python:client:common:smoke:'
node-version: 22.x
python-version: '3.10'
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install Python packages
run: |
pip install virtualenv
yarn run install:python
- name: Install Node.js packages
run: yarn install
- name: Install gvisor
run: sudo apt install runsc
- name: Run eslint
if: contains(matrix.tests, ':lint:')
run: yarn run lint:ci
- name: Make sure bucket is versioned
if: contains(matrix.tests, ':server-') || contains(matrix.tests, ':gen-server:')
env:
AWS_ACCESS_KEY_ID: administrator
AWS_SECRET_ACCESS_KEY: administrator
run: aws --region us-east-1 --endpoint-url http://localhost:9000 s3api put-bucket-versioning --bucket grist-docs-test --versioning-configuration Status=Enabled
- name: Build Node.js code
run: yarn run build:prod
- name: Install Google Chrome for Testing
if: contains(matrix.tests, ':nbrowser-') || contains(matrix.tests, ':smoke:') || contains(matrix.tests, ':stubs:')
run: ./test/test_env.sh ./node_modules/selenium-webdriver/bin/linux/selenium-manager
- name: Run smoke test
if: contains(matrix.tests, ':smoke:')
run: VERBOSE=1 DEBUG=1 MOCHA_WEBDRIVER_HEADLESS=1 yarn run test:smoke
- name: Run python tests
if: contains(matrix.tests, ':python:')
run: yarn run test:python
- name: Run client tests
if: contains(matrix.tests, ':client:')
run: yarn run test:client
- name: Run common tests
if: contains(matrix.tests, ':common:')
run: yarn run test:common
- name: Run stubs tests
if: contains(matrix.tests, ':stubs:')
run: MOCHA_WEBDRIVER_HEADLESS=1 yarn run test:stubs
- name: Run gen-server tests with sqlite, minio and redis
if: contains(matrix.tests, ':gen-server:')
run: |
yarn run test:gen-server
# Anchors should be used once available. Not supported yet as of December 2024.
# https://github.com/actions/runner/issues/1182
env:
MOCHA_WEBDRIVER_HEADLESS: 1
TESTS: ${{ matrix.tests }}
GRIST_DOCS_MINIO_ACCESS_KEY: administrator
GRIST_DOCS_MINIO_SECRET_KEY: administrator
TEST_REDIS_URL: "redis://localhost/11"
GRIST_DOCS_MINIO_USE_SSL: 0
GRIST_DOCS_MINIO_ENDPOINT: localhost
GRIST_DOCS_MINIO_PORT: 9000
GRIST_DOCS_MINIO_BUCKET: grist-docs-test
- name: Run gen-server tests with postgres, minio and redis
if: contains(matrix.tests, ':gen-server:')
run: |
PGPASSWORD=$TYPEORM_PASSWORD psql -h $TYPEORM_HOST -U $TYPEORM_USERNAME -w $TYPEORM_DATABASE -c "SHOW ALL;" | grep ' jit '
yarn run test:gen-server
env:
MOCHA_WEBDRIVER_HEADLESS: 1
TESTS: ${{ matrix.tests }}
GRIST_DOCS_MINIO_ACCESS_KEY: administrator
GRIST_DOCS_MINIO_SECRET_KEY: administrator
TEST_REDIS_URL: "redis://localhost/11"
GRIST_DOCS_MINIO_USE_SSL: 0
GRIST_DOCS_MINIO_ENDPOINT: localhost
GRIST_DOCS_MINIO_PORT: 9000
GRIST_DOCS_MINIO_BUCKET: grist-docs-test
TYPEORM_TYPE: postgres
TYPEORM_HOST: localhost
TYPEORM_DATABASE: db_name
TYPEORM_USERNAME: db_user
TYPEORM_PASSWORD: db_password
- name: Run server tests with minio and redis
if: contains(matrix.tests, ':server-')
run: |
export TEST_SPLITS=$(echo $TESTS | sed "s/.*:server-\([^:]*\).*/\1/")
yarn run test:server
env:
MOCHA_WEBDRIVER_HEADLESS: 1
TESTS: ${{ matrix.tests }}
GRIST_DOCS_MINIO_ACCESS_KEY: administrator
GRIST_DOCS_MINIO_SECRET_KEY: administrator
TEST_REDIS_URL: "redis://localhost/11"
GRIST_DOCS_MINIO_USE_SSL: 0
GRIST_DOCS_MINIO_ENDPOINT: localhost
GRIST_DOCS_MINIO_PORT: 9000
GRIST_DOCS_MINIO_BUCKET: grist-docs-test
- name: Run main tests without minio and redis
if: contains(matrix.tests, ':nbrowser-')
run: |
mkdir -p $MOCHA_WEBDRIVER_LOGDIR
export GREP_TESTS=$(echo $TESTS | sed "s/.*:nbrowser-\([^:]*\).*/\1/")
MOCHA_WEBDRIVER_SKIP_CLEANUP=1 MOCHA_WEBDRIVER_HEADLESS=1 yarn run test:nbrowser --parallel --jobs 3
env:
TESTS: ${{ matrix.tests }}
MOCHA_WEBDRIVER_LOGDIR: ${{ runner.temp }}/test-logs/webdriver
TESTDIR: ${{ runner.temp }}/test-logs
- name: Prepare for saving artifact
if: failure()
run: |
ARTIFACT_NAME=logs-$(echo $TESTS | sed 's/[^-a-zA-Z0-9]/_/g')
echo "Artifact name is '$ARTIFACT_NAME'"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV
mkdir -p $TESTDIR
find $TESTDIR -iname "*.socket" -exec rm {} \;
env:
TESTS: ${{ matrix.tests }}
TESTDIR: ${{ runner.temp }}/test-logs
- name: Save artifacts on failure
if: failure()
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ runner.temp }}/test-logs # only exists for webdriver tests
services:
# https://github.com/bitnami/bitnami-docker-minio/issues/16
minio:
image: bitnami/minio:latest
env:
MINIO_DEFAULT_BUCKETS: "grist-docs-test:public"
MINIO_ROOT_USER: administrator
MINIO_ROOT_PASSWORD: administrator
ports:
- 9000:9000
options: >-
--health-cmd "curl -f http://localhost:9000/minio/health/ready"
--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
postgresql:
image: postgres:latest
env:
POSTGRES_USER: db_user
POSTGRES_PASSWORD: db_password
POSTGRES_DB: db_name
# JIT is enabled by default since Postgres 17 and has a huge negative impact on performance,
# making many tests timeout.
# https://support.getgrist.com/self-managed/#what-is-a-home-database
POSTGRES_INITDB_ARGS: "-c jit=off"
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U db_user"
--health-interval 10s
--health-timeout 5s
--health-retries 5
candidate:
needs: build_and_test
if: ${{ success() && github.event_name == 'push' }}
runs-on: ubuntu-22.04
steps:
- name: Fetch new candidate branch
uses: actions/checkout@v3
- name: Update candidate branch
uses: ad-m/github-push-action@8407731efefc0d8f72af254c74276b7a90be36e1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: latest_candidate
force: true