-
Notifications
You must be signed in to change notification settings - Fork 11
218 lines (186 loc) · 6.49 KB
/
selene-plugins.yml
File metadata and controls
218 lines (186 loc) · 6.49 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
name: Selene Plugins
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -C debuginfo=0
on:
push:
branches: [master, development, dev]
paths:
- 'python/selene-plugins/**'
- 'crates/pecos-simulators/**'
- 'crates/pecos-core/**'
- 'exp/pecos-stab-tn/**'
- '.github/workflows/selene-plugins.yml'
pull_request:
branches: [master, development, dev]
paths:
- 'python/selene-plugins/**'
- 'crates/pecos-simulators/**'
- 'crates/pecos-core/**'
- 'exp/pecos-stab-tn/**'
- '.github/workflows/selene-plugins.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
# Build and test on the current platform (fast feedback)
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-15-intel, windows-latest]
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Rust
run: rustup show
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Build and install Selene plugins (Unix)
if: runner.os != 'Windows'
run: |
if [[ "${{ runner.os }}" == "macOS" ]]; then
EXT="dylib"
else
EXT="so"
fi
# Discover all selene plugins, build, copy libraries, and install
CARGO_ARGS=""
for DIR in python/selene-plugins/pecos-selene-*/; do
PLUGIN=$(basename "$DIR")
CARGO_ARGS="$CARGO_ARGS -p $PLUGIN"
done
cargo build --release $CARGO_ARGS
for DIR in python/selene-plugins/pecos-selene-*/; do
PLUGIN=$(basename "$DIR")
LIB_NAME=$(echo "$PLUGIN" | tr '-' '_')
DEST="python/selene-plugins/$PLUGIN/python/${LIB_NAME}/_dist/lib"
mkdir -p "$DEST"
cp "target/release/lib${LIB_NAME}.$EXT" "$DEST/"
uv pip install --system -e "${DIR}[test]"
done
- name: Build and install Selene plugins (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$plugins = Get-ChildItem -Directory python/selene-plugins/pecos-selene-* | Select-Object -ExpandProperty Name
$cargoArgs = $plugins | ForEach-Object { "-p"; $_ }
cargo build --release @cargoArgs
foreach ($plugin in $plugins) {
$libName = $plugin -replace '-', '_'
$dest = "python/selene-plugins/$plugin/python/$libName/_dist/lib"
New-Item -ItemType Directory -Force -Path $dest
Copy-Item "target/release/$libName.dll" "$dest/"
}
foreach ($pluginDir in (Get-ChildItem -Directory python/selene-plugins/pecos-selene-*)) {
uv pip install --system -e "$($pluginDir.FullName)[test]"
}
- name: Run tests
run: |
pytest python/selene-plugins/ -v --tb=short
# Build wheels for distribution
build-wheels:
needs: test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-15-intel, windows-latest]
plugin:
- name: pecos-selene-stabilizer
package: pecos_selene_stabilizer
- name: pecos-selene-statevec
package: pecos_selene_statevec
- name: pecos-selene-stab-vec
package: pecos_selene_stab_vec
- name: pecos-selene-stab-mps
package: pecos_selene_stab_mps
- name: pecos-selene-mast
package: pecos_selene_mast
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Rust
run: rustup show
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Build Rust library (Unix)
if: runner.os != 'Windows'
run: |
cargo build --release -p ${{ matrix.plugin.name }}
- name: Build Rust library (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cargo build --release -p ${{ matrix.plugin.name }}
- name: Copy library to Python package (Unix)
if: runner.os != 'Windows'
run: |
if [[ "${{ runner.os }}" == "macOS" ]]; then
EXT="dylib"
else
EXT="so"
fi
PLUGIN_DIR="python/selene-plugins/${{ matrix.plugin.name }}"
mkdir -p "$PLUGIN_DIR/python/${{ matrix.plugin.package }}/_dist/lib"
cp "target/release/lib${{ matrix.plugin.package }}.$EXT" "$PLUGIN_DIR/python/${{ matrix.plugin.package }}/_dist/lib/"
- name: Copy library to Python package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$pluginDir = "python/selene-plugins/${{ matrix.plugin.name }}"
New-Item -ItemType Directory -Force -Path "$pluginDir/python/${{ matrix.plugin.package }}/_dist/lib"
Copy-Item "target/release/${{ matrix.plugin.package }}.dll" "$pluginDir/python/${{ matrix.plugin.package }}/_dist/lib/"
- name: Build wheel
run: |
cd python/selene-plugins/${{ matrix.plugin.name }}
uv pip install --system build
python -m build --wheel --outdir dist
- name: Upload wheel
uses: actions/upload-artifact@v7
with:
name: wheel-${{ matrix.plugin.name }}-${{ matrix.os }}
path: python/selene-plugins/${{ matrix.plugin.name }}/dist/*.whl
# Collect all wheels into a single artifact
collect-wheels:
needs: build-wheels
runs-on: ubuntu-latest
steps:
- name: Download all wheel artifacts
uses: actions/download-artifact@v7
with:
path: wheels/
pattern: wheel-*
merge-multiple: true
- name: List wheels
run: |
echo "=== All Selene plugin wheels ==="
ls -la wheels/
echo ""
echo "=== Summary ==="
echo "Total wheels: $(ls -1 wheels/*.whl 2>/dev/null | wc -l)"
- name: Upload combined wheels
uses: actions/upload-artifact@v7
with:
name: selene-plugin-wheels
path: wheels/*.whl