-
Notifications
You must be signed in to change notification settings - Fork 27
219 lines (193 loc) · 6.78 KB
/
presubmit.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
name: "Presubmit: build and test wheels"
on:
pull_request:
branches:
- main
jobs:
mypy:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install nox
run: |
python -m ensurepip
python -m pip install nox
- name: Run mypy
env:
# workaround for https://github.com/pypa/setuptools/issues/3557
SETUPTOOLS_ENABLE_FEATURES: legacy-editable
run: |
nox -s mypy
build-wheels-linux:
name: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-20.04
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Build Wheels
uses: pypa/cibuildwheel@v2.20.0
env:
# For presubmit, just build / test the most common arch
CIBW_ARCHS: native
# For presubmit, skip build / test for pypy
CIBW_SKIP: pp37*
CIBW_ENVIRONMENT: >
CRC32C_PURE_PYTHON="0"
CRC32C_INSTALL_PREFIX="$(pwd)/usr"
CIBW_BUILD_VERBOSITY: 1
# Build the C library inside CIBW so that the manylinux image is
# used to link the share library; otherwise, our extension wouldn't
# be able to link with it.
CIBW_BEFORE_BUILD: >
python -m pip install --upgrade setuptools pip wheel &&
python -m pip install cmake &&
cmake -S google_crc32c -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCRC32C_BUILD_TESTS=no \
-DCRC32C_BUILD_BENCHMARKS=no \
-DBUILD_SHARED_LIBS=yes \
-DCMAKE_INSTALL_PREFIX:PATH=$(pwd)/usr &&
make -C build all install
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests/
- uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: wheelhouse/
build-wheels-macos:
name: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-13
# Wheels port forward
#- macos-11
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Get C library hash
id: get-c-lib-hash
run:
echo "::set-output name=hash::$(git -C google_crc32c log -n 1 --pretty=%H)"
- id: load-cache
name: Load cached C library
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/usr
key:
libcrc32c-${{ matrix.os }}-${{ steps.get-c-lib-hash.outputs.hash }}
- name: Build C Library
if: steps.load-cache.outputs.cache-hit != 'true'
run: >
python -m pip install --upgrade setuptools pip wheel &&
python -m pip install cmake &&
cmake -S google_crc32c -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCRC32C_BUILD_TESTS=no \
-DCRC32C_BUILD_BENCHMARKS=no \
-DBUILD_SHARED_LIBS=yes \
-DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}/usr \
-DCMAKE_INSTALL_NAME_DIR:PATH=${{ github.workspace }}/usr/lib &&
make -C build all install
- name: Build Wheels
uses: pypa/cibuildwheel@v2.20.0
env:
# For presubmit, just build / test the most common arch
CIBW_ARCHS: native
# For presubmit, skip build / test for pypy
CIBW_SKIP: pp37*
CIBW_ENVIRONMENT: >
CRC32C_PURE_PYTHON="0"
CRC32C_INSTALL_PREFIX="$(pwd)/usr"
CIBW_BUILD_VERBOSITY: 1
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests/
- uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: wheelhouse/
build-wheels-windows:
name: ${{ matrix.os }} ( ${{ matrix.platform }} )
strategy:
matrix:
os:
- windows-2019
platform:
# For presubmit, just build / test the most common platform
- x64
#- Win32
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Get C library hash
id: get-c-lib-hash
run:
echo "::set-output name=hash::$(git -C google_crc32c log -n 1 --pretty=%H)"
- id: load-cache
name: Load cached C library
uses: actions/cache@v3
with:
path: ${{ github.workspace }}\usr
key:
libcrc32c-${{ matrix.os }}-${{ matrix.platform }}-${{ steps.get-c-lib-hash.outputs.hash }}
- name: Build C Library
if: steps.load-cache.outputs.cache-hit != 'true'
run: |
echo "::group::Install cmake"
python -m pip install --upgrade setuptools pip wheel
python -m pip install cmake
echo "::endgroup::"
echo "::group::Run cmake to initialze build tree"
cmake -S google_crc32c -B build -G "Visual Studio 16 2019" -A ${{ matrix.platform }} -DCRC32C_BUILD_BENCHMARKS=no -DCRC32C_BUILD_TESTS=no -DBUILD_SHARED_LIBS=no -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=yes -DCRC32C_USE_GLOG=0
echo "::endgroup::"
echo "::group::Run cmake to build library"
cmake --build build --verbose --config Release
echo "::endgroup::"
echo "::group::Run cmake to install library"
cmake --install build --verbose --config Release --prefix=${{ github.workspace }}\usr\
echo "::endgroup::"
# Passing through ${{ github.workspace }} to CIBW_ENVIRONMENT mangles
# backslashes: compute a variant which uses only forward-slashses.
- id: crc32c-install-prefix
name: Dead-reckon a CIBW-compatible install prefix
shell: bash
run: |
python -c "import os; workspace = '/'.join(os.getenv('GITHUB_WORKSPACE').split(os.sep)); pfx = f'{workspace}/usr'; print(f'::set-output name=prefix::{pfx}')"
- id: platform-arch
name: Map platform -> wheel arch
shell: bash
run: |
if [[ "${{ matrix.platform }}" == "Win32" ]]; then
echo "::set-output name=arch::x86"
else
echo "::set-output name=arch::AMD64"
fi
- name: Build Wheels
uses: pypa/cibuildwheel@v2.20.0
env:
CIBW_ARCHS_WINDOWS: ${{ steps.platform-arch.outputs.arch }}
# For presubmit, skip build / test for pypy
CIBW_SKIP: pp37*
CIBW_ENVIRONMENT: CRC32C_PURE_PYTHON="0" CRC32C_INSTALL_PREFIX="${{ steps.crc32c-install-prefix.outputs.prefix }}"
CIBW_BUILD_VERBOSITY: 3
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests
- uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: wheelhouse/