-
Notifications
You must be signed in to change notification settings - Fork 23
317 lines (268 loc) · 9.69 KB
/
ci.yml
File metadata and controls
317 lines (268 loc) · 9.69 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
name: CI tests
on:
pull_request:
push:
branches:
- main
env:
FORCE_COLOR: true
UV_VERSION: "0.11.8"
NODE_VERSION: "22.22"
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pre-commit:
name: Run linters and other pre-commit hooks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.10
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
working-directory: ./pydatalab
run: |
uv sync --locked --all-extras --dev
- name: Run pre-commit
working-directory: ./pydatalab
run: |
uv run pre-commit run --all-files --show-diff-on-failure
pytest:
name: Run Python unit tests
services:
mongo:
image: mongo:8
ports:
- 27017:27017
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 2
matrix:
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v6
with:
# tests need an unshallowed version of the repository to check the version
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install MongoDB tools binaries
run: |
wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.9.0.deb && sudo apt install ./mongodb-database-tools-*-100.9.0.deb
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
working-directory: "./pydatalab"
enable-cache: true
- name: Install locked versions of dependencies
working-directory: ./pydatalab
run: |
uv sync --locked --all-extras --dev
- name: Run all tests
working-directory: ./pydatalab
run: |
uv run pytest -rs --cov=pydatalab --cov-report=term --cov-report=xml -vvv ./tests
- name: Upload coverage to Codecov
if: matrix.python-version == '3.10' && github.repository == 'datalab-org/datalab'
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: datalab-org/datalab
webapp:
name: Test the app build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Node
uses: actions/setup-node@v6
env:
FORCE_COLOR: 0
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
cache-dependency-path: ./webapp/yarn.lock
- name: Install web app
working-directory: ./webapp
run: yarn install --frozen-lockfile
- name: Build web app
working-directory: ./webapp
run: yarn build
plugins:
name: Test plugin builds
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: false
working-directory: "./pydatalab"
- name: Clone and mount template plugin to test local plugin installation
run: |
mkdir -p pydatalab/plugins
cp .github/workflows/plugins.ci-template.toml plugins.toml
# Initialise copier with default/dummy options
uvx copier@9.8.0 copy -l \
-d author_email=test@test.com \
-d author_fullname=test \
-d project_name=datalab-app-plugin-template \
-d repository_namespace=datalab-org \
"https://github.com/datalab-org/datalab-app-plugin-template" \
pydatalab/plugins/datalab-app-plugin-template
- name: Set some environment variables for CI containers pre-build
run: |
echo "PYDATALAB_TESTING=true" >> .env
echo "PYDATALAB_TESTING=true" >> pydatalab/.env
- name: Build Docker images
uses: docker/bake-action@v7
with:
files: docker-compose.yml
load: true
source: .
targets: 'api'
set: |
api.cache-from=type=gha,scope=${{ github.ref_name }}-build-api
api.cache-from=type=gha,scope=main-build-api
api.cache-to=type=gha,scope=${{ github.ref_name }}-build-api,mode=max
api.args.SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0+ci
api.args.WEB_CONCURRENCY=1
api.tags=datalab-api:latest
- name: Start services
run: |
# Launch production container profiles and wait for them to come up
if ! docker compose up api --force-recreate -d --wait; then
echo "=== Docker compose startup failed ==="
echo "=== Container logs: ==="
docker compose logs database api app
echo "=== Container status: ==="
docker compose ps database api app
exit 1
fi
- name: Test that plugin is loaded
run: |
# Test that plugin block is listed in info endpoint
curl -s http://localhost:5000/info/blocks | jq '.data | any(.id == "example")'
e2e:
name: e2e tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
browser-backend: ["electron", "chrome"] # , "firefox"] # Temporarily disable Firefox until migration to Cypress v14 (https://github.com/datalab-org/datalab/issues/1289)
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Node
uses: actions/setup-node@v6
env:
FORCE_COLOR: 0
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
cache-dependency-path: ./webapp/yarn.lock
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Set some environment variables for CI containers pre-build
run: |
cp webapp/.env.test_e2e .env
echo "PYDATALAB_TESTING=true" >> .env
echo "PYDATALAB_TESTING=true" >> pydatalab/.env
- name: Build Docker images
uses: docker/bake-action@v7
with:
files: docker-compose.yml
load: true
source: .
targets: 'app,api,database'
set: |
app.cache-from=type=gha,scope=${{ github.ref_name }}-build-app
app.cache-from=type=gha,scope=main-build-app
api.cache-from=type=gha,scope=${{ github.ref_name }}-build-api
api.cache-from=type=gha,scope=main-build-api
database.cache-from=type=gha,scope=${{ github.ref_name }}-build-database
database.cache-from=type=gha,scope=main-build-database
api.cache-to=type=gha,scope=${{ github.ref_name }}-build-api,mode=max
app.cache-to=type=gha,scope=${{ github.ref_name }}-build-app,mode=max
database.cache-to=type=gha,scope=${{ github.ref_name }}-build-database,mode=max
api.args.SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0+ci
api.args.WEB_CONCURRENCY=1
app.args.VUE_APP_GIT_VERSION=0.0.0+ci
app.tags=datalab-app:latest
api.tags=datalab-api:latest
database.tags=datalab-database:latest
- name: Start services
run: |
# Launch production container profiles and wait for them to come up
if ! docker compose up database api app --no-build --force-recreate -d --wait; then
echo "=== Docker compose startup failed ==="
echo "=== Container logs: ==="
docker compose logs database api app
echo "=== Container status: ==="
docker compose ps database api app
exit 1
fi
- name: Run end-to-end tests
uses: cypress-io/github-action@v7
with:
config: baseUrl=http://localhost:8081
working-directory: ./webapp
record: ${{ github.repository == 'datalab-org/datalab' }}
browser: ${{ matrix.browser-backend }}
group: "End-to-end tests (${{ matrix.browser-backend }})"
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
component:
# Cypress component tests don't need the datalab stack — they exercise Vue
# components in isolation. Splitting them out means they run in parallel
# with the e2e job instead of serially after it.
name: Component tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 2
matrix:
browser-backend: ["electron", "chrome"]
steps:
- uses: actions/checkout@v6
- name: Set up Node
uses: actions/setup-node@v6
env:
FORCE_COLOR: 0
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
cache-dependency-path: ./webapp/yarn.lock
- name: Run component tests
uses: cypress-io/github-action@v7
with:
working-directory: ./webapp
record: ${{ github.repository == 'datalab-org/datalab' }}
component: true
publish-summary: false
browser: ${{ matrix.browser-backend }}
group: "Component tests (${{ matrix.browser-backend }})"
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
liccheck:
name: Check OSS license compatibility for dependencies
uses: ./.github/workflows/license-check.yml