-
Notifications
You must be signed in to change notification settings - Fork 84
293 lines (250 loc) Β· 10.1 KB
/
test.yml
File metadata and controls
293 lines (250 loc) Β· 10.1 KB
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
name: Build and Test
on:
push:
branches:
- master
- staging
- trying
- 'prepare-*'
pull_request:
branches:
- '**'
# Allow one concurrent deployment
concurrency:
group: ${{ github.ref }}-test
cancel-in-progress: true
jobs:
test:
name: Build and Test
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
target:
- id: 'linux-amd64'
os: 'ubuntu-latest'
target-name: 'x86_64-unknown-linux-gnu'
rust-toolchain: 'stable'
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz'
#- id: 'linux-aarch64'
# os: ['self-hosted', 'linux', 'ARM64', 'python']
# target-name: 'aarch64-unknown-linux-gnu'
# rust-toolchain: 'stable'
# llvm-archive-url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/11.x/linux-aarch64.tar.gz'
- id: 'darwin-amd64'
os: 'macos-latest'
target-name: 'x86_64-apple-darwin'
rust-toolchain: 'stable'
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz'
- id: 'windows-amd64'
os: 'windows-latest'
target-name: 'x86_64-pc-windows-msvc'
rust-toolchain: 'stable'
# llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/11.x/windows-amd64.tar.gz'
llvm_choco_version: 13.0.0
fail-fast: false
runs-on: ${{ matrix.target.os }}
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Install dependencies
if: matrix.target.id == 'linux-amd64'
run: |
sudo apt-get update -y
sudo apt-get install libtinfo5
echo "LD_LIBRARY_PATH=/lib/x86_64-linux-gnu" >> $GITHUB_ENV
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.target.rust-toolchain }}
default: true
override: true
target: ${{ matrix.target.target-name }}
# Caching is disabled because it interferes with artifact creation
# - uses: Swatinem/rust-cache@v2
# with:
# shared-key: "rust-cache"
- name: Set current Python version
shell: bash
run: |
echo "${{ matrix.python }}" > .python-version
- name: Set up Python ${{ matrix.python }} (amd64)
if: matrix.target.id != 'linux-aarch64'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Set up Python ${{ matrix.python }} (aarch64)
if: matrix.target.id == 'linux-aarch64'
shell: bash
run: |
test -d $HOME/.pyenv || curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv install --list | grep '^ ${{ matrix.python }}' | tail -n 1 | tr -d '[:space:]' > .python-version
pyenv install --skip-existing "$(cat .python-version)"
- name: Validate python version
run: |
$pythonVersionFull = (python --version)
$pythonVersion = $pythonVersionFull -replace '\.(\d+)$',''
if ("Python ${{ matrix.python }}" -ne "$pythonVersion"){
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
exit 1
}
$pythonVersion
shell: pwsh
- name: Print python version (verbose)
run: |
python -VV
shell: pwsh
- name: Install LLVM (Choco - Windows)
if: matrix.target.llvm_choco_version
shell: bash
run: |
choco install llvm --version ${{ matrix.target.llvm_choco_version }} --allow-downgrade
cd 'C:\Program Files\LLVM\'
LLVM_DIR=$(pwd)
echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
- name: Install LLVM
if: matrix.target.llvm_url
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSf ${{ matrix.target.llvm_url }} -L -o llvm.tar.xz
LLVM_DIR=$(pwd)/${{ env.LLVM_DIR }}
mkdir ${LLVM_DIR}
tar xf llvm.tar.xz --strip-components=1 -C ${LLVM_DIR}
echo "${LLVM_DIR}/bin" >> $GITHUB_PATH
echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
env:
LLVM_DIR: .llvm
- name: Set up utilities
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
test -f $HOME/.cargo/bin/just || cargo install just
test -f $HOME/.cargo/bin/fd || cargo install fd-find
- name: Set up extra utilities for macOS
if: matrix.target.id == 'darwin-amd64'
shell: bash
run: |
brew install gnu-sed
- name: Set build number when automatically pre-releasing
if: startsWith(github.ref, 'refs/heads/prepare-')
shell: bash
run: |
scripts/update-version.sh "$(scripts/update-version.sh --get)-rc${{ github.run_id }}"
- name: Install the prelude
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
just prelude
- name: Compile the library
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
if test -d .env/bin/; then source .env/bin/activate; else source .env/Scripts/activate; fi
maturin list-python
PYTHON_INTERPRETER=$(maturin list-python 2>&1 | grep -o "CPython $(cat .python-version | grep -o -E '^[^\.]+\.[^\.]+').* at .*" | cut -d' ' -f 4 | tr '\\' '/')
echo "Selected interpreter: ${PYTHON_INTERPRETER}"
just build-all "${{ matrix.target.target-name }}"
- name: Run all the tests
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
if test -d .env/bin/; then source .env/bin/activate; else source .env/Scripts/activate; fi
just test
- name: Build the wheels
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
if test -d .env/bin/; then source .env/bin/activate; else source .env/Scripts/activate; fi
maturin list-python
PYTHON_INTERPRETER=$(maturin list-python 2>&1 | grep -o "CPython $(cat .python-version | grep -o -E '^[^\.]+\.[^\.]+').* at .*" | cut -d' ' -f 4 | tr '\\' '/')
echo "Selected interpreter: ${PYTHON_INTERPRETER}"
just build-all-wheels "${PYTHON_INTERPRETER}" "${{ matrix.target.target-name }}"
just build-any-wheel
- name: Inspect wheels
shell: bash
run: |
ls -lhaGiR target/wheels/*.whl
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: wheels-${{ matrix.python }}-${{ matrix.target.id }}
path: target/wheels
if-no-files-found: error
retention-days: 1
prerelease:
name: Pre-Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/prepare-')
needs: [test]
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Download the Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Inspect artifacts
shell: bash
run: |
ls -lhaGiR artifacts/*
- name: Set current Python version
shell: bash
run: |
echo "3.11" > .python-version
- name: Set up Python ${{ matrix.python }} (amd64)
if: matrix.target.id != 'linux-aarch64'
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Set up Python ${{ matrix.python }} (aarch64)
if: matrix.target.id == 'linux-aarch64'
shell: bash
run: |
test -d $HOME/.pyenv || curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv install --list | grep '^ 3.11' | tail -n 1 | tr -d '[:space:]' > .python-version
pyenv install --skip-existing "$(cat .python-version)"
# Caching is disabled because it interferes with artifact creation
#- uses: Swatinem/rust-cache@v1
- name: Set up just
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
test -f $HOME/.cargo/bin/just || cargo install just
- name: Prelude
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
just prelude
- name: Publish the wheels on TestPyPI
shell: bash
env:
TWINE_PASSWORD: ${{ secrets.MATURIN_PASSWORD }}
run: |
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
if test -d .env/bin/; then source .env/bin/activate; else source .env/Scripts/activate; fi
just publish testpypi $(ls artifacts/wheels-*/*.whl | tr '/' '\t' | sort -k 3 | uniq -f 2 | tr '\t' '/' | grep --invert-match aarch64)
build-status:
if: always() && github.event_name == 'push'
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Mark the job as succeeded
if: needs.test.result == 'success'
run: exit 0
- name: Mark the job as failed
if: needs.test.result != 'success'
run: exit 1