-
-
Notifications
You must be signed in to change notification settings - Fork 29
189 lines (163 loc) · 5.25 KB
/
CI.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
183
184
185
186
187
188
189
name: CI
permissions:
id-token: write
on:
push:
branches:
- main
tags:
- "*"
pull_request:
workflow_dispatch:
inputs:
# Latest commit to include with the release. If omitted, use the latest commit on the main branch.
sha:
description: Commit SHA
type: string
defaults:
run:
shell: bash
env:
PYTHON_VERSION: '3.9'
jobs:
create-sdist:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: [polars_ds]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Create source distribution
uses: PyO3/maturin-action@v1
with:
command: sdist
args: >
--manifest-path Cargo.toml
--out dist
- name: Test sdist
run: |
pip install --force-reinstall --verbose dist/*.tar.gz
pip install typing_extensions
pip install -r requirements.txt
python -c 'import polars_ds as pds'
python -c 'from polars_ds import linear_models'
python -c 'from polars_ds.ts_features import *'
python -c 'from polars_ds.spatial import *'
python -c 'from polars_ds.sample_and_split import *'
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist-${{ matrix.package }}
path: dist/*.tar.gz
- name: Test Correctness
run: |
python -m pip install --upgrade pip
pip install pytest
pip install .
pip install -r tests/requirements-test.txt
pytest tests/test_*
- name: Test Notebooks
run: |
python -m pip install --upgrade pip
pip install jupyter ipython ipykernel nbconvert
pip install -r tests/requirements-test.txt
jupyter execute examples/basics.ipynb
jupyter execute examples/diagnosis.ipynb
jupyter execute examples/sample_and_split.ipynb
build-wheels:
runs-on: ${{ matrix.os }}
needs: [create-sdist]
strategy:
fail-fast: false
matrix:
package: [polars_ds]
os: [ubuntu-latest, macos-13, windows-latest]
architecture: [x86-64, aarch64]
exclude:
- os: windows-latest
architecture: aarch64
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Determine CPU features for x86-64
id: features
if: matrix.architecture == 'x86-64'
env:
IS_MACOS: ${{ matrix.os == 'macos-13' }}
run: |
if [[ "$IS_MACOS" = true ]]; then
FEATURES=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma,+pclmulqdq
else
FEATURES=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+avx2,+fma,+bmi1,+bmi2,+lzcnt,+pclmulqdq
fi
echo "features=$FEATURES" >> $GITHUB_OUTPUT
- name: Set RUSTFLAGS for x86-64
if: matrix.architecture == 'x86-64'
env:
FEATURES: ${{ steps.features.outputs.features }}
run: echo "RUSTFLAGS=-C target-feature=${{ steps.features.outputs.features }}" >> $GITHUB_ENV
- name: Set Rust target for aarch64
if: matrix.architecture == 'aarch64'
id: target
run: |
TARGET=${{ matrix.os == 'macos-13' && 'aarch64-apple-darwin' || 'aarch64-unknown-linux-gnu'}}
echo "target=$TARGET" >> $GITHUB_OUTPUT
- name: Set jemalloc for aarch64 Linux
if: matrix.architecture == 'aarch64' && matrix.os == 'ubuntu-latest'
run: |
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
target: ${{ steps.target.outputs.target }}
args: >
--release
--manifest-path Cargo.toml
--out dist
manylinux: ${{ matrix.architecture == 'aarch64' && '2_24' || 'auto' }}
- name: Test wheel
# Only test on x86-64 for now as this matches the runner architecture
if: matrix.architecture == 'x86-64'
run: |
pip install --force-reinstall --verbose dist/*.whl
pip install typing_extensions
python -c 'import polars_ds'
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.package }}-${{ matrix.os }}-${{ matrix.architecture }}
path: dist/*.whl
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [build-wheels, create-sdist]
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheel-*
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: sdist-*
merge-multiple: true
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
with:
command: upload
args: --non-interactive --skip-existing *