-
-
Notifications
You must be signed in to change notification settings - Fork 14
307 lines (280 loc) · 8.91 KB
/
tests.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
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
name: Tests
on:
push:
branches: ["main"]
pull_request:
defaults:
run:
shell: bash -eux {0}
jobs:
base_setup:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.11"]
include:
- os: ubuntu-latest
python-version: "3.12"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Base Setup
uses: ./.github/actions/base-setup
with:
node_version: 18.0
- name: Check Hatch Version
run: hatch --version
base_setup_minimum:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
with:
dependency_type: minimum
- run: |
pip install -e ".[test]"
# NOTE: keep the python version in sync with README
python --version
python --version | grep "3.8"
hatch run check_minimum
base_setup_pre:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
with:
dependency_type: pre
- run: |
pip install -e ".[test]"
# NOTE: keep this version in sync with README
python --version
python --version | grep "3.12"
hatch run check_pre
test_lint:
name: Test Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
- name: Run Linters
run: |
hatch run typing:test
hatch run lint:build
pipx run interrogate -v .
check_links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
- uses: ./.github/actions/check-links
downstream_defaults:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Base Setup
uses: ./.github/actions/base-setup
- name: Create a mock python package
run: echo "from setuptools import setup; setup(name='foo')" > setup.py
- name: Check Downstream test with defaults
uses: ./.github/actions/downstream-test
with:
package_name: jupyter_core
downstream_overrides:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Base Setup
uses: ./.github/actions/base-setup
- name: Create a mock python package
run: echo "from setuptools import setup; setup(name='foo')" > setup.py
- name: Check Downstream test with overrides
uses: ./.github/actions/downstream-test
with:
package_name: nbclient
package_spec: "nbclient[test] ipykernel"
package_download_extra_args: "--use-pep517"
test_command: "echo 'hello'"
extra_test: "pytest"
env_values: IPYKERNEL_CELL_NAME=\<IPY-INPUT\>
binder_link:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Base Setup
uses: ./.github/actions/base-setup
- name: Check Binder Link
uses: ./.github/actions/binder-link
with:
github_token: "FAKE"
url_path: "/foo/bar"
pr_script:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Base Setup
uses: ./.github/actions/base-setup
- name: Check PR Script All Options
uses: ./.github/actions/pr-script
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true
script: '["jlpm run integrity", "jlpm run lint"]'
commit_message: "auto run cleanup"
target: "https://github.com/jupyterlab/maintainer-tools/pull/39"
association: "MEMBER"
git_username: "snuffy-bot"
git_email: "snuffy-bot@example.com"
- name: Check PR Script Defaults
uses: ./.github/actions/pr-script
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true
pre_commit: true
target: "https://github.com/jupyterlab/maintainer-tools/pull/39"
update_snapshots-manual-server:
runs-on: ubuntu-latest
env:
TEST_FOLDER: mock-playwright
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Base Setup
uses: ./.github/actions/base-setup
- name: Create a mock playwright test package
shell: bash
run: |
mkdir -p ${TEST_FOLDER}/tests/example.spec.ts-snapshots
pushd ${TEST_FOLDER}
# Prevent yarn to look up in the folder hierarchy
touch yarn.lock
yarn init -yp
yarn add -D @playwright/test
cat package.json | jq '. += {"scripts": {"start": "echo starting...", "test:update": "yarn playwright test -u"}}' > new_package.json
cat > tests/example.spec.ts << EOF
import { test, expect } from '@playwright/test';
test('basic test', async ({ page }) => {
await page.goto('https://playwright.dev/');
await page.locator('text=Get started').click();
await expect(page).toHaveTitle(/Installation | Playwright/);
});
EOF
cp new_package.json package.json
# Create fake snapshot
touch tests/example.spec.ts-snapshots/dummy.txt
git checkout -b test-snapshot
popd
- name: Check update snapshots action
uses: ./.github/actions/update-snapshots
with:
github_token: "FAKE"
test_folder: ${{ env.TEST_FOLDER }}
server_url: https-get://playwright.dev
dry_run: yes
artifact_name: playwright-manual-snapshots
update_snapshots:
runs-on: ubuntu-latest
env:
TEST_FOLDER: mock-playwright
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Base Setup
uses: ./.github/actions/base-setup
- name: Create a mock playwright test package
shell: bash
run: |
mkdir -p ${TEST_FOLDER}/tests/example.spec.ts-snapshots
pushd ${TEST_FOLDER}
# Prevent yarn to look up in the folder hierarchy
touch yarn.lock
yarn init -yp
yarn add -D @playwright/test
cat package.json | jq '. += {"scripts": {"test:update": "yarn playwright test -u"}}' > new_package.json
cat > tests/example.spec.ts << EOF
import { test, expect } from '@playwright/test';
test('basic test', async ({ page }) => {
await page.goto('https://playwright.dev/');
await page.locator('text=Get started').click();
await expect(page).toHaveTitle(/Installation | Playwright/);
});
EOF
cp new_package.json package.json
# Create fake snapshot
touch tests/example.spec.ts-snapshots/dummy.txt
git checkout -b test-snapshot
popd
- name: Check update snapshots action
uses: ./.github/actions/update-snapshots
with:
github_token: "FAKE"
test_folder: ${{ env.TEST_FOLDER }}
start_server_script: "null"
dry_run: yes
make_sdist:
name: Make SDist
runs-on: windows-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
- uses: ./.github/actions/make-sdist
test_sdist:
runs-on: macos-latest
needs: [make_sdist]
name: Install from SDist and Test
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
- uses: ./.github/actions/test-sdist
coverage_test:
name: Test coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
- run: |
pip install coverage[toml] pytest
python -m coverage run -m pytest foobar.py
ls -a
- uses: ./.github/actions/upload-coverage
with:
artifact_name: coverage-data-${{ matrix.os }}
coverage_report:
name: Combine & check coverage
needs: coverage_test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/report-coverage
tests_check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- base_setup
- base_setup_minimum
- base_setup_pre
- test_lint
- check_links
- binder_link
- pr_script
- downstream_defaults
- downstream_overrides
- update_snapshots-manual-server
- update_snapshots
- test_sdist
- coverage_report
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}