-
Notifications
You must be signed in to change notification settings - Fork 2
171 lines (168 loc) · 6.06 KB
/
quantlib-risks.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
# builds only on the following conditions:
# - pull requests into main
# - OR pushes of tags starting with v*
# - OR manual dispatch on repo
# publishes to test pypi if:
# - in auto-differentiation/QuantLib-Risks repository
# - AND pushes of tags starting with v*
# - OR manual dispatch on repo
# publishes to real PyPI if:
# - publish to Test PyPI worked (with all build conditions above)
# - and if it's a version tag (starting with v*)
name: QuantLib-Risks wheels
on:
pull_request:
branches:
- main
push:
tags:
- v*
workflow_dispatch:
jobs:
build_wheels:
name: Wheels
strategy:
fail-fast: false
matrix:
buildplat: ["win_amd64", "macosx_x86_64", "manylinux_x86_64", "musllinux_x86_64"]
python: ["cp38", "cp39", "cp310", "cp311", "cp312"]
include:
- buildplat: "manylinux_x86_64"
os: ubuntu-20.04
platform: linux
ccache: ccache
preset: linux-xad-gcc-ninja-release
- buildplat: "musllinux_x86_64"
os: ubuntu-20.04
platform: linux
ccache: ccache
preset: linux-xad-gcc-ninja-release
- buildplat: "macosx_x86_64"
os: "macos-12"
platform: macos
ccache: ccache
preset: linux-xad-gcc-ninja-release
- buildplat: "win_amd64"
os: windows-2022
platform: windows
ccache: sccache
preset: windows-xad-msvc-release
exclude:
# gives "is not a supported wheel on this platform" for some reason
- buildplat: "macosx_x86_64"
python: "cp38"
runs-on: ${{ matrix.os }}
env:
QL_PRESET: ${{ matrix.preset }}
CCACHE_EXE: ${{ matrix.ccache }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Setup Boost (Windows)
if: ${{ matrix.platform == 'windows' }}
run: |
choco install -y ninja
$Url = "https://downloads.sourceforge.net/project/boost/boost-binaries/1.84.0/boost_1_84_0-msvc-14.3-64.exe"
(New-Object System.Net.WebClient).DownloadFile($Url, "$RUNNER_TEMP\boost.exe")
Start-Process -Wait -FilePath "$RUNNER_TEMP\boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=C:\local\boost"
- name: Setup Boost (Mac)
if: ${{ matrix.platform == 'macos' }}
run: |
brew install boost
brew install ninja
brew install ccache
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.buildplat }}-${{ matrix.python }}
variant: ${{ matrix.ccache }}
max-size: 650M
- name: Setup boost path (Win)
if: ${{ matrix.platform == 'windows' }}
shell: cmd
run: echo BOOST_ROOT=C:\local\boost >> %GITHUB_ENV%
- name: Store CCache dir (Linux)
if: ${{ matrix.platform == 'linux' }}
run: |
HOST_CCACHE_DIR="$(ccache -k cache_dir)"
mkdir -p $HOST_CCACHE_DIR
echo "HOST_CCACHE_DIR=${HOST_CCACHE_DIR}" >> $GITHUB_ENV
- name: Stub `setup.py` check (Linux/Mac)
if: ${{ matrix.platform != 'windows' }}
run: |
mkdir -p build/${{ matrix.preset }}/Python
touch build/${{ matrix.preset }}/Python/setup.py
- name: Stub `setup.py` check (Windows)
if: ${{ matrix.platform == 'windows' }}
shell: bash
run: |
mkdir -p build/${{ matrix.preset }}/Python
touch build/${{ matrix.preset }}/Python/setup.py
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat }}
CIBW_BEFORE_BUILD_LINUX: /bin/bash ./tools/prebuild_ql-risks.sh
CIBW_ENVIRONMENT: QLR_PYTHON_VERSION="${{ matrix.python }}"
CIBW_ENVIRONMENT_PASS_LINUX: QL_PREFIX HOST_CCACHE_DIR QLR_PYTHON_VERSION CIBUILDWHEEL=1
CIBW_BEFORE_BUILD_WINDOWS: tools\prebuild_ql-risks.bat
CIBW_BEFORE_BUILD_MACOS: bash ./tools/prebuild_ql-risks.sh
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}"
CIBW_BEFORE_TEST: pip install pandas numpy matplotlib jinja2
CIBW_TEST_COMMAND_WINDOWS: ${{ github.workspace }}/Python/run_tests.bat
CIBW_TEST_COMMAND_MACOS: bash ${{ github.workspace }}/Python/run_tests.sh
CIBW_TEST_COMMAND_LINUX: bash /host${{ github.workspace }}/Python/run_tests.sh
CIBW_BUILD_VERBOSITY: 2
with:
package-dir: build/${{ matrix.preset }}/Python
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.python }}-${{ matrix.buildplat }}
path: ./wheelhouse/*.whl
if-no-files-found: error
test-publish:
needs: build_wheels
if: >-
github.event_name == 'workflow_dispatch' ||
(github.repository == 'auto-differentiation/QuantLib-Risks' &&
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')))
environment:
name: testpypi
url: https://test.pypi.org/p/QuantLib-Risks
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/[email protected]
with:
verbose: true
repository-url: https://test.pypi.org/legacy/
skip-existing: true
publish:
runs-on: ubuntu-latest
needs: test-publish
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
environment:
name: pypi
url: https://pypi.org/p/QuantLib-Risks
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/[email protected]
name: Publish on PyPI
with:
verbose: true
skip-existing: true