6
6
workflow_dispatch :
7
7
8
8
jobs :
9
+ build :
10
+ name : Build package
11
+ runs-on : ubuntu-latest
12
+ steps :
13
+ - uses : actions/checkout@v4
14
+ - name : Set up Python
15
+ uses : actions/setup-python@v5
16
+ with :
17
+ cache : " pip"
18
+ - name : Install pypa/build
19
+ run : >-
20
+ python3 -m pip install --user
21
+ build
22
+ - name : Build a binary wheel and a source tarball
23
+ run : python3 -m build
24
+ - name : Upload artifact
25
+ id : artifact-upload-step
26
+ uses : actions/upload-artifact@v4
27
+ with :
28
+ name : dist-files
29
+ path : dist/*
30
+ if-no-files-found : error
31
+ compression-level : 0 # They are already compressed
9
32
test-run :
10
33
runs-on : ubuntu-latest
34
+ needs : build
11
35
strategy :
12
36
matrix :
13
37
include :
@@ -33,57 +57,64 @@ jobs:
33
57
ignore-test-outcome : false
34
58
35
59
steps :
36
- - uses : actions/checkout@v3
60
+ - uses : actions/checkout@v4
61
+
62
+ - name : Set up Python ${{ matrix.python-version }}
63
+ uses : actions/setup-python@v4
64
+ id : setup-python
65
+ with :
66
+ python-version : ${{ matrix.python-version }}
37
67
38
- - name : Set up Python ${{ matrix.python-version }}
39
- uses : actions/setup-python@v4
40
- id : setup-python
41
- with :
42
- python-version : ${{ matrix.python-version }}
68
+ - name : Install poetry
69
+ run : |
70
+ python -m pip install poetry==1.8.3
43
71
44
- - name : Install poetry
45
- run : |
46
- python -m pip install poetry==1.8.3
72
+ - name : Configure poetry
73
+ run : |
74
+ python -m poetry config virtualenvs.in-project true
47
75
48
- - name : Configure poetry
49
- run : |
50
- python -m poetry config virtualenvs.in-project true
76
+ - name : Cache the virtualenv
77
+ id : poetry-dependencies-cache
78
+ uses : actions/cache@v3
79
+ with :
80
+ path : ./.venv
81
+ key : ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
51
82
52
- - name : Cache the virtualenv
53
- id : poetry-dependencies-cache
54
- uses : actions/cache@v3
55
- with :
56
- path : ./.venv
57
- key : ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
83
+ - name : Install dev dependencies
84
+ if : steps.poetry-dependencies-cache.outputs.cache-hit != 'true'
85
+ run : |
86
+ python -m poetry install --only=dev
58
87
59
- - name : Install dev dependencies
60
- if : steps.poetry-dependencies-cache.outputs.cache-hit != 'true'
61
- run : |
62
- python -m poetry install --only=dev
88
+ - name : Download artifact
89
+ uses : actions/download-artifact@v4
90
+ with :
91
+ name : dist-files
92
+ path : dist/
63
93
64
- - name : Type checking
65
- # Ignore errors for older pythons
66
- continue-on-error : ${{ matrix.ignore-typecheck-outcome }}
67
- run : |
68
- source .venv/bin/activate
69
- tox -e mypy
94
+ - name : Type checking
95
+ # Ignore errors for older pythons
96
+ continue-on-error : ${{ matrix.ignore-typecheck-outcome }}
97
+ run : |
98
+ source .venv/bin/activate
99
+ tox -e mypy
70
100
71
- - name : Test with tox
72
- continue-on-error : ${{ matrix.ignore-test-outcome }}
73
- run : |
74
- source .venv/bin/activate
75
- coverage erase
76
- tox run-parallel -f ${{ matrix.toxfactor }} --parallel-no-spinner --parallel-live
77
- coverage combine
78
- coverage xml
101
+ - name : Test with tox
102
+ continue-on-error : ${{ matrix.ignore-test-outcome }}
103
+ run : |
104
+ source .venv/bin/activate
105
+ coverage erase
106
+ # Using `installpkg dist/*.tar.gz` because we want to install the pre-built package (want to test against that)
107
+ tox run-parallel -f ${{ matrix.toxfactor }} --parallel-no-spinner --parallel-live --installpkg dist/*.whl
108
+ coverage combine
109
+ coverage xml
79
110
80
- - uses : codecov/codecov-action@v4
81
- with :
82
- # Explicitly using the token to avoid Codecov rate limit errors
83
- # See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
84
- token : ${{ secrets.CODECOV_TOKEN }}
85
- fail_ci_if_error : false
86
- verbose : true # optional (default = false)
111
+ - uses : codecov/codecov-action@v4
112
+ with :
113
+ # Explicitly using the token to avoid Codecov rate limit errors
114
+ # See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
115
+ token : ${{ secrets.CODECOV_TOKEN }}
116
+ fail_ci_if_error : false
117
+ verbose : true # optional (default = false)
87
118
88
119
pypi-publish :
89
120
name : Upload release to PyPI
@@ -94,18 +125,14 @@ jobs:
94
125
permissions :
95
126
id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
96
127
if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
97
- needs : test-run
128
+ needs :
129
+ - " test-run"
130
+ - " build"
98
131
steps :
99
- - uses : actions/checkout@v4
100
- - name : Set up Python
101
- uses : actions/setup-python@v5
102
- - name : Install pypa/build
103
- run : >-
104
- python3 -m
105
- pip install
106
- build
107
- --user
108
- - name : Build a binary wheel and a source tarball
109
- run : python3 -m build
132
+ - name : Download artifact
133
+ uses : actions/download-artifact@v4
134
+ with :
135
+ name : dist-files
136
+ path : dist/
110
137
- name : Publish package distributions to PyPI
111
138
uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments