-
Notifications
You must be signed in to change notification settings - Fork 0
329 lines (291 loc) Β· 10.9 KB
/
ci.yml
File metadata and controls
329 lines (291 loc) Β· 10.9 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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
name: CI
on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- main
schedule:
- cron: "9 16 * * 1"
jobs:
build:
strategy:
fail-fast: false
matrix:
cfg:
- conda-env: unix
python-version: "3.12"
julia-version: "1.10"
label: conda
runs-on: ubuntu-latest
shell: 'bash -l {0}'
- conda-env: null
python-version: "3.12"
julia-version: "1.10"
label: installer
runs-on: ubuntu-latest
shell: 'bash -e {0}'
- conda-env: unix
python-version: "3.12"
julia-version: "1.10"
label: conda
runs-on: macos-13
shell: 'bash -l {0}'
- conda-env: null
python-version: "3.12" # even patch updates (M.m.p) need editing to match with "warning: hard coded path" below
julia-version: "1.10"
label: installer
runs-on: macos-13
# runs-on: macos-latest # fails b/c cbc can't compile on M1 (the GHA runners)
shell: 'bash -e {0}'
# runs the script installing *released* software and a little testing
- conda-env: null
python-version: "3.12"
julia-version: "1.10"
label: script
runs-on: ubuntu-latest
shell: 'bash -l {0}'
defaults:
run:
shell: ${{ matrix.cfg.shell }}
name: "π ${{ matrix.cfg.python-version }} β’ ${{ matrix.cfg.label }} β’ ${{ matrix.cfg.runs-on }}"
runs-on: ${{ matrix.cfg.runs-on }}
steps:
- uses: actions/checkout@v4
if: matrix.cfg.label == 'script'
with:
sparse-checkout: |
devtools/linux_conda_install.sh
# devtools/conda-envs/unix.yaml # if need local for changes
sparse-checkout-cone-mode: false
- uses: actions/checkout@v4
if: matrix.cfg.label != 'script'
with:
fetch-depth: 0
persist-credentials: false
- name: Edit env file
if: matrix.cfg.label == 'conda'
run: |
echo "::group::View Env Spec File for Conda (from repo)"
cp devtools/conda-envs/${{ matrix.cfg.conda-env }}.yaml unix.yaml
cat unix.yaml
echo "::endgroup::"
if [[ "${{ runner.os }}" == "Linux" ]]; then
:
sed -i "s;- pandamodelsbackend;#- pandamodelsbackend;g" unix.yaml
fi
if [[ "${{ runner.os }}" == "macOS" ]]; then
:
sed -E -i.bak "s;- pandamodelsbackend;#- pandamodelsbackend;g" unix.yaml
fi
echo "::group::View Env Spec File for Conda (Edited)"
cat unix.yaml
echo "::endgroup::"
- name: Install Conda Python ${{ matrix.cfg.python-version }}
if: matrix.cfg.label == 'script'
uses: conda-incubator/setup-miniconda@v3
with:
show-channel-urls: true
auto-activate-base: true
activate-environment: ""
- name: Install Conda Python ${{ matrix.cfg.python-version }} and power software
if: matrix.cfg.label == 'conda'
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: test
environment-file: unix.yaml
python-version: ${{ matrix.cfg.python-version }}
auto-activate-base: false
show-channel-urls: true
add-pip-as-python-dependency: true
conda-remove-defaults: true
- name: Install Python ${{ matrix.cfg.python-version }}
if: matrix.cfg.label == 'installer'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.cfg.python-version }}
- name: Install Python power software
if: matrix.cfg.label == 'installer'
run: |
uname -p
which python pip
python --version
python -m pip install numpy pandas scipy pytest grid2op julia "pandapower>=2.14,<3.0"
- name: Install Julia ${{ matrix.cfg.julia-version }}
if: matrix.cfg.label == 'installer'
uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.cfg.julia-version }}
- name: Install Julia power software
if: matrix.cfg.label != 'script'
run: |
julia -e '
using Pkg
# PwM alone for latest Ipopt and clean PwM test suite
Pkg.add(["PowerModels", "PyCall"])
# for experimenting with full stack. "update_pm" releases PdM version pins on Iptop, etc.
#Pkg.add([
# Pkg.PackageSpec(;name="Ipopt"),
# Pkg.PackageSpec(;name="PowerModels", version="0.21.3"),
# Pkg.PackageSpec(;name="PyCall"),
# Pkg.PackageSpec(;url="https://github.com/loriab/PandaModels.jl", rev="update_pm")
#])'
- name: Install PandaModelsBackend
if: matrix.cfg.label != 'script'
run: |
python -m pip install -e .[tests]
- name: Environment information
if: matrix.cfg.label != 'script'
run: |
python -m pip list
python -m pip list | grep -e power -e grid -e panda
which python python-jl julia
python --version
python-jl --version
julia --version
julia -e 'using Pkg; Pkg.status(); Pkg.status(outdated=true)'
- name: Check all-in-one install script
if: matrix.cfg.label == 'script'
run: |
source devtools/linux_conda_install.sh
- name: Test PowerModels in Julia
# if: false
if: matrix.cfg.label != 'script'
run: |
julia -e 'using PyCall; math = pyimport("math"); print(math.sin(math.pi/4))'
julia -e 'using Pkg; Pkg.test("PowerModels")'
# PwM testing above is clean but takes 6m, so optionally toggle off
- name: Test PandaModels in Julia
if: matrix.cfg.label != 'script'
run: |
julia -e 'using Pkg; Pkg.add("PandaModels")'
#julia -e 'using Pkg; Pkg.add(Pkg.PackageSpec(;name="Ipopt", version="0.9"))'
julia -e 'using Pkg; Pkg.status(); Pkg.status(outdated=true)'
julia -e 'using PandaModels'
julia -e 'using Pkg; Pkg.test("PandaModels")'
# PdM testing above has a couple failures b/c Ipopt=1 unless downgrade (taking PM with it)
# shortcut this step by commenting out the Pkg.test above
- name: Special setup Mac
if: matrix.cfg.label == 'installer' && runner.os == 'macOS'
run: |
# warning: hard coded path
julia -e 'ENV["PYTHON"]="/Users/runner/hostedtoolcache/Python/3.12.10/x64/bin/python"; using Pkg; Pkg.build("PyCall")'
- name: Special setup download delay
if: false # runner.os == 'macOS'
# file download in (basic) section is flaky for Mac. use `sed -i "s;;;g"` for non-Mac
run: |
sed -E -i.bak "s;nb_retry=10;nb_retry=100;g" $(dirname $(which python))/../lib/python${{ matrix.cfg.python-version }}/site-packages/grid2op/MakeEnv/Make.py
sed -E -i.bak "s;time.sleep(1);time.sleep(8);g" $(dirname $(which python))/../lib/python${{ matrix.cfg.python-version }}/site-packages/grid2op/MakeEnv/Make.py
- name: Test PowerModels in PandaPower
if: matrix.cfg.label != 'script'
run: |
which python python-jl
python-jl -m pytest -v $(dirname $(which python))/../lib/python${{ matrix.cfg.python-version }}/site-packages/pandapower/test/opf/test_pandamodels_runpm.py
# use python-jl instead of python above if get a static libpython error
# loc is simply $CONDA_PREFIX but the setup-python counterpart env.pythonLocation seems broken
# PdP testing above has a couple failures b/c Ipopt=1 unless downgrade (taking PM with it)
- name: Test PandaModelsBackend (basic)
if: runner.os == 'Linux' && matrix.cfg.label != 'script'
run: |
which python python-jl
python-jl pandamodelsbackend/tests/test_basic_usage.py
- name: Test PandaModelsBackend (API)
if: matrix.cfg.label != 'script'
run: |
python-jl pandamodelsbackend/tests/test_backend_api.py
- name: Install pypa/build & build a binary wheel and a source tarball
if: matrix.cfg.label == 'installer' && runner.os == 'Linux'
run: |
python -m pip install build --user
python -m build
- name: Store the distribution packages
if: matrix.cfg.label == 'installer' && runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: >-
Publish Python π distribution π¦ to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pandamodelsbackend
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution π¦ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
github-release:
name: >-
Sign the Python π distribution π¦ with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
"$GITHUB_REF_NAME"
--repo "$GITHUB_REPOSITORY"
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
"$GITHUB_REF_NAME" dist/**
--repo "$GITHUB_REPOSITORY"
publish-to-testpypi:
name: Publish Python π distribution π¦ to TestPyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/pandamodelsbackend
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution π¦ to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
skip-existing: true