Skip to content

Commit 7a44f81

Browse files
committed
Make release fully triggered & move tests to a separate ci
Building the wheels for every PR / push is mostly unnecessary, technically one wheel could be broken and the rest not, but ua-parser doesn't actually have anything OS (or architecture) specific, so the odds seem pretty low. Therefore stop doing that, move the wheels / release workflow to full triggered, and extract basic wheels (ubutun & amd64 only) and tests to a separate CI for regular testing. Fixes #9, #8, #6.
1 parent 38034a7 commit 7a44f81

File tree

5 files changed

+142
-37
lines changed

5 files changed

+142
-37
lines changed

.github/workflows/py-tests.yml

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
wheels:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version:
16+
- "3.x"
17+
- "pypy-3.10"
18+
- "graalpy-24"
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- uses: actions/cache@v4
27+
with:
28+
path: |
29+
~/.cargo/bin/
30+
~/.cargo/registry/index/
31+
~/.cargo/registry/cache/
32+
~/.cargo/git/db/
33+
target/
34+
key: ${{ runner.os }}-cargo-${{ hashFiles('ua-parser-py/Cargo.toml') }}
35+
restore-keys: |
36+
${{ runner.os }}-cargo-
37+
38+
- uses: actions/cache@v4
39+
with:
40+
path: |
41+
~/.cache/pip
42+
~/.cache/pip-graalpy
43+
key: ${{ runner.os }}-pip-maturin-${{ matrix.python-version }}
44+
45+
- uses: PyO3/maturin-action@v1
46+
with:
47+
args: --release --out dist -m ua-parser-py/Cargo.toml -i python --zig
48+
sccache: true
49+
- uses: actions/upload-artifact@v4
50+
with:
51+
name: wheels-${{ matrix.python-version }}
52+
path: dist/*
53+
retention-days: 1
54+
compression-level: 0
55+
56+
tests:
57+
needs: wheels
58+
runs-on: ubuntu-latest
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
python-version:
63+
- "3.9"
64+
- "3.10"
65+
- "3.11"
66+
- "3.12"
67+
- "3.13"
68+
- "pypy-3.10"
69+
- "graalpy-24"
70+
71+
include:
72+
- wheel: "3.x"
73+
- python-version: "pypy-3.10"
74+
wheel: "pypy-3.10"
75+
- python-version: "graalpy-24"
76+
wheel: "graalpy-24"
77+
78+
steps:
79+
- uses: actions/checkout@v4
80+
with:
81+
submodules: true
82+
- uses: actions/setup-python@v5
83+
with:
84+
python-version: ${{ matrix.python-version }}
85+
allow-prereleases: true
86+
- uses: actions/cache@v4
87+
with:
88+
path: |
89+
~/.cache/pip
90+
~/.cache/pip-graalpy
91+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
92+
- uses: actions/download-artifact@v4
93+
with:
94+
name: wheels-${{ matrix.wheel }}
95+
path: dist
96+
- run: python -mpip install --upgrade pip
97+
- run: |
98+
if ! pip download --only-binary :all: pyyaml > /dev/null 2>&1
99+
then
100+
sudo apt install libyaml-dev
101+
fi
102+
- run: python -mpip install pytest pyyaml
103+
- run: python -mpip install --find-links dist ua_parser_rs
104+
- run: pytest -v -Werror -ra ua-parser-py

.github/workflows/pychecks.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: py checks
33
on:
44
pull_request:
55
push:
6-
branches:
7-
- main
86

97
permissions:
108
contents: read

.github/workflows/pyo3-wheels.yml

+34-32
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
name: Wheels and Tests
1+
name: Wheels
22

33
on:
4-
push:
5-
branches: [ main ]
6-
pull_request:
74
workflow_dispatch:
5+
inputs:
6+
release:
7+
description: 'Push wheels to pypi'
8+
type: boolean
9+
default: false
10+
required: true
811

912
permissions:
1013
contents: read
@@ -69,6 +72,8 @@ jobs:
6972
with:
7073
name: wheels-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.python-version }}
7174
path: dist/*
75+
retention-days: 1
76+
compression-level: 0
7277

7378
sdist:
7479
runs-on: ubuntu-latest
@@ -85,38 +90,10 @@ jobs:
8590
name: wheels-sdist
8691
path: dist
8792

88-
# TODO: tags don't work because multiple crates in same repo, so
89-
# needs some other method of picking versions
90-
release:
91-
name: Release
92-
runs-on: ubuntu-latest
93-
if: ${{ github.event_name == 'workflow_dispatch' }}
94-
needs: [wheels, sdist]
95-
permissions:
96-
# Use to sign the release artifacts
97-
id-token: write
98-
# Used to upload release artifacts
99-
contents: write
100-
# Used to generate artifact attestation
101-
attestations: write
102-
environment: release
103-
steps:
104-
- uses: actions/download-artifact@v4
105-
- name: Generate artifact attestation
106-
uses: actions/attest-build-provenance@v1
107-
with:
108-
subject-path: 'wheels-*/*'
109-
- name: Publish to PyPI
110-
uses: PyO3/maturin-action@v1
111-
with:
112-
command: upload
113-
args: --non-interactive --skip-existing wheels-*/*
114-
11593
tests:
11694
needs: wheels
11795

11896
strategy:
119-
fail-fast: false
12097
matrix:
12198
python-version:
12299
- "3.9"
@@ -190,3 +167,28 @@ jobs:
190167
run: pip install --find-links dist ua_parser_rs
191168
- name: Run tests
192169
run: pytest -v -Werror -ra ua-parser-py
170+
171+
release:
172+
name: Release
173+
runs-on: ubuntu-latest
174+
needs: [tests, sdist]
175+
if: ${{ inputs.release == 'true' }}
176+
permissions:
177+
# Use to sign the release artifacts
178+
id-token: write
179+
# Used to upload release artifacts
180+
contents: write
181+
# Used to generate artifact attestation
182+
attestations: write
183+
environment: release
184+
steps:
185+
- uses: actions/download-artifact@v4
186+
- name: Generate artifact attestation
187+
uses: actions/attest-build-provenance@v1
188+
with:
189+
subject-path: 'wheels-*/*'
190+
- name: Publish to PyPI
191+
uses: PyO3/maturin-action@v1
192+
with:
193+
command: upload
194+
args: --non-interactive --skip-existing wheels-*/*

.github/workflows/rust.yml

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Rust
33
on:
44
pull_request:
55
push:
6-
branches:
7-
- main
86

97
env:
108
CARGO_TERM_COLOR: always

ua-parser-py/pyproject.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ build-backend = "maturin"
44

55
[project]
66
name = "ua-parser-rs"
7-
requires-python = ">=3.8"
7+
requires-python = ">=3.9"
88
classifiers = [
99
"Programming Language :: Rust",
1010
"Programming Language :: Python :: 3.9",
11+
"Programming Language :: Python :: 3.10",
12+
"Programming Language :: Python :: 3.11",
13+
"Programming Language :: Python :: 3.12",
1114
"Programming Language :: Python :: Implementation :: CPython",
1215
"Programming Language :: Python :: Implementation :: PyPy",
1316
# "Programming Language :: Python :: Implementation :: GraalPy",

0 commit comments

Comments
 (0)