Skip to content

Commit 3dbc018

Browse files
authored
Improve manual profiling runs (#939)
1 parent d2b42be commit 3dbc018

File tree

5 files changed

+201
-123
lines changed

5 files changed

+201
-123
lines changed

.github/workflows/build-wheels.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Build Wheels
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
sdist-name:
7+
description: Name of the source distribution file
8+
required: true
9+
type: string
10+
build-all:
11+
description: Build all wheels including musllinux
12+
type: boolean
13+
14+
jobs:
15+
build-wheels:
16+
name: Build wheels on ${{ matrix.os }} for ${{ matrix.archs }}
17+
runs-on: "${{ matrix.os }}"
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- os: ubuntu-24.04-arm
23+
archs: aarch64
24+
- os: ubuntu-latest
25+
archs: x86_64
26+
- os: macos-latest
27+
archs: arm64
28+
- os: macos-15-intel
29+
archs: x86_64
30+
# - os: windows-11-arm
31+
# archs: ARM64
32+
- os: windows-latest
33+
archs: AMD64
34+
35+
env:
36+
CIBW_SKIP: "${{ !inputs.build-all && '*-musllinux_*' || '' }}"
37+
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v5
41+
42+
- name: Download source distribution
43+
uses: actions/download-artifact@v6
44+
with:
45+
name: artifact-sdist
46+
path: dist
47+
48+
# TODO: Remove this once the action supports specifying extras, see:
49+
# https://github.com/pypa/cibuildwheel/pull/2630
50+
- name: Install uv
51+
if: runner.os != 'Linux'
52+
uses: astral-sh/setup-uv@v7
53+
54+
- name: Build & Test Wheels
55+
uses: pypa/cibuildwheel@v3.2.1
56+
with:
57+
config-file: .cibuildwheel.toml
58+
package-dir: dist/${{ inputs.sdist-name }}
59+
env:
60+
CIBW_ARCHS: "${{ matrix.archs }}"
61+
62+
- name: Upload artifact
63+
uses: actions/upload-artifact@v5
64+
with:
65+
name: artifact-wheels-${{ matrix.os }}-${{ matrix.archs }}
66+
path: wheelhouse/*.whl
67+
if-no-files-found: error

.github/workflows/ci.yml

Lines changed: 10 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -32,61 +32,11 @@ on:
3232

3333
jobs:
3434
prepare:
35-
name: Run static analysis and prepare build
36-
runs-on: ubuntu-latest
37-
38-
outputs:
39-
sdist-name: "${{ steps.build-sdist.outputs.file-name }}"
40-
latest-supported-python: "${{ steps.latest-supported-python.outputs.version }}"
41-
42-
steps:
43-
- name: Checkout code
44-
uses: actions/checkout@v5
45-
46-
- name: Fetch release history
47-
uses: ./.github/actions/fetch-release-history
48-
with:
49-
github-token: "${{ github.token }}"
50-
51-
- name: Load environment file
52-
uses: ./.github/actions/load-env
53-
54-
- name: Install Python
55-
uses: actions/setup-python@v6
56-
with:
57-
python-version-file: pyproject.toml
58-
59-
- name: Install uv
60-
uses: astral-sh/setup-uv@v7
61-
62-
- name: Install command runner
63-
run: uv tool install rust-just
64-
65-
- name: Install static analysis dependencies
66-
run: just env-sync hooks
67-
68-
- name: Run hooks
69-
run: just hooks-check
70-
71-
- name: Build source distribution
72-
id: build-sdist
73-
run: |-
74-
uv build --sdist
75-
sdist_name=$(basename dist/*.tar.gz)
76-
echo "file-name=${sdist_name}" >> $GITHUB_OUTPUT
77-
78-
- name: Upload artifact
79-
uses: actions/upload-artifact@v5
80-
with:
81-
name: artifact-sdist
82-
path: dist/${{ steps.build-sdist.outputs.file-name }}
83-
if-no-files-found: error
84-
85-
- name: Fetch latest supported Python
86-
id: latest-supported-python
87-
uses: ./.github/actions/latest-supported-python
88-
with:
89-
github-token: "${{ github.token }}"
35+
name: Validate build
36+
uses: ./.github/workflows/prepare-build.yml
37+
with:
38+
run-static-analysis: true
39+
fetch-latest-python: true
9040

9141
test:
9242
name: Test Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
@@ -218,61 +168,14 @@ jobs:
218168
run: just test-typing
219169

220170
build-wheels:
221-
name: Build wheels on ${{ matrix.os }} for ${{ matrix.archs }}
171+
name: Build wheels ${{ github.event_name == 'release' && 'for release' || '' }}
222172
needs:
223173
- test
224174
- prepare
225-
runs-on: "${{ matrix.os }}"
226-
strategy:
227-
fail-fast: false
228-
matrix:
229-
include:
230-
- os: ubuntu-24.04-arm
231-
archs: aarch64
232-
- os: ubuntu-latest
233-
archs: x86_64
234-
- os: macos-latest
235-
archs: arm64
236-
- os: macos-15-intel
237-
archs: x86_64
238-
# - os: windows-11-arm
239-
# archs: ARM64
240-
- os: windows-latest
241-
archs: AMD64
242-
243-
env:
244-
CIBW_SKIP: "${{ github.event_name != 'release' && '*-musllinux_*' || '' }}"
245-
246-
steps:
247-
- name: Checkout code
248-
uses: actions/checkout@v5
249-
250-
- name: Download source distribution
251-
uses: actions/download-artifact@v6
252-
with:
253-
name: artifact-sdist
254-
path: dist
255-
256-
# TODO: Remove this once the action supports specifying extras, see:
257-
# https://github.com/pypa/cibuildwheel/pull/2630
258-
- name: Install uv
259-
if: runner.os != 'Linux'
260-
uses: astral-sh/setup-uv@v7
261-
262-
- name: Build & Test Wheels
263-
uses: pypa/cibuildwheel@v3.2.1
264-
with:
265-
config-file: .cibuildwheel.toml
266-
package-dir: dist/${{ needs.prepare.outputs.sdist-name }}
267-
env:
268-
CIBW_ARCHS: "${{ matrix.archs }}"
269-
270-
- name: Upload artifact
271-
uses: actions/upload-artifact@v5
272-
with:
273-
name: artifact-wheels-${{ matrix.os }}-${{ matrix.archs }}
274-
path: wheelhouse/*.whl
275-
if-no-files-found: error
175+
uses: ./.github/workflows/build-wheels.yml
176+
with:
177+
sdist-name: "${{ needs.prepare.outputs.sdist-name }}"
178+
build-all: ${{ github.event_name == 'release' }}
276179

277180
profile:
278181
name: Run profiling tests on Python ${{ needs.prepare.outputs.latest-supported-python }}
@@ -281,7 +184,6 @@ jobs:
281184
- build-wheels
282185
uses: ./.github/workflows/profile.yml
283186
with:
284-
version: dev
285187
python: "${{ needs.prepare.outputs.latest-supported-python }}"
286188

287189
upload-pypi:
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Manual Profile
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: Version of msgspec to profile from PyPI (leave empty to build from source)
8+
type: string
9+
python:
10+
description: Minor version of Python to use for profiling
11+
type: string
12+
13+
jobs:
14+
prepare:
15+
name: Prepare build
16+
if: inputs.version == ''
17+
uses: ./.github/workflows/prepare-build.yml
18+
with:
19+
run-static-analysis: false
20+
fetch-latest-python: false
21+
22+
build-wheels:
23+
name: Build wheels
24+
if: inputs.version == ''
25+
needs:
26+
- prepare
27+
uses: ./.github/workflows/build-wheels.yml
28+
with:
29+
sdist-name: "${{ needs.prepare.outputs.sdist-name }}"
30+
31+
profile:
32+
name: Run profiling tests
33+
needs:
34+
- build-wheels
35+
if: always() && (needs.build-wheels.result == 'success' || needs.build-wheels.result == 'skipped')
36+
uses: ./.github/workflows/profile.yml
37+
with:
38+
version: "${{ inputs.version }}"
39+
python: "${{ inputs.python }}"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Prepare Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
run-static-analysis:
7+
description: Whether to run static analysis checks
8+
type: boolean
9+
fetch-latest-python:
10+
description: Whether to fetch the latest supported Python version
11+
type: boolean
12+
outputs:
13+
sdist-name:
14+
description: Name of the source distribution file
15+
value: "${{ jobs.prepare.outputs.sdist-name }}"
16+
latest-supported-python:
17+
description: Latest supported Python version
18+
value: "${{ jobs.prepare.outputs.latest-supported-python }}"
19+
20+
jobs:
21+
prepare:
22+
name: Prepare build ${{ inputs.run-static-analysis && 'with static analysis' || '' }}
23+
runs-on: ubuntu-latest
24+
25+
outputs:
26+
sdist-name: "${{ steps.build-sdist.outputs.file-name }}"
27+
latest-supported-python: "${{ steps.latest-supported-python.outputs.version }}"
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v5
32+
33+
- name: Fetch release history
34+
uses: ./.github/actions/fetch-release-history
35+
with:
36+
github-token: "${{ github.token }}"
37+
38+
- name: Load environment file
39+
uses: ./.github/actions/load-env
40+
41+
- name: Install Python
42+
uses: actions/setup-python@v6
43+
with:
44+
python-version-file: pyproject.toml
45+
46+
- name: Install uv
47+
uses: astral-sh/setup-uv@v7
48+
49+
- name: Install command runner
50+
if: inputs.run-static-analysis
51+
run: uv tool install rust-just
52+
53+
- name: Install static analysis dependencies
54+
if: inputs.run-static-analysis
55+
run: just env-sync hooks
56+
57+
- name: Run hooks
58+
if: inputs.run-static-analysis
59+
run: just hooks-check
60+
61+
- name: Build source distribution
62+
id: build-sdist
63+
run: |-
64+
uv build --sdist
65+
sdist_name=$(basename dist/*.tar.gz)
66+
echo "file-name=${sdist_name}" >> $GITHUB_OUTPUT
67+
68+
- name: Upload artifact
69+
uses: actions/upload-artifact@v5
70+
with:
71+
name: artifact-sdist
72+
path: dist/${{ steps.build-sdist.outputs.file-name }}
73+
if-no-files-found: error
74+
75+
- name: Fetch latest supported Python
76+
if: inputs.fetch-latest-python
77+
id: latest-supported-python
78+
uses: ./.github/actions/latest-supported-python
79+
with:
80+
github-token: "${{ github.token }}"

.github/workflows/profile.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
name: Profile
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
version:
7-
description: Version of msgspec to profile
8-
required: true
9-
type: string
10-
python:
11-
description: Minor version of Python to use for profiling
12-
type: string
134
workflow_call:
145
inputs:
156
version:
16-
description: Version of msgspec to profile
17-
required: true
7+
description: Version of msgspec to profile from PyPI (leave empty to use artifacts)
188
type: string
199
python:
2010
description: Minor version of Python to use for profiling
@@ -81,19 +71,19 @@ jobs:
8171
run: uv sync --only-group test-prof
8272

8373
- name: Download artifacts
84-
if: inputs.version == 'dev'
74+
if: inputs.version == ''
8575
uses: actions/download-artifact@v6
8676
with:
8777
name: artifact-wheels-${{ matrix.os }}-${{ matrix.archs }}
8878
path: dist
8979
merge-multiple: true
9080

91-
- name: Install version ${{ inputs.version }} from ${{ inputs.version == 'dev' && 'artifact' || 'PyPI' }}
81+
- name: Install from ${{ inputs.version == '' && 'artifact' || format('PyPI (version {0})', inputs.version) }}
9282
env:
9383
VIRTUAL_ENV: "${{ steps.metadata.outputs.env-path }}"
9484
run: >-
95-
uv pip install${{ inputs.version == 'dev' && ' --no-index --find-links dist' || '' }}
96-
${{ format('msgspec{0}{1}', inputs.version != 'dev' && '==' || '', inputs.version != 'dev' && inputs.version || '') }}
85+
uv pip install${{ inputs.version == '' && ' --no-index --find-links dist' || '' }}
86+
${{ inputs.version == '' && 'msgspec' || format('msgspec=={0}', inputs.version) }}
9787
9888
# TODO: set up infra to commit results after each merge and then make tests compare
9989
- name: Run profiling tests on Python ${{ steps.metadata.outputs.python-version }}

0 commit comments

Comments
 (0)