66 workflow_dispatch :
77
88jobs :
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+ twine
23+ - name : Build a binary wheel and a source tarball
24+ run : python3 -m build
25+ - name : Check the distribution files with `twine`
26+ run : twine check --strict dist/*
27+ - name : Upload artifact
28+ id : artifact-upload-step
29+ uses : actions/upload-artifact@v4
30+ with :
31+ name : dist-files
32+ path : dist/*
33+ if-no-files-found : error
34+ compression-level : 0 # They are already compressed
935 test-run :
1036 runs-on : ubuntu-latest
37+ needs : build
1138 strategy :
1239 matrix :
1340 include :
3360 ignore-test-outcome : false
3461
3562 steps :
36- - uses : actions/checkout@v3
63+ - uses : actions/checkout@v4
3764
3865 - name : Set up Python ${{ matrix.python-version }}
3966 uses : actions/setup-python@v4
6188 run : |
6289 python -m poetry install --only=dev
6390
91+ - name : Download artifact
92+ uses : actions/download-artifact@v4
93+ with :
94+ name : dist-files
95+ path : dist/
96+
6497 - name : Type checking
6598 # Ignore errors for older pythons
6699 continue-on-error : ${{ matrix.ignore-typecheck-outcome }}
@@ -73,14 +106,37 @@ jobs:
73106 run : |
74107 source .venv/bin/activate
75108 coverage erase
76- tox run-parallel -f ${{ matrix.toxfactor }} --parallel-no-spinner --parallel-live
109+ # Using `--parallel 4` as it's the number of CPUs in the GitHub Actions runner
110+ # Using `installpkg dist/*.whl` because we want to install the pre-built package (want to test against that)
111+ tox run-parallel -f ${{ matrix.toxfactor }} --parallel 4 --parallel-no-spinner --parallel-live --installpkg dist/*.whl
77112 coverage combine
78113 coverage xml
79114
80115 - uses : codecov/codecov-action@v4
81116 with :
82- # Explicitly using the token in order to avoid Codecov rate limit errors
117+ # Explicitly using the token to avoid Codecov rate limit errors
83118 # See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
84119 token : ${{ secrets.CODECOV_TOKEN }}
85- fail_ci_if_error : true
120+ fail_ci_if_error : false
86121 verbose : true # optional (default = false)
122+
123+ pypi-publish :
124+ name : Upload release to PyPI
125+ runs-on : ubuntu-latest
126+ environment :
127+ name : pypi
128+ url : https://pypi.org/p/pytest-factoryboy
129+ permissions :
130+ id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
131+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
132+ needs :
133+ - " test-run"
134+ - " build"
135+ steps :
136+ - name : Download artifact
137+ uses : actions/download-artifact@v4
138+ with :
139+ name : dist-files
140+ path : dist/
141+ - name : Publish package distributions to PyPI
142+ uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments