-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (160 loc) · 5.14 KB
/
build-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Build & test
on:
workflow_dispatch:
pull_request:
paths:
- "**.pyi?"
- "**.rs"
- "Cargo.*"
- "pyproject.toml"
push:
branches:
- "main"
paths:
- "**.pyi?"
- "**.rs"
- "Cargo.*"
- "pyproject.toml"
workflow_call:
inputs:
release:
type: boolean
description: Build for release
default: false
outputs:
run_id:
description: Workflow run ID
value: ${{ jobs.output_run_id.outputs.run_id }}
env:
# If this workflow is called to build for release, build using
# release profile.
build_profile: ${{ inputs.release && 'release' || 'dev' }}
jobs:
linux:
name: Build & test on Linux
runs-on: ubuntu-latest
strategy:
matrix:
# If this workflow is called to build for release, build for x64 and ARM64
# processors. However, run tests only for x64, as GH doesn't provide
# ARM64 runners.
target: ${{ inputs.release && fromJSON('["x64", "aarch64"]') || fromJSON('["x64"]') }}
# If this workflow is called to build for release, build using
# only one Python version, which is the lowest ABI version set
# in PyO3 features.
py: ${{ inputs.release && fromJSON('["3.8"]') || fromJSON('["3.8", "3.12"]') }}
env:
DISPLAY: :0
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
- name: Install test dependencies
run: sudo apt-get update & sudo apt-get install -y xvfb xclip
- name: Run virtual X11 server
run: Xvfb :0 -screen 0 800x600x16 &
- name: Setup venv
run: python -m venv .venv
- name: Build extension module
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --profile ${{ env.build_profile }} --out dist
manylinux: auto
- name: Run tests
if: ${{ matrix.target == 'x64' }}
run: |
source .venv/bin/activate
pip install dist/*
pip install -r requirements-dev.txt
pytest -v
- name: Update build artifact
if: ${{ inputs.release }}
uses: actions/upload-artifact@v4
with:
name: wheels-${{ runner.os }}-${{ matrix.target }}
path: dist
windows:
name: Build & test on Windows
runs-on: windows-latest
strategy:
matrix:
# If this workflow is called to build for release, build using
# only one Python version, which is the lowest ABI version set
# in PyO3 features.
py: ${{ inputs.release && fromJSON('["3.8"]') || fromJSON('["3.8", "3.12"]') }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
- name: Setup venv
run: python -m venv .venv
- name: Build extension module
uses: PyO3/maturin-action@v1
with:
target: x64
args: --profile ${{ env.build_profile }} --out dist
- name: Run tests
shell: powershell
run: |
.venv\Scripts\activate.ps1
pip install dist\$(Get-ChildItem -Name dist\*.whl)
pip install -r requirements-dev.txt
pytest -v
- name: Update build artifact
if: ${{ inputs.release }}
uses: actions/upload-artifact@v4
with:
name: wheels-${{ runner.os }}
path: dist
macos:
name: Build & test on MacOS
runs-on: macos-12
strategy:
matrix:
# If this workflow is called to build for release, build for x64 and ARM64
# processors. However, run tests only for x64, as GH doesn't provide
# ARM64 runners.
target: ${{ inputs.release && fromJSON('["x64", "aarch64"]') || fromJSON('["x64"]') }}
# If this workflow is called to build for release, build using
# only one Python version, which is the lowest ABI version set
# in PyO3 features.
py: ${{ inputs.release && fromJSON('["3.8"]') || fromJSON('["3.8", "3.12"]') }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
- name: Setup venv
run: python -m venv .venv
- name: Build extension module
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --profile ${{ env.build_profile }} --out dist
- name: Run tests
if: ${{ matrix.target == 'x64' }}
run: |
source .venv/bin/activate
pip install dist/*
pip install -r requirements-dev.txt
pytest -v
- name: Update build artifact
if: ${{ inputs.release }}
uses: actions/upload-artifact@v4
with:
name: wheels-${{ runner.os }}-${{ matrix.target }}
path: dist
output_run_id:
name: Export workflow run ID to the caller
if: ${{ inputs.release }}
runs-on: ubuntu-latest
env:
RUN_ID: ${{ github.run_id }}
outputs:
run_id: ${{ steps.export.outputs.run_id }}
steps:
- id: export
run: echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT