forked from cvxpy/cvxpy
-
Notifications
You must be signed in to change notification settings - Fork 0
226 lines (193 loc) · 7.57 KB
/
build.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
name: build
on:
pull_request:
push:
branches:
- master
- 'release/**'
tags:
- '*'
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
# Only cancels-in-progress on PRs (head_ref only defined in PR, fallback run_id always unique)
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
actions-linting:
uses: cvxpy/actions/.github/workflows/linting.yml@main
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, macos-12, windows-2022 ]
python-version: [ 3.9, "3.10", "3.11", "3.12" ]
env:
RUNNER_OS: ${{ matrix.os }}
PYTHON_VERSION: ${{ matrix.python-version }}
SINGLE_ACTION_CONFIG: "${{ matrix.single_action_config == 'True' && 'True' || 'False' }}"
USE_OPENMP: "${{ matrix.openmp == 'True' && 'True' || 'False' }}"
MOSEK_CI_BASE64: ${{ secrets.MOSEK_CI_BASE64 }}
steps:
- uses: actions/checkout@v4
- name: Set Additional Envs
run: |
echo "PYTHON_SUBVERSION=$(echo $PYTHON_VERSION | cut -c 3-)" >> $GITHUB_ENV
echo $MOSEK_CI_BASE64 | base64 -d > mosek.lic
echo "MOSEKLM_LICENSE_FILE=$( [[ $RUNNER_OS == 'macOS' ]] && echo $(pwd)/mosek.lic || echo $(realpath mosek.lic) )" >> $GITHUB_ENV
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge,anaconda
- name: Install
run: |
source continuous_integration/install_dependencies.sh
- name: Test
run: |
source continuous_integration/test_script.sh
- name: Upload coverage file
uses: actions/upload-artifact@v4
if: ${{env.SINGLE_ACTION_CONFIG == 'True'}}
with:
name: coverage
path: coverage.xml
build_wheels:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, macos-12, windows-2022 ]
python-version: [ 3.9, "3.10", "3.11", "3.12" ]
env:
RUNNER_OS: ${{ matrix.os }}
PYTHON_VERSION: ${{ matrix.python-version }}
SINGLE_ACTION_CONFIG: "${{ matrix.single_action_config == 'True' }}"
PYPI_SERVER: ${{ secrets.PYPI_SERVER }}
PYPI_USER: ${{ secrets.PYPI_USER }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set Additional Envs
shell: bash
run: |
echo "PYTHON_SUBVERSION=$(echo $PYTHON_VERSION | cut -c 3-)" >> $GITHUB_ENV
echo "DEPLOY=$( [[ $GITHUB_EVENT_NAME == 'push' && $GITHUB_REF == 'refs/tags'* ]] && echo 'True' || echo 'False' )" >> $GITHUB_ENV
- name: Set up QEMU # For aarch64, see https://cibuildwheel.readthedocs.io/en/stable/faq/#emulation
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Build wheels
if: ${{github.event_name == 'push' && env.USE_OPENMP != 'True'}}
env:
CIBW_BUILD: "cp3${{env.PYTHON_SUBVERSION}}-*"
CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux*"
CIBW_ARCHS_MACOS: x86_64 universal2
CIBW_ARCHS_LINUX: auto aarch64
uses: pypa/cibuildwheel@v2.19.1
- name: Build source
if: ${{github.event_name == 'push' && env.SINGLE_ACTION_CONFIG == 'True'}}
run: |
pip install build
python -m build --sdist -o wheelhouse
- name: Check wheels
if: ${{github.event_name == 'push' && env.USE_OPENMP != 'True'}}
shell: bash
run: |
python -m pip install --upgrade twine
twine check wheelhouse/*
- name: Release to pypi
if: ${{env.DEPLOY == 'True' && env.USE_OPENMP != 'True'}}
shell: bash
run: |
twine upload --skip-existing --repository-url $PYPI_SERVER wheelhouse/* -u $PYPI_USER -p $PYPI_PASSWORD
- name: Upload artifacts to github
if: ${{github.event_name == 'push' && env.USE_OPENMP != 'True'}}
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.python-version }}
path: ./wheelhouse
build_cvxpy-base:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, macos-12, windows-2022 ]
python-version: [ 3.9, "3.10", "3.11", "3.12" ]
env:
PYTHON_VERSION: ${{ matrix.python-version }}
SINGLE_ACTION_CONFIG: "${{ matrix.single_action_config == 'True' }}"
PIP_INSTALL: "${{ matrix.pip_install == 'True' }}"
PYPI_SERVER: ${{ secrets.PYPI_SERVER }}
PYPI_USER: ${{ secrets.PYPI_USER }}
PYPI_BASE_PASSWORD: ${{ secrets.PYPI_BASE_PASSWORD }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set Additional Envs
shell: bash
run: |
echo "PYTHON_SUBVERSION=$(echo $PYTHON_VERSION | cut -c 3-)" >> $GITHUB_ENV
echo "DEPLOY=$( [[ $GITHUB_EVENT_NAME == 'push' && $GITHUB_REF == 'refs/tags'* ]] && echo 'True' || echo 'False' )" >> $GITHUB_ENV
- name: Adapt pyproject.toml
shell: bash
run: |
# Mac has a different syntax for sed -i, this works across oses
sed -i.bak -e 's/name = "cvxpy"/name = "cvxpy-base"/g' pyproject.toml
sed -i.bak '/clarabel >= /d' pyproject.toml
sed -i.bak '/osqp >= /d' pyproject.toml
sed -i.bak '/ecos >= /d' pyproject.toml
sed -i.bak '/scs >= /d' pyproject.toml
sed -i.bak -e 's/name="cvxpy",/name="cvxpy-base",/g' setup.py
rm -rf pyproject.toml.bak setup.py.bak
- name: Verify that we can build by pip-install on each OS.
if: ${{env.PIP_INSTALL == 'True'}}
run: |
pip install . pytest cplex
pytest cvxpy/tests/test_conic_solvers.py -k 'TestCPLEX'
- name: Set up QEMU # For aarch64, see https://cibuildwheel.readthedocs.io/en/stable/faq/#emulation
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Build wheels
if: ${{github.event_name == 'push'}}
env:
CIBW_BUILD: "cp3${{env.PYTHON_SUBVERSION}}-*"
CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux*"
CIBW_ARCHS_MACOS: x86_64 universal2
CIBW_ARCHS_LINUX: auto aarch64
uses: pypa/cibuildwheel@v2.19.1
- name: Build source
if: ${{github.event_name == 'push' && env.SINGLE_ACTION_CONFIG == 'True'}}
run: |
pip install build
python -m build --sdist -o wheelhouse
- name: Check wheels
shell: bash
if: ${{github.event_name == 'push'}}
run: |
python -m pip install --upgrade twine
twine check wheelhouse/*
- name: Release to pypi
shell: bash
if: ${{env.DEPLOY == 'True'}}
run: |
twine upload --skip-existing --repository-url $PYPI_SERVER wheelhouse/* -u $PYPI_USER -p $PYPI_BASE_PASSWORD
- name: Upload artifacts to github
if: ${{github.event_name == 'push'}}
uses: actions/upload-artifact@v4
with:
name: wheels-base-${{ matrix.os }}-${{ matrix.python-version }}
path: ./wheelhouse