Skip to content

Commit fb81efc

Browse files
committed
Split CI and publish workflows for rate limiter (#2)
Separate the single workflow into two: - ci-rate-limiter.yaml: build & test on push/PR with path filters - pypi-rate-limiter.yaml: build, test & publish on tags or manual dispatch This prevents tag pushes from accidentally publishing to Test PyPI and avoids unnecessary builds on unrelated main pushes. Signed-off-by: Jonathan Springer <jps@s390x.com> Signed-off-by: lucarlig <luca.carlig@ibm.com>
1 parent 23baa05 commit fb81efc

2 files changed

Lines changed: 131 additions & 20 deletions

File tree

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: CI cpex-rate-limiter
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "rate_limiter/**"
8+
- ".github/workflows/ci-rate-limiter.yaml"
9+
pull_request:
10+
paths:
11+
- "rate_limiter/**"
12+
- ".github/workflows/ci-rate-limiter.yaml"
13+
- ".github/workflows/pypi-rate-limiter.yaml"
14+
15+
permissions:
16+
contents: read
17+
18+
defaults:
19+
run:
20+
working-directory: rate_limiter
21+
22+
jobs:
23+
build-linux:
24+
name: Build & Test / ${{ matrix.platform }}
25+
runs-on: ${{ matrix.runner }}
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
include:
30+
- runner: ubuntu-latest
31+
platform: linux-x86_64
32+
- runner: ubuntu-24.04-arm
33+
platform: linux-aarch64
34+
- runner: ubuntu-24.04-s390x
35+
platform: linux-s390x
36+
- runner: ubuntu-24.04-ppc64le
37+
platform: linux-ppc64le
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Install system dependencies
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get install -y python3-dev python3-venv pipx
46+
47+
- name: Install Rust toolchain
48+
run: |
49+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
50+
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
51+
52+
- name: Install maturin
53+
run: pipx install maturin
54+
55+
- name: Build wheel
56+
run: maturin build --release --out dist
57+
58+
- name: Install wheel and test dependencies
59+
run: |
60+
python3 -m venv .venv
61+
.venv/bin/pip install dist/*.whl pytest pytest-asyncio
62+
63+
- name: Run tests
64+
run: .venv/bin/pytest tests/ -v
65+
66+
build-macos:
67+
name: Build & Test / macos-arm64
68+
runs-on: macos-latest
69+
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- uses: actions/setup-python@v5
74+
with:
75+
python-version: "3.11"
76+
77+
- name: Install Rust toolchain
78+
run: |
79+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
80+
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
81+
82+
- name: Install maturin
83+
run: pip install maturin
84+
85+
- name: Build wheel
86+
run: maturin build --release --out dist
87+
88+
- name: Install wheel and test dependencies
89+
run: |
90+
pip install dist/*.whl pytest pytest-asyncio
91+
92+
- name: Run tests
93+
run: pytest tests/ -v
94+
95+
build-windows:
96+
name: Build & Test / windows-x86_64
97+
runs-on: windows-latest
98+
99+
steps:
100+
- uses: actions/checkout@v4
101+
102+
- uses: actions/setup-python@v5
103+
with:
104+
python-version: "3.11"
105+
106+
- name: Install Rust toolchain
107+
run: |
108+
Invoke-WebRequest -Uri https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
109+
.\rustup-init.exe -y
110+
echo "$env:USERPROFILE\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
111+
112+
- name: Install maturin
113+
run: pip install maturin
114+
115+
- name: Build wheel
116+
run: maturin build --release --out dist
117+
118+
- name: Install wheel and test dependencies
119+
run: |
120+
pip install (Get-Item dist/*.whl).FullName pytest pytest-asyncio
121+
122+
- name: Run tests
123+
run: pytest tests/ -v

.github/workflows/pypi-rate-limiter.yaml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
name: Build cpex-rate-limiter wheels
1+
name: Publish cpex-rate-limiter
22

33
on:
44
push:
5-
branches: [main]
6-
paths:
7-
- "rate_limiter/**"
8-
- ".github/workflows/pypi-rate-limiter.yaml"
9-
pull_request:
10-
paths:
11-
- "rate_limiter/**"
12-
- ".github/workflows/pypi-rate-limiter.yaml"
5+
tags:
6+
- "rate-limiter-v*"
137
workflow_dispatch:
148

159
permissions:
@@ -73,14 +67,8 @@ jobs:
7367
path: rate_limiter/dist/*.whl
7468

7569
build-macos:
76-
name: Build / ${{ matrix.platform }}
77-
runs-on: ${{ matrix.runner }}
78-
strategy:
79-
fail-fast: false
80-
matrix:
81-
include:
82-
- runner: macos-latest
83-
platform: macos-arm64
70+
name: Build / macos-arm64
71+
runs-on: macos-latest
8472

8573
steps:
8674
- uses: actions/checkout@v4
@@ -110,7 +98,7 @@ jobs:
11098
- name: Upload wheel
11199
uses: actions/upload-artifact@v4
112100
with:
113-
name: wheel-${{ matrix.platform }}
101+
name: wheel-macos-arm64
114102
path: rate_limiter/dist/*.whl
115103

116104
build-windows:
@@ -171,13 +159,13 @@ jobs:
171159
path: rate_limiter/dist/*.tar.gz
172160

173161
# ---------------------------------------------------------------------------
174-
# Publish to Test PyPI (on push / PR)
162+
# Publish to Test PyPI (manual dispatch only)
175163
# ---------------------------------------------------------------------------
176164
publish-testpypi:
177165
name: Publish to Test PyPI
178166
needs: [build-linux, build-macos, build-windows, sdist]
179167
runs-on: ubuntu-latest
180-
if: ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch') && !startsWith(github.ref, 'refs/tags/rate-limiter-v')
168+
if: github.event_name == 'workflow_dispatch'
181169
environment: testpypi
182170
permissions:
183171
id-token: write

0 commit comments

Comments
 (0)