-
Notifications
You must be signed in to change notification settings - Fork 40
109 lines (90 loc) · 2.91 KB
/
test.yml
File metadata and controls
109 lines (90 loc) · 2.91 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
name: Test
on:
push:
branches: [ master ]
pull_request:
# branches: [ master ]
release:
types: [published]
jobs:
build-wheel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'
- name: Build the wheel
run: |
python -m pip install --group dev
python -m build
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel
path: dist/*.whl
- name: Run the tests
run: |
pytest -v
- name: Build the docs
run: |
make -j 4 -C doc/sphinx SPHINXOPTS="-W --keep-going" html
# Test the wheel on different platforms
test:
runs-on: ${{ matrix.cfg.os }}
needs: build-wheel
strategy:
matrix:
cfg:
#- { os: ubuntu-20.04, py: '3.6' }
- { os: ubuntu-latest, py: '3.10' }
- { os: ubuntu-latest, py: '3.14', doc: 1 }
- { os: windows-latest, py: '3.14' }
- { os: macos-latest, py: '3.14' }
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.cfg.py }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.cfg.py }}
- name: Download the wheel
uses: actions/download-artifact@v4
with:
name: wheel
path: dist
- name: Install the wheel
run: python -m pip install dist/periodictable*.whl
shell: bash
# uncertainties and matplotlib are optional packages, but they are needed for mypy tests
- name: Install test dependencies
run: |
python -m pip install --group test
# Use --pyargs --import-mode=append to target the installed package.
# Change into the test directory to test the wheel so that the
# source directory is not on the path. We are running coverage tests
# because it shows that it is indeed the installed package that is tested.
# The mypy plugin fails when testing the installed package. Since there is no
# way to turn the option off, so we instead erase the addopts configuration
# and put them explicitly on the pytest command line below without --mypy.
- name: Test wheel with pytest
run: |
cd test
pytest -v --pyargs --import-mode=append periodictable --override-ini addopts= --doctest-modules --doctest-glob=*.rst --cov=periodictable . ../doc/sphinx/guide
# Upload wheel to PyPI only when a tag is pushed, and its name begins with 'v'
upload-to-pypi:
runs-on: ubuntu-latest
environment: release
needs: test
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
steps:
- name: Download wheel
uses: actions/download-artifact@v4
with:
name: wheel
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1