-
Notifications
You must be signed in to change notification settings - Fork 26
182 lines (173 loc) · 6.08 KB
/
main.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
name: CI
on:
push:
branches: ["master"]
tags:
- "*"
pull_request:
branches: ["master"]
env:
# Should speed up build. See
# https://matklad.github.io/2021/09/04/fast-rust-builds.html
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
jobs:
tests:
name: "${{ matrix.os }}: Python ${{ matrix.python-version }}"
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: ["ubuntu-20.04", "macos-latest"]
runs-on: "${{ matrix.os }}"
env:
PYTHONFAULTHANDLER: "true"
steps:
- uses: "actions/checkout@v3"
with:
# We need tags to get the correct code version:
fetch-depth: 0
- uses: "actions/setup-python@v4"
with:
python-version: "${{ matrix.python-version }}"
- uses: "actions-rs/toolchain@v1"
with:
toolchain: stable
- name: "Install rust for arm64"
if: startsWith(matrix.os, 'mac') && (matrix.python-version == '3.9')
run: |
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
- name: "Install gfortran"
if: startsWith(matrix.os, 'mac')
run: |
brew install gcc
gfortran --version || sudo ln -s `which gfortran-12` /usr/local/bin/gfortran
- uses: Swatinem/rust-cache@v1
with:
key: "${{ matrix.os }}-${{ matrix.python-version }}"
- name: "Install gfortran"
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y gfortran ninja-build lld
- name: "Install dependencies and code"
run: |
set -euo pipefail
make venv
. venv/bin/activate
python -m sysconfig
make
pip install -e .[dev]
- name: "Run tests"
run: |
set -euo pipefail
. venv/bin/activate
make test
- name: "Build macOS wheels"
if: startsWith(matrix.os, 'mac') && (matrix.python-version == '3.9')
uses: pypa/[email protected]
env:
MACOSX_DEPLOYMENT_TARGET: "11"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_SKIP: "cp37-macosx_arm64 cp36* cp37* cp38* cp39* pp*"
CIBW_BEFORE_BUILD: "touch filpreload/src/_filpreload.c" # force rebuild of Python code with new interpreter
CIBW_TEST_COMMAND: python -m filprofiler run {project}/benchmarks/pystone.py
with:
output-dir: dist
- name: "Build manylinux wheels"
if: startsWith(matrix.os, 'ubuntu') && (matrix.python-version == '3.9')
run: |
set -euo pipefail
. venv/bin/activate
make manylinux-wheel
# Test wheel
deactivate
python3.9 -m venv venv2
. venv2/bin/activate
pip install -r requirements-dev.txt
pip install dist/*-cp39-*manylinux*.whl
mv filprofiler filprofiler.disabled
make test-python-no-deps
- uses: actions/upload-artifact@v3
with:
name: "${{ matrix.os }}-${{ matrix.python-version }}-wheel"
path: dist/*.whl
# - name: Publish distribution 📦 to Test PyPI
# if: (startsWith(matrix.os, 'ubuntu') && (matrix.python-version == '3.9')) || startsWith(matrix.os, 'mac')
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
# run: |
# set -euo pipefail
# . venv/bin/activate
# twine check dist/*.whl
# twine upload --repository testpypi dist/*.whl
- name: Publish distribution 📦 to PyPI
if: startsWith(github.event.ref, 'refs/tags') && ((startsWith(matrix.os, 'ubuntu') && (matrix.python-version == '3.9')) || (startsWith(matrix.os, 'mac') && (matrix.python-version == '3.9')))
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
set -euo pipefail
. venv/bin/activate
twine check dist/*.whl
twine upload --repository pypi dist/*.whl
docs:
name: "Documentation check and publish"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- name: "Run mdbook"
run: |
set -euo pipefail
cd docs
./build.sh
- name: Publish
if: startsWith(github.event.ref, 'refs/tags')
env:
PUBLISH_DOCS_HOOK: ${{ secrets.PUBLISH_DOCS_HOOK }}
run: |
set -euo pipefail
curl -X POST -d '{}' "$PUBLISH_DOCS_HOOK"
arm-wheels:
name: "Wheels for ARM64"
runs-on: "ubuntu-latest"
#if: startsWith(github.event.ref, 'refs/tags')
env:
CIBW_ARCHS_LINUX: aarch64
CIBW_MANYLINUX_AARCH64_IMAGE: "manylinux_2_28"
CIBW_BEFORE_ALL_LINUX: "yum install -y lld && curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y"
CIBW_BEFORE_BUILD: "touch filpreload/src/_filpreload.c" # force rebuild of Python code with new interpreter
CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"'
CIBW_SKIP: "cp36-* cp37-* cp38-* pp* *-musllinux*"
CIBW_TEST_COMMAND: python -m filprofiler run {project}/benchmarks/pystone.py
steps:
- uses: actions/checkout@v3
with:
# We need tags to get the correct code version:
fetch-depth: 0
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Build wheels
uses: pypa/[email protected]
with:
output-dir: dist
- uses: actions/upload-artifact@v3
with:
name: "arm64-wheel"
path: dist/*.whl
- name: Publish distribution 📦 to PyPI
if: startsWith(github.event.ref, 'refs/tags')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
set -euo pipefail
pip install twine
twine check dist/*.whl
twine upload --repository pypi dist/filprofiler*.whl