-
Notifications
You must be signed in to change notification settings - Fork 37
618 lines (531 loc) · 19.3 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
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
name: Build Status
on:
push:
branches:
- main
tags:
- v*
paths-ignore:
- LICENSE
- NOTICE
- README.md
pull_request:
branches:
- main
paths-ignore:
- LICENSE
- NOTICE
- README.md
workflow_dispatch:
inputs:
ci-full:
description: "Run Full CI"
required: false
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
checks: write
pull-requests: write
jobs:
####################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~/##########\~~~~~~~~~~~~#
#~~~~~~~~~|#|~~~~~~~|#|~~~~~~~~~~~~#
#~~~~~~~~~|#|~~~~~~~|#|~~~~~~~~~~~~#
#~~~~~~~~~|#|~~~~~~~|#|~~~~~~~~~~~~#
#~~~~~~~~~|#|~~~~~~~|#|~~~~~~~~~~~~#
#~~~~~~~~~|#|~~~~~~~|#|~~~~~~~~~~~~#
#~~~~~~~~~\##########/~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Stage One - Initialize the build #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# This is so we can inspect the latest commit message from
# both push and pull_request events (there is no
# github.event.head_commit.message otherwise on pull
# requests)
initialize:
runs-on: ubuntu-22.04
outputs:
COMMIT_MESSAGE: ${{ steps.setup.outputs.COMMIT_MSG }}
FULL_RUN: ${{ steps.setuppush.outputs.FULL_RUN || steps.setuppr.outputs.FULL_RUN || steps.setupmanual.outputs.FULL_RUN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# for pull_request so we can do HEAD^2
fetch-depth: 2
- name: Get Commit Message
run: echo "COMMIT_MSG=$(git log -1 --pretty=%B HEAD | tr '\n' ' ')" >> $GITHUB_ENV
if: ${{ github.event_name == 'push' }}
- name: Get Commit Message
run: echo "COMMIT_MSG=$(git log -1 --pretty=%B HEAD^2 | tr '\n' ' ')" >> $GITHUB_ENV
if: ${{ github.event_name == 'pull_request' }}
- name: Display and Setup Build Args (Push)
id: setuppush
run: |
echo "Commit Message: $COMMIT_MSG"
echo "Full Run: $FULL_RUN"
echo "COMMIT_MSG=$COMMIT_MSG" >> $GITHUB_OUTPUT
echo "FULL_RUN=$FULL_RUN" >> $GITHUB_OUTPUT
env:
FULL_RUN: ${{ startsWith(github.ref_name, 'v') || contains(github.event.head_commit.message, '[ci-full]') }}
if: ${{ github.event_name == 'push' }}
- name: Display and Setup Build Args (PR)
id: setuppr
run: |
echo "Commit Message: $COMMIT_MSG"
echo "Full Run: $FULL_RUN"
echo "COMMIT_MSG=$COMMIT_MSG" >> $GITHUB_OUTPUT
echo "FULL_RUN=$FULL_RUN" >> $GITHUB_OUTPUT
env:
FULL_RUN: ${{ contains(github.event.pull_request.title, '[ci-full]') || contains(env.COMMIT_MSG, '[ci-full]') }}
if: ${{ github.event_name == 'pull_request' }}
- name: Display and Setup Build Args (Manual)
id: setupmanual
run: |
echo "Commit Message: $COMMIT_MSG"
echo "Full Run: $FULL_RUN"
echo "COMMIT_MSG=$COMMIT_MSG" >> $GITHUB_OUTPUT
echo "FULL_RUN=$FULL_RUN" >> $GITHUB_OUTPUT
env:
FULL_RUN: ${{ github.event.inputs.ci-full }}
if: ${{ github.event_name == 'workflow_dispatch' }}
###################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~~/#######|~~~~~~~~~~~~~#
#~~~~~~~~~~/########|~~~~~~~~~~~~~#
#~~~~~~~~~/###/~|###|~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~|###|~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~|###|~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~|###|~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~|###|~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Stage One - Lint Python / C++ #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
lint:
needs:
- initialize
strategy:
matrix:
os:
- ubuntu-22.04
python-version:
- 3.9
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: ./.github/actions/setup-python
with:
version: '${{ matrix.python-version }}'
- name: Install python dependencies
run: make requirements
- name: Python Lint Steps (Linux)
run: make lint
############################
#~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~/########\~~~~~~~#
#~~~~~~~|###|~~~\###\~~~~~~#
#~~~~~~~~~~~~~~/###/~~~~~~~#
#~~~~~~~~~~~~/###/~~~~~~~~~#
#~~~~~~~~~~/###/~~~~~~~~~~~#
#~~~~~~~~/###/~~~~~~~~~~~~~#
#~~~~~~|#############|~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Stage Two - Build Python #
#~~~~~~~~~~~~~~~~~~~~~~~~~~#
build:
needs:
- initialize
strategy:
matrix:
os:
- ubuntu-22.04 # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
- macos-12 # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
- macos-14 # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
# - windows-2022 # https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
cibuildwheel:
- "cp38"
- "cp39"
- "cp310"
- "cp311"
is-full-run:
- ${{ needs.initialize.outputs.FULL_RUN == 'true' }}
exclude:
############################
# Things to always exclude #
############################
# Skip when cibuildwheel != python version
# to avoid duplication
- python-version: "3.8"
cibuildwheel: "cp39"
- python-version: "3.8"
cibuildwheel: "cp310"
- python-version: "3.8"
cibuildwheel: "cp311"
- python-version: "3.9"
cibuildwheel: "cp38"
- python-version: "3.9"
cibuildwheel: "cp310"
- python-version: "3.9"
cibuildwheel: "cp311"
- python-version: "3.10"
cibuildwheel: "cp38"
- python-version: "3.10"
cibuildwheel: "cp39"
- python-version: "3.10"
cibuildwheel: "cp311"
- python-version: "3.11"
cibuildwheel: "cp38"
- python-version: "3.11"
cibuildwheel: "cp39"
- python-version: "3.11"
cibuildwheel: "cp310"
##############################################
# Things to exclude if not a full matrix run #
##############################################
# mac arm builds support py3.10+
- os: macos-14
python-version: "3.8"
- os: macos-14
python-version: "3.9"
# minimize CI resource usage
- is-full-run: false
os: ubuntu-22.04
python-version: "3.8"
# windows is slow, so dont build unless its a full run
# - is-full-run: false
# os: windows-2022
# avoid unnecessary use of mac resources
- is-full-run: false
os: macos-12
- is-full-run: false
os: macos-14
python-version: "3.8"
- is-full-run: false
os: macos-14
python-version: "3.9"
- is-full-run: false
os: macos-14
python-version: "3.10"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: ./.github/actions/setup-python
with:
version: '${{ matrix.python-version }}'
- name: Set up Caches
uses: ./.github/actions/setup-caches
with:
cibuildwheel: '${{ matrix.cibuildwheel }}'
- name: Set up dependencies
uses: ./.github/actions/setup-dependencies
with:
cibuildwheel: '${{ matrix.cibuildwheel }}'
if: ${{ runner.os == 'macOS' }}
########
# Linux
- name: Python Wheel Steps (Linux - cibuildwheel)
run: make dist-py-cibw
env:
CIBW_BUILD: "${{ matrix.cibuildwheel }}-manylinux*"
CIBW_ENVIRONMENT_LINUX: CSP_MANYLINUX="ON" CCACHE_DIR="/host/home/runner/work/csp/csp/.ccache" VCPKG_DEFAULT_BINARY_CACHE="/host${{ env.VCPKG_DEFAULT_BINARY_CACHE }}" VCPKG_DOWNLOADS="/host${{ env.VCPKG_DOWNLOADS }}"
CIBW_BUILD_VERBOSITY: 3
if: ${{ runner.os == 'Linux' }}
########
# Macos
- name: Python Build Steps (Macos x86)
run: make dist-py-cibw
env:
CIBW_BUILD: "${{ matrix.cibuildwheel }}-macos*"
CIBW_ENVIRONMENT_MACOS: CC="/usr/local/bin/gcc-13" CXX="/usr/local/bin/g++-13" CCACHE_DIR="/Users/runner/work/csp/csp/.ccache" VCPKG_DEFAULT_BINARY_CACHE="${{ env.VCPKG_DEFAULT_BINARY_CACHE }}" VCPKG_DOWNLOADS="${{ env.VCPKG_DOWNLOADS }}"
CIBW_ARCHS_MACOS: x86_64
CIBW_BUILD_VERBOSITY: 3
if: ${{ matrix.os == 'macos-12' }}
- name: Python Build Steps (Macos arm)
run: make dist-py-cibw
env:
CIBW_BUILD: "${{ matrix.cibuildwheel }}-macos*"
CIBW_ENVIRONMENT_MACOS: PATH="/opt/homebrew/opt/bison/bin/:$PATH" CC="/opt/homebrew/bin/gcc-13" CXX="/opt/homebrew/bin/g++-13" LDFLAGS="-Wl,-ld_classic" CCACHE_DIR="/Users/runner/work/csp/csp/.ccache" VCPKG_DEFAULT_BINARY_CACHE="${{ env.VCPKG_DEFAULT_BINARY_CACHE }}" VCPKG_DOWNLOADS="${{ env.VCPKG_DOWNLOADS }}"
CIBW_ARCHS_MACOS: arm64
CIBW_BUILD_VERBOSITY: 3
if: ${{ matrix.os == 'macos-14' }}
##########
# Windows
- name: Python Build Steps (Windows vc14.3)
run: make dist-py-cibw
env:
CIBW_BUILD: "${{ matrix.cibuildwheel }}-win_amd64"
CMAKE_GENERATOR: Visual Studio 17 2022
CIBW_ENVIRONMENT_WINDOWS: TODO="todo"
if: ${{ matrix.os == 'windows-2022' }}
# Upload artifacts
- name: Upload Wheel
uses: actions/upload-artifact@v4
with:
name: csp-dist-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}
path: wheelhouse/*.whl
#############################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~/########\~~~~~~~#
#~~~~~~~~~|##|~~~~|##|~~~~~~#
#~~~~~~~~~~~~~~~~~|##|~~~~~~#
#~~~~~~~~~~~~~|######|~~~~~~#
#~~~~~~~~~~~~~~~~~|##|~~~~~~#
#~~~~~~~~~|##|~~~~|##|~~~~~~#
#~~~~~~~~~\#########/~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Stage Three - Build SDist #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~#
build_sdist:
needs:
- initialize
strategy:
matrix:
os:
- ubuntu-22.04
python-version:
- 3.9
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: ./.github/actions/setup-python
with:
version: '${{ matrix.python-version }}'
- name: Install python dependencies
run: make requirements
# Build SDist
- name: Python SDist Steps
run: make dist-py-sdist
# Upload artifacts
- name: Upload SDist
uses: actions/upload-artifact@v4
with:
name: csp-sdist
path: dist/*.tar.gz
#############################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~|##|~~~~|##|~~~~~~~~#
#~~~~~~~|##|~~~~|##|~~~~~~~~#
#~~~~~~~|##|~~~~|##|~~~~~~~~#
#~~~~~~~|##########|~~~~~~~~#
#~~~~~~~~~~~~~~~|##|~~~~~~~~#
#~~~~~~~~~~~~~~~|##|~~~~~~~~#
#~~~~~~~~~~~~~~~|##|~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Stage Four - Test Python #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~#
test:
needs:
- initialize
- build
strategy:
matrix:
os:
- ubuntu-22.04
- macos-12
- macos-14
# - windows-2022
python-version:
- 3.8
- 3.9
- "3.10"
- 3.11
is-full-run:
- ${{ needs.initialize.outputs.FULL_RUN == 'true' }}
exclude:
##############################################
# Things to exclude if not a full matrix run #
##############################################
# mac arm builds support py3.10+
- os: macos-14
python-version: "3.8"
- os: macos-14
python-version: "3.9"
# Exclude windows builds
# - is-full-run: false
# os: windows-2022
# Exclude macOS builds for now
- is-full-run: false
os: macos-12
- is-full-run: false
os: macos-14
# Exclude Python 3.8, 3.10, 3.11 builds
- is-full-run: false
python-version: 3.8
- is-full-run: false
python-version: 3.9
- is-full-run: false
python-version: "3.10"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: ./.github/actions/setup-python
with:
version: '${{ matrix.python-version }}'
- name: Install python dependencies
run: make requirements
- name: Install test dependencies (Linux)
shell: bash
run: sudo apt-get install graphviz
if: ${{ runner.os == 'Linux' }}
- name: Install test dependencies (Mac)
shell: bash
run: brew install graphviz
if: ${{ runner.os == 'macOS' }}
# Download artifact
- name: Download wheel
uses: actions/download-artifact@v4
with:
name: csp-dist-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}
- name: Install wheel (Linux)
run: python -m pip install -U *manylinux2014*.whl --target .
if: ${{ runner.os == 'Linux' }}
# Note, on mac we must install the x86 wheel, the arm64 wheel
# would need an arm machine to test
- name: Install wheel (OSX)
run: python -m pip install -U *x86*.whl --target .
if: ${{ runner.os == 'macOS' && matrix.python-version != '3.11' }}
- name: Install wheel (OSX 3.11+)
run: python -m pip install -U *universal*.whl --target .
if: ${{ runner.os == 'macOS' && matrix.python-version == '3.11' }}
- name: Install wheel (windows)
run: python -m pip install -U (Get-ChildItem .\*.whl | Select-Object -Expand FullName) --target .
if: ${{ runner.os == 'Windows' }}
# Run tests
- name: Python Test Steps
run: make test
########################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~|##########|~~~~~~~~~~~~#
#~~~~~~~~~~~~~~|##|~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~|##|~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~|##########|~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~|##|~~~~~~~~~~~~#
#~~~~~~~~~~~~~~|##|~~~~|##|~~~~~~~~~~~~#
#~~~~~~~~~~~~~~|##########|~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Stage Four - Build / test the SDist #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# test_sdist:
# needs:
# - initialize
# - build_sdist
# strategy:
# matrix:
# os:
# - ubuntu-22.04
# python-version:
# - 3.9
# runs-on: ${{ matrix.os }}
# # if: ${{ needs.initialize.outputs.FULL_RUN == 'true' }}
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# submodules: recursive
# - name: Set up Python ${{ matrix.python-version }}
# uses: ./.github/actions/setup-python
# with:
# version: '${{ matrix.python-version }}'
# - name: Set up Caches
# uses: ./.github/actions/setup-caches
# with:
# cibuildwheel: 'cp39'
# # Python
# - name: Install python dependencies
# run: make requirements
# # Download sdist
# - uses: actions/download-artifact@v4
# with:
# name: csp-sdist
# path: dist/
# # Install sdist
# - name: Install sdist
# run: python -m pip install -U dist/csp*.tar.gz --target .
# env:
# CCACHE_DIR: /host/home/runner/work/csp/csp/.ccache
# VCPKG_DEFAULT_BINARY_CACHE: /host/home/runner/vcpkg_cache
# # Test sdist
# - name: Run tests against from-scratch sdist build
# run: make test
##########################################################################################################################
#################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~|##########|~~~~~~~~~~#
#~~~~~~~~~|##|~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~|##|~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~|##########|~~~~~~~~~~#
#~~~~~~~~~|##|~~~~|##|~~~~~~~~~~#
#~~~~~~~~~|##|~~~~|##|~~~~~~~~~~#
#~~~~~~~~~|##########|~~~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Test Dependencies/Regressions #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
test_dependencies:
needs:
- initialize
- build
strategy:
matrix:
os:
- ubuntu-20.04
python-version:
- 3.9
package:
- "sqlalchemy>=2"
- "sqlalchemy<2"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: ./.github/actions/setup-python
with:
version: '${{ matrix.python-version }}'
- name: Install python dependencies
run: make requirements
- name: Install test dependencies
shell: bash
run: sudo apt-get install graphviz
# Download artifact
- name: Download wheel
uses: actions/download-artifact@v4
with:
name: csp-dist-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}
- name: Install wheel
run: python -m pip install -U *manylinux2014*.whl --target .
- name: Install package - ${{ matrix.package }}
run: python -m pip install -U "${{ matrix.package }}"
# Run tests
- name: Python Test Steps
run: make test TEST_ARGS="-k TestDBReader"
if: ${{ contains( 'sqlalchemy', matrix.package )}}