-
-
Notifications
You must be signed in to change notification settings - Fork 88
242 lines (203 loc) · 7.56 KB
/
ci.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
#
# GitHub actions for building the distribution and wheels of the sgp4 package
# linting and testing the source.
#
# Contributed by @mworion
#
# Strategy:
# The action is called with each commit, pull request master (and) release
# branch. If commit is to release branch, the PyPI upload will follow
# successful tests automatically.
#
# Run lint on python source, build step by step the python distro and
# run all package tests for all OS and python versions
#
# If this job succeeds, build step by step all wheels for all OS and python
# versions and run the tests in accelerated mode.
#
# If the first two jobs succeed, upload the distro and wheels to PyPI
#
name: ci
on:
# the trigger event for running the action is either a push on master or
# release branch
push:
branches:
- master
- release
- ci
# or a pull request to master branch
pull_request:
branches:
- master
jobs:
# This action is split into three jobs:
# - Building the distribution linting and testing without acceleration
# - Building the wheels for the distribution and testing with acceleration
# - Uploading the artifacts to PyPI package if branch is release
# The uploading job needs all tests to be finished without error.
build_test_dist:
# Build the distribution in a matrix. Jobs are done in parallel.
# The formal distro which is uploaded to PyPI will be built on
# ubuntu-latest for python 3.12.
# As in dist build no compilation takes place, we run all tests
# in not accelerated mode.
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 15
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: checkout
uses: actions/checkout@v4
- name: Setup_Python_${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# The build test needs numpy and pyflakes. Adding twine enables for
# testing and checking the metadata. Adding wheels for package
# installation before running the tests
- name: install_deps
run: pip install numpy pyflakes setuptools twine
- name: build_sdist
run: python setup.py sdist
- name: check_metadata
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
run: twine check dist/*
- name: upload_sdist
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*.tar.gz
- name: copy_file
run: mv dist/sgp4*.* dist/sgp4.tar.gz
- name: install_dist
run: |
pip install dist/sgp4.tar.gz
python -c "from sgp4.api import accelerated; print(accelerated)"
- name: run_tests
run: python -m sgp4.tests
build_test_wheels:
# Building wheels for different OS, python and platform versions. This is
# done with the help of 'cibuildwheel' package. It will run on all
# necessary supported OS (native or emulated), each running cibuildwheel on
# python 3.12.
# Reference: https://cibuildwheel.readthedocs.io/en/stable/
# OS: Windows, Linux, macOS (x64 and M1), ARM64
# Python: versions 3.7 - 3.12 in testing
# Python: versions 3.7 - 3.12 in build wheels
# As all build wheels are installed after build, the tests run in
# accelerated mode only.
runs-on: ${{ matrix.os }}
needs: [build_test_dist]
strategy:
max-parallel: 4
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ['3.12']
include:
- os: ubuntu-20.04
cibw_archs: "aarch64"
python-version: '3.12'
steps:
# Using QEMU for aarch64 emulation
- name: setup QEMU
if: matrix.cibw_archs == 'aarch64'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: checkout
uses: actions/checkout@v4
- name: Setup_Python_${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: install_deps
run: python -m pip install cibuildwheel
# unfortunately actions do not have an else statement
# and I have to split builds due to numpy pinning
- name: build_test_aarch64_until_p39
if: matrix.cibw_archs == 'aarch64'
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_LINUX: "aarch64"
CIBW_SKIP: '*-musllinux_*'
CIBW_BUILD: "cp37-* cp38-* cp39-*"
CIBW_BUILD_VERBOSITY: 0
CIBW_TEST_REQUIRES: numpy==1.21.1
CIBW_TEST_COMMAND: python -m sgp4.tests
- name: build_test_normal_until_p39
if: matrix.cibw_archs != 'aarch64'
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CIBW_ARCHS_LINUX: "auto"
CIBW_SKIP: '*-musllinux_*'
CIBW_BUILD: "cp37-* cp38-* cp39-*"
CIBW_BUILD_VERBOSITY: 0
CIBW_TEST_REQUIRES: numpy==1.21.1
CIBW_TEST_COMMAND: python -m sgp4.tests
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"
- name: build_test_aarch64_from_p310
if: matrix.cibw_archs == 'aarch64'
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_LINUX: "aarch64"
CIBW_SKIP: '*-musllinux_*'
CIBW_BUILD: "cp310-* cp311-* cp312-*"
CIBW_BUILD_VERBOSITY: 0
CIBW_TEST_REQUIRES: numpy==1.26.1
CIBW_TEST_COMMAND: python -m sgp4.tests
- name: build_test_normal_from_p310
if: matrix.cibw_archs != 'aarch64'
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CIBW_ARCHS_LINUX: "x86_64"
CIBW_SKIP: '*-musllinux_*'
CIBW_BUILD: "cp310-* cp311-* cp312-*"
CIBW_BUILD_VERBOSITY: 0
CIBW_TEST_REQUIRES: numpy==1.26.1
CIBW_TEST_COMMAND: python -m sgp4.tests
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"
- name: list_wheels
run: ls wheelhouse
- name: upload_wheels
uses: actions/upload-artifact@v4
with:
name: wheelhouse-${{ matrix.os }}
path: wheelhouse
upload_to_pypi:
# Finally, we collect all out data from the artifacts and put them back to
# dist directory for an upload. The final step waits for the other jobs to
# be finished and starts only if the trigger event of the action was a push
# on release branch
runs-on: [ubuntu-latest]
needs: [build_test_dist, build_test_wheels]
if: |
github.event_name == 'push' &&
github.ref == 'refs/heads/release'
steps:
- uses: actions/setup-python@v4
# download dist files
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
# download wheels
- uses: actions/download-artifact@v4
with:
name: wheelhouse
path: dist
# For the activation of the PyPI index, please add a secret token from
# PyPI to the GitHub repo, give it a name and replace in the password
# reference the <pypi_password> with the name of the secret's name you have
# chosen for the PyPI token.
- name: upload_to_pypi
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.pypi_password }}
skip_existing: true