-
Notifications
You must be signed in to change notification settings - Fork 2
101 lines (95 loc) · 2.95 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
name: "Tests"
on:
push:
branches-ignore:
- "dependabot/**"
- "sourcery/**"
pull_request:
workflow_dispatch:
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Run pre-commit
uses: pre-commit/[email protected]
create-test-matrix:
name: Create Notebook List
runs-on: ubuntu-latest
needs: [pre-commit]
outputs:
notebook-list: ${{ steps.notebooks.outputs.notebook-list }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Set notebook list
id: notebooks
shell: python
run: |
import json
import os
from pathlib import Path
block_list =[
"BRC_NIR-global-case-study-pretty",
"BRC_VIS_NIR-target-case-study-pretty",
"BRC_VIS-global-case-study-pretty",
"CK-case-study",
"oc_tol",
"coc_tol",
"oc_coc_tol_target",
"oc_coc_tol_target_refined",
"PCP-case-study",
"PCP-case-study-pretty",
"BE-case-study-pretty",
"Spirulina-case-study",
"CKq-case-study",
"CKuq-case-study",
"PS1_pyglotaran_equalarea",
"ocg_dcm",
"ocg_dcm-refined2",
"PAL_open_global-pretty",
"PAL_closed_global-pretty",
"PAL_open_closed_target_exercise"
]
notebook_paths = []
for notebook_path in Path().rglob("*.ipynb"):
if notebook_path.stem not in block_list:
notebook_paths.append(
{
"name": notebook_path.stem,
"path": notebook_path.resolve().as_posix(),
}
)
with open(os.getenv("GITHUB_OUTPUT"), "a", encoding="utf8") as f:
f.writelines([f"notebook-list={json.dumps(notebook_paths)}"])
run-tests:
name: "Test ${{ matrix.notebook_path.name }}"
runs-on: ubuntu-latest
needs: [create-test-matrix]
strategy:
matrix:
notebook_path: ${{fromJson(needs.create-test-matrix.outputs.notebook-list)}}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install test dependencies
run: |
pip install wheel
pip install -r .github/test-requirements.txt
- name: Testing ${{ matrix.notebook_path.name }}
run: python -m pytest --nbval-lax ${{ matrix.notebook_path.path }}
- name: Installed packages
if: always()
run: |
pip freeze