Skip to content

Commit e7ed328

Browse files
committed
Test against the artifact that we will upload to PyPI
1 parent a12fa3b commit e7ed328

File tree

1 file changed

+41
-14
lines changed

1 file changed

+41
-14
lines changed

.github/workflows/main.yml

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,32 @@ on:
66
workflow_dispatch:
77

88
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
932
test-run:
1033
runs-on: ubuntu-latest
34+
needs: build
1135
strategy:
1236
matrix:
1337
include:
@@ -33,7 +57,7 @@ jobs:
3357
ignore-test-outcome: false
3458

3559
steps:
36-
- uses: actions/checkout@v3
60+
- uses: actions/checkout@v4
3761

3862
- name: Set up Python ${{ matrix.python-version }}
3963
uses: actions/setup-python@v4
@@ -61,6 +85,12 @@ jobs:
6185
run: |
6286
python -m poetry install --only=dev
6387
88+
- name: Download artifact
89+
uses: actions/download-artifact@v4
90+
with:
91+
name: dist-files
92+
path: dist/
93+
6494
- name: Type checking
6595
# Ignore errors for older pythons
6696
continue-on-error: ${{ matrix.ignore-typecheck-outcome }}
@@ -73,7 +103,8 @@ jobs:
73103
run: |
74104
source .venv/bin/activate
75105
coverage erase
76-
tox run-parallel -f ${{ matrix.toxfactor }} --parallel-no-spinner --parallel-live
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
77108
coverage combine
78109
coverage xml
79110
@@ -94,18 +125,14 @@ jobs:
94125
permissions:
95126
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
96127
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
97-
needs: test-run
128+
needs:
129+
- "test-run"
130+
- "build"
98131
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/
110137
- name: Publish package distributions to PyPI
111138
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)