Skip to content

Commit a4d9b0f

Browse files
committed
Split up tests
1 parent 26a513c commit a4d9b0f

File tree

3 files changed

+114
-53
lines changed

3 files changed

+114
-53
lines changed

.github/workflows/test-and-package.yaml renamed to .github/workflows/test-code.yaml

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
1212

13-
name: Test code and build package
13+
name: Test code
1414

1515
# Trigger the workflow on push, pull request and manual trigger
1616
on: [push, pull_request, workflow_call]
@@ -55,7 +55,7 @@ jobs:
5555
exit 1
5656
5757
# Job 2: Test code and upload coverage to Codecov
58-
code-testing:
58+
test-code:
5959
needs: code-consistency # previous job 'code-consistency' need to be finished first
6060

6161
# current job matrix. if modified, remember to UPDATE the strategy in the next job
@@ -82,7 +82,7 @@ jobs:
8282
- name: Install Python dependencies
8383
run: pip install '.[dev]'
8484

85-
- name: Run tests and create coverage report
85+
- name: Run Python tests and create coverage report
8686
run: >
8787
pytest tests/
8888
--cov=./
@@ -111,52 +111,3 @@ jobs:
111111
# env:
112112
# OS: ${{ matrix.os }}
113113
# PYTHON: ${{ matrix.python-version }}
114-
115-
- name: Create Python package # dist/*.whl
116-
run: python -m build --wheel --outdir dist
117-
118-
- name: Upload zipped Python package for next job
119-
uses: actions/upload-artifact@v4
120-
with:
121-
name: EasyDiffractionLib_py${{ matrix.python-version }}_${{ matrix.os }}_${{ runner.arch }}
122-
path: |
123-
dist/*.whl
124-
tests/
125-
if-no-files-found: "error"
126-
compression-level: 0
127-
128-
# Job 3: Test the package
129-
package-testing:
130-
needs: code-testing # previous job 'code-testing' need to be finished first
131-
132-
strategy:
133-
fail-fast: false
134-
matrix:
135-
os: [ubuntu-24.04, windows-2022, macos-13, macos-14]
136-
python-version: ['3.10', '3.11', '3.12']
137-
138-
runs-on: ${{ matrix.os }}
139-
140-
steps:
141-
- name: Set up Python ${{ matrix.python-version }}
142-
uses: actions/setup-python@v5
143-
with:
144-
python-version: ${{ matrix.python-version }}
145-
146-
- name: Upgrade package installer for Python
147-
run: python -m pip install --upgrade pip
148-
149-
- name: Download zipped Python package from previous job
150-
uses: actions/download-artifact@v4
151-
with: # name or path are taken from the upload step of the previous job
152-
name: EasyDiffractionLib_py${{ matrix.python-version }}_${{ matrix.os }}_${{ runner.arch }}
153-
path: . # directory to extract downloaded zipped artifacts
154-
155-
- name: Install Python package from previous job
156-
shell: bash
157-
run: pip install dist/*.whl
158-
159-
- name: Run tests
160-
run: |
161-
pip install pytest pytest-xdist
162-
pytest tests/ -n auto --color=yes

.github/workflows/test-ipynb.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- name: Install Python dependencies
7070
run: pip install '.[dev,charts]'
7171

72-
- name: Run tests on Jupyter Notebooks
72+
- name: Test Jupyter notebooks
7373
shell: bash
7474
run: >
7575
pytest

.github/workflows/test-package.yaml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# This workflow will for a variety of Python versions
2+
# - install the code base
3+
# - lint the code base
4+
# - test the code base
5+
# - upload the test coverage to codecov
6+
#
7+
# It will also
8+
# - build the package
9+
# - check the package
10+
#
11+
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
12+
13+
name: Build and test package
14+
15+
# Trigger the workflow on push, pull request and manual trigger
16+
on: [push, pull_request, workflow_call]
17+
18+
# Allow only one concurrent workflow, skipping runs queued between the run in-progress and latest queued.
19+
# And cancel in-progress runs.
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
26+
# Job 1: Build the package
27+
build-package:
28+
29+
# current job matrix. if modified, remember to UPDATE the strategy in the next job
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
os: [ubuntu-24.04, windows-2022, macos-13, macos-14]
34+
python-version: ['3.10', '3.11', '3.12']
35+
36+
runs-on: ${{ matrix.os }}
37+
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Python ${{ matrix.python-version }}
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
47+
- name: Upgrade package installer for Python
48+
run: python -m pip install --upgrade pip
49+
50+
- name: Install Python dependencies
51+
run: pip install '.[dev]'
52+
53+
- name: Create Python package # dist/*.whl
54+
run: python -m build --wheel --outdir dist
55+
56+
- name: Upload zipped Python package (with tests and examples) for next job
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: EasyDiffractionLib_py${{ matrix.python-version }}_${{ matrix.os }}_${{ runner.arch }}
60+
path: |
61+
dist/*.whl
62+
tests/
63+
examples/
64+
if-no-files-found: "error"
65+
compression-level: 0
66+
67+
# Job 2: Test the package
68+
test-package:
69+
needs: build-package # previous job 'code-testing' need to be finished first
70+
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
os: [ubuntu-24.04, windows-2022, macos-13, macos-14]
75+
python-version: ['3.10', '3.11', '3.12']
76+
77+
runs-on: ${{ matrix.os }}
78+
79+
steps:
80+
- name: Set up Python ${{ matrix.python-version }}
81+
uses: actions/setup-python@v5
82+
with:
83+
python-version: ${{ matrix.python-version }}
84+
85+
- name: Upgrade package installer for Python
86+
run: python -m pip install --upgrade pip
87+
88+
- name: Download zipped Python package (with tests and examples) from previous job
89+
uses: actions/download-artifact@v4
90+
with: # name or path are taken from the upload step of the previous job
91+
name: EasyDiffractionLib_py${{ matrix.python-version }}_${{ matrix.os }}_${{ runner.arch }}
92+
path: . # directory to extract downloaded zipped artifacts
93+
94+
- name: Install Python package from previous job with 'dev' extras
95+
run: pip install 'easydiffraction[dev]' --find-links=dist
96+
97+
- name: Run Python tests
98+
run: >
99+
pytest tests/
100+
--color=yes
101+
-n auto
102+
103+
- name: Run tests on Jupyter Notebooks
104+
shell: bash
105+
run: >
106+
pytest
107+
--nbmake examples/*ipynb
108+
--nbmake-timeout=300
109+
--color=yes
110+
-n=auto

0 commit comments

Comments
 (0)