-
Notifications
You must be signed in to change notification settings - Fork 32
295 lines (244 loc) · 8.95 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
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
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0
# This is a basic workflow to help you get started with Actions
name: Build and Test C++ and Python
# Controls when the workflow will run
on:
# run pipeline on push event of main or release branch
push:
branches:
- main
- 'release/**'
# run pipeline on pull request
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
acquire-python-version-build-sdist:
name: Build sdist and set version
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (!startsWith(github.head_ref, 'release'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Set PyPI Version
run: |
pip install requests build
python set_pypi_version.py
- name: Build SDist
run: python -m build --sdist --outdir wheelhouse .
- name: Keep version file
uses: actions/upload-artifact@v3
with:
name: version
path: PYPI_VERSION
- name: Keep SDist
uses: actions/upload-artifact@v3
with:
name: wheelhouse
path: ./wheelhouse/*.tar.gz
build-cpp-test-linux:
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (!startsWith(github.head_ref, 'release'))
runs-on: ubuntu-latest
strategy:
matrix:
build-option: [ debug, release ]
compiler: [gcc, clang]
include:
- compiler: gcc
cc: gcc-11
cxx: g++-11
- compiler: clang
cc: clang-14
cxx: clang++-14
env:
CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
PRESET: ci-${{ matrix.compiler }}-${{ matrix.build-option }}
steps:
- uses: actions/checkout@v4
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
- name: Enable brew
run: |
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
- name: Install C++ dependencies
run: |
brew install boost eigen nlohmann-json msgpack-cxx doctest
- name: Build and test
run: ./build.sh -p ${{ env.PRESET }} -e -i -t
build-cpp-test-windows:
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (!startsWith(github.head_ref, 'release'))
runs-on: windows-latest
strategy:
matrix:
build-option: [ debug, release ]
compiler: [msvc, clang-cl]
env:
PRESET: ${{ matrix.compiler }}-${{ matrix.build-option }}
steps:
- uses: actions/checkout@v4
- name: Activate conda
run: |
& "$env:CONDA\condabin\conda" init
- name: Install conda environment
run: |
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge libboost-headers eigen nlohmann_json msgpack-cxx doctest
- name: Build and test
run: |
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
# generate cmake cache
cmake --preset ${{ env.PRESET }} -DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library; if(!$?) { Exit $LASTEXITCODE }
# build
cmake --build --preset ${{ env.PRESET }} --verbose -j 1; if(!$?) { Exit $LASTEXITCODE }
# test
ctest --test-dir cpp_build\${{ env.PRESET }} --output-on-failure; if(!$?) { Exit $LASTEXITCODE }
# install
cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install; if(!$?) { Exit $LASTEXITCODE }
# build and run integration test
cd tests/package_tests; if(!$?) { Exit $LASTEXITCODE }
cmake --preset ${{ env.PRESET }}; if(!$?) { Exit $LASTEXITCODE }
cmake --build --preset ${{ env.PRESET }} --verbose -j 1; if(!$?) { Exit $LASTEXITCODE }
cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install; if(!$?) { Exit $LASTEXITCODE }
install\${{ env.PRESET }}\bin\power_grid_model_package_test; if(!$?) { Exit $LASTEXITCODE }
build-cpp-test-macos:
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (!startsWith(github.head_ref, 'release'))
runs-on: macos-latest
strategy:
matrix:
build-option: [ debug, release ]
env:
CMAKE_PREFIX_PATH: /usr/local
CC: clang
CXX: clang++
PRESET: ci-clang-${{ matrix.build-option }}
steps:
- uses: actions/checkout@v4
- name: Install cpp dependencies
run: |
brew install ninja boost eigen nlohmann-json msgpack-cxx doctest
- name: Build and test
run: ./build.sh -p ${{ env.PRESET }} -e -i -t
build-and-test-python:
strategy:
matrix:
platform: [ linux-x64, linux-aarch64, macos, windows ]
include:
- platform: linux-x64
os: ubuntu-latest
cibw_build: "*_x86_64"
- platform: linux-aarch64
os: ubuntu-latest
cibw_build: "*_aarch64"
- platform: macos
os: macos-latest
cibw_build: "*"
- platform: windows
os: windows-latest
cibw_build: "*"
runs-on: ${{ matrix.os }}
needs: [acquire-python-version-build-sdist]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: version
path: .
- name: Set up QEMU
if: matrix.os == 'ubuntu-latest'
uses: docker/setup-qemu-action@v3
- name: Build wheels
uses: pypa/[email protected]
# GitHub Actions specific build parameters
env:
# pass GitHub runner info into Linux container
CIBW_ENVIRONMENT_PASS_LINUX: GITHUB_SHA GITHUB_REF GITHUB_RUN_NUMBER
CIBW_BUILD: ${{ matrix.cibw_build }}
- name: Keep wheel files
uses: actions/upload-artifact@v3
with:
name: wheelhouse
path: ./wheelhouse/*.whl
build-and-test-conda:
name: Build and test in Conda
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (!startsWith(github.head_ref, 'release'))
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: ["ubuntu", "macos", "windows"]
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: conda-pgm-env
environment-file: .github/conda_pgm_env.yml
auto-activate-base: false
- name: List conda
run: |
conda info
conda list
- name: Build
run: python -m pip install . -vv --no-build-isolation --no-deps
- name: Test
run: pytest
publish-wheels:
needs: [build-cpp-test-linux, build-cpp-test-windows, build-cpp-test-macos, build-and-test-python, build-and-test-conda]
runs-on: ubuntu-latest
permissions:
contents: write
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASS }}
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: x64
- uses: actions/download-artifact@v3
with:
name: wheelhouse
path: wheelhouse
- uses: actions/download-artifact@v3
with:
name: version
path: .
- name: List assets
run: |
ls ./wheelhouse/ -al
- name: Get tag
id: tag
run: echo "tag=v$(cat PYPI_VERSION)" >> $GITHUB_OUTPUT
- name: Display tag
run: echo "${{ steps.tag.outputs.tag }}"
- name: Upload wheels
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch')
run: |
pip install twine
echo "Publish to PyPI..."
twine upload --verbose wheelhouse/*
- name: Release
uses: softprops/action-gh-release@v1
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch')
with:
files: |
./wheelhouse/*
tag_name: ${{ steps.tag.outputs.tag }}
prerelease: ${{ contains(steps.tag.outputs.tag, 'rc') }}
generate_release_notes: true
target_commitish: ${{ github.sha }}