77 branches : [ master ]
88
99jobs :
10- test :
10+ build-wheel :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - uses : actions/checkout@v4
1115
16+ - name : Set up Python
17+ uses : actions/setup-python@v5
18+ with :
19+ python-version : ' 3.11'
20+
21+ - name : Build the wheel
22+ run : |
23+ python -m pip install build
24+ python -m build
25+
26+ - name : Upload wheel
27+ uses : actions/upload-artifact@v4
28+ with :
29+ name : wheel
30+ path : dist/*.whl
31+
32+ - name : Run the tests
33+ run : |
34+ python -m pip install numpy pyparsing pytest pytest-cov
35+ pytest -v
36+
37+ - name : Build the docs
38+ run : |
39+ python -m pip install matplotlib sphinx
40+ python -m pip install dist/periodictable*.whl
41+ make -j 4 -C doc/sphinx SPHINXOPTS="-W --keep-going" html
42+
43+ # Test the wheel on different platforms
44+ test :
1245 runs-on : ${{ matrix.cfg.os }}
46+ needs : build-wheel
47+
1348 strategy :
1449 matrix :
1550 cfg :
1954 - { os: ubuntu-latest, py: 3.11, doc: 1 }
2055 - { os: windows-latest, py: 3.11 }
2156 - { os: macos-latest, py: 3.11 }
57+ fail-fast : false
2258
2359 steps :
2460 - uses : actions/checkout@v4
@@ -28,18 +64,43 @@ jobs:
2864 with :
2965 python-version : ${{ matrix.cfg.py }}
3066
67+ - name : Download the wheel
68+ uses : actions/download-artifact@v4
69+ with :
70+ name : wheel
71+ path : dist
72+
73+ - name : Install the wheel
74+ run : python -m pip install dist/periodictable*.whl
75+ shell : bash
76+
3177 - name : Install Python dependencies
3278 run : |
33- python -m pip install --upgrade pip
34- python -m pip install wheel setuptools
35- python -m pip install numpy scipy matplotlib pytest pytest-cov
79+ python -m pip install pytest pytest-cov
3680
37- - name : Test with pytest
81+ # Change into the test directory to test the wheel so that the
82+ # source directory is not on the path. Full tests with coverage are
83+ # run before building the wheel.
84+ - name : Test wheel with pytest
3885 run : |
39- pytest -v
86+ cd test
87+ pytest -v --pyargs --import-mode=append periodictable . ../doc/sphinx/guide
4088
41- - name : check that the docs build (linux only)
42- if : matrix.cfg.doc == 1
43- run : |
44- python -m pip install sphinx
45- make -j 4 -C doc/sphinx SPHINXOPTS="-W --keep-going" html
89+ # Upload wheel to PyPI only when a tag is pushed, and its name begins with 'v'
90+ upload-to-pypi :
91+ runs-on : ubuntu-latest
92+ environment : release
93+ needs : test
94+ if : startsWith(github.ref, 'refs/tags/v')
95+ permissions :
96+ id-token : write
97+ steps :
98+
99+ - name : Download wheel
100+ uses : actions/download-artifact@v4
101+ with :
102+ name : wheel
103+ path : dist
104+
105+ - name : Publish package distributions to PyPI
106+ uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments