-
Notifications
You must be signed in to change notification settings - Fork 49
841 lines (713 loc) · 33.9 KB
/
ci.yml
File metadata and controls
841 lines (713 loc) · 33.9 KB
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
name: "CI"
on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
jobs:
Dependencies:
runs-on: ubuntu-latest
name: "Resolve repo dependencies"
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Resolve repo dependencies
id: resolve-dependencies
# writes to GITHUB_OUTPUT via os.system() shell
run: |
python3 $GITHUB_WORKSPACE/.github/scripts/resolve_dependent_repos.py \
--project CSXCAD
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_FORK_OWNER: ${{ github.event.pull_request.head.repo.owner.login }}
# map a step output to a job output
outputs:
fparser_repo: ${{ steps.resolve-dependencies.outputs.fparser_repo }}
fparser_branch: ${{ steps.resolve-dependencies.outputs.fparser_branch }}
# format a human-friendly string in the following format:
#
# * Checkout XXXX.git (PR: https://example.com/XXXX)
#
# OR:
#
# * Checkout XXXX.git (branch: XXXX)
fparser_checkout_title: >
Checkout ${{ steps.resolve-dependencies.outputs.fparser_repo }}.git
(${{ steps.resolve-dependencies.outputs.fparser_pr_url != 'None' &&
format('PR: {0}', steps.resolve-dependencies.outputs.fparser_pr_url) ||
format('branch: {0}', steps.resolve-dependencies.outputs.fparser_branch) }})
Linux:
runs-on: ubuntu-latest
needs: Dependencies
defaults:
run:
shell: bash
strategy:
# Use "false" means a single failed build won't terminate other combinations
# in the matrix. This wastes CPU time, but is an important debugging tool to
# prevent a single broken platform from stopping the whole matrix.
fail-fast: false
matrix:
os:
# name: OS name (only a name for humans to read).
# libc: userland libc, "GNU" or "musl"
# (only a name for humans to read)
# ancient: true or false.
# true: incompatible with GitHub's actions/checkout due to
# node.js compatibility problem. Manual git checkout
# required.
# false: use standard GitHub's actions/checkout.
# docker-image: string, image on DockerHub to use
- name: "CentOS 7"
libc: "GNU"
ancient: true
docker-image: "centos:7"
- name: "Ubuntu 14.04"
libc: "GNU"
ancient: true
docker-image: "ubuntu:14.04"
- name: "Debian oldoldstable"
libc: "GNU"
ancient: false
docker-image: "debian:oldoldstable"
- name: "Debian oldstable"
libc: "GNU"
ancient: false
docker-image: "debian:oldstable"
- name: "Debian"
libc: "GNU"
ancient: false
docker-image: "debian:latest"
- name: "Ubuntu"
libc: "GNU"
ancient: false
docker-image: "ubuntu:latest"
- name: "Fedora"
libc: "GNU"
ancient: false
docker-image: "fedora:latest"
- name: "AlmaLinux 8"
libc: "GNU"
ancient: false
docker-image: "almalinux:8"
- name: "AlmaLinux 9"
libc: "GNU"
ancient: false
docker-image: "almalinux:9"
# Waiting for upstream packages:
# https://bugzilla.redhat.com/show_bug.cgi?id=2374130
# https://bugzilla.redhat.com/show_bug.cgi?id=2419727
#
#- name: "AlmaLinux Latest"
# libc: "GNU"
# ancient: false
# docker-image: "almalinux:latest"
- name: "Alpine"
libc: "musl"
ancient: false
docker-image: "alpine:latest"
container:
image: ${{ matrix.os.docker-image }}
# allow mount/netns
options: "--cap-add CAP_SYS_ADMIN --cap-add NET_ADMIN --security-opt apparmor=unconfined"
name: "${{ matrix.os.libc }}/Linux (${{ matrix.os.name }})"
env:
# Wno-error is needed because any third-party dependencies
# like compiler version changes or even Python libraries
# installed by pip can block the pipeline, this is not what
# we want.
CXXFLAGS: "-Wall -Wextra -Wno-error"
steps:
- name: Check for dockerenv file
# bash is not installed on Alpine at this point
shell: sh
run: (ls /.dockerenv && echo Found dockerenv) || exit 1
# When checking out repos, I recommend running actions/checkout
# as soon as possible before anything else, and in the reverse
# order, from the project repo to its dependencies. This reduces
# race conditions due to force pushes (they are harmless but
# annoying).
- if: ${{ ! matrix.os.ancient }}
name: Checkout CSXCAD.git
uses: actions/checkout@v4
with:
path: CSXCAD
# checkout must be deep, not shallow.
# We need tags for "git describe", otherwise build fails.
fetch-depth: 0
- if: ${{ ! matrix.os.ancient }}
name: ${{ needs.Dependencies.outputs.fparser_checkout_title }}
uses: actions/checkout@v4
with:
repository: "${{ needs.Dependencies.outputs.fparser_repo }}"
ref: "${{ needs.Dependencies.outputs.fparser_branch }}"
path: fparser
- name: Install dependencies
shell: sh
run: |
if grep -q "ID=fedora" /etc/os-release; then
dnf install -y git
dnf install -y gcc gcc-c++ cmake git tinyxml-devel vtk-devel hdf5-devel \
CGAL-devel python3-pip \
python3-setuptools python3-setuptools_scm \
python3-Cython python3-numpy python3-matplotlib
# only for CI/CD test builds without networks.
dnf install -y iproute
elif grep -q 'ID="almalinux"' /etc/os-release; then
dnf install -y epel-release
dnf config-manager --set-enabled powertools || dnf config-manager --set-enabled crb
dnf install -y git
dnf install -y gcc gcc-c++ cmake git tinyxml-devel vtk-devel hdf5-devel \
CGAL-devel python3-pip \
python3-setuptools python3-wheel python3-setuptools_scm \
python3-Cython python3-numpy python3-matplotlib
# only for CI/CD test builds without networks.
dnf install -y iproute
elif grep -q "ID=debian" /etc/os-release || grep -q "ID=ubuntu" /etc/os-release; then
# retry failed downloads 3 times
echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries
apt-get update
apt-get install -y build-essential git \
libcgal-dev libhdf5-dev libtinyxml-dev \
python3-pip \
python3-setuptools python3-numpy
# VTK9 or VTK7, at least one must succeed (depending on Debian version)
# VTK9, VTK7, or VTK6, at least one must succeed (depending on Debian version)
apt-get install -y libvtk9-dev || \
apt-get install -y libvtk7-dev || \
apt-get install -y libvtk6-dev
# only for CI/CD test builds without networks.
apt-get install -y iproute2
if grep -q 'VERSION_ID="14.04"' /etc/os-release; then
# Ubuntu 14.04 has CMake 2 by default, but we require CMake 3
apt-get install -y cmake3
# Ubuntu 14.04's cython3 package is ancient, install via pip instead
apt-get install -y python3-pip
# Must use Cython 3.0 or lower, since 3.1 uses f-string which is
# incompatible with Python 3.4.
pip3 install "cython<3.1"
# Ubuntu 14.04's matplotlib package is ancient, install the
# minimum version and its dependencies via pip. Note that the
# native build uses Python 3.4 while the venv build (tested
# later) uses Python 3.5 without these problems.
#
# pip's pyparsing is incompatible with Python 3.4
apt-get install -y python3-pyparsing
# same, newer cycler has incompatible type annotation
pip3 install "cycler==0.10.0"
pip3 install "matplotlib==2.1.0"
# venv is not installed here. See special case in the step
# "Create Python venv and install dependencies"
else
apt-get install -y cmake
apt-get install -y python3-setuptools-scm cython3 python3-matplotlib
# testing Python packages in isolated venv
apt-get install -y python3-venv
fi
elif grep -q "ID=alpine" /etc/os-release; then
apk add bash \
build-base gmp-dev mpfr-dev git cmake \
tinyxml-dev hdf5-dev cgal-dev vtk-dev \
python3-dev py3-pip \
py3-setuptools py3-setuptools_scm cython \
py3-numpy py3-matplotlib
# only for CI/CD test builds without networks.
apk add iproute2
elif [ -f /etc/centos-release ]; then
# IPv6 on GitHub Actions is broken, causing random network failures
# if a CDN rosolves to IPv6.
echo "ip_resolve=4" >> /etc/yum.conf
# CentOS repos are EOL and desupported
sed -i 's|^mirrorlist|#mirrorlist|g; s|^#baseurl|baseurl|g; s|mirror.centos.org|vault.centos.org|g' \
/etc/yum.repos.d/CentOS-Base.repo
yum install -y centos-release-scl || true
sed -i 's|^mirrorlist|#mirrorlist|g; s|^#baseurl|baseurl|g;
s|^# baseurl|baseurl|g; s|mirror.centos.org|vault.centos.org|g' \
/etc/yum.repos.d/CentOS-SCLo-scl.repo \
/etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
cat /etc/yum.repos.d/CentOS-SCLo-scl.repo
cat /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
yum install -y epel-release
yum install -y git
yum install -y gcc gcc-c++ gmp-devel mpfr-devel \
cmake3 git tinyxml-devel vtk-devel hdf5-devel \
python3-devel \
python3-pip \
python3-setuptools python3-setuptools_scm python3-Cython \
python3-numpy
# only for CI/CD test builds without networks.
yum install -y iproute
# use cmake3 instead of default cmake2
alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 99
# To upgrade GCC, one can use GCC 7 from centos-release-scl, required by CGAL.
# Even GCC 10+ is provided.
# Not used for now, since openEMS is still compatible with GCC 4.8! But we may
# need it in the future.
# yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++
# alternatives --install /usr/local/bin/gcc gcc /opt/rh/devtoolset-7/root/usr/bin/gcc 99
# alternatives --install /usr/local/bin/g++ g++ /opt/rh/devtoolset-7/root/usr/bin/g++ 99
# This is a very old Boost incompatible with openEMS, but good enough
# for CGAL. See openEMS.git for the alternative solution.
yum install -y boost-devel
# CentOS didn't package matplotlib for Python 3, install the minimum
# requirement here.
pip3 install "matplotlib==2.1.0"
# not package on CentOS
# CGAL v4.14.3 was old enough to be compatible with GCC 4.8. Otherwise,
# you get: The compiler feature "cxx_decltype_auto" is not known
# to CXX compiler "GNU" version 4.8.5.
git clone $GITHUB_SERVER_URL/CGAL/cgal.git --depth=1 --branch=v4.14.3
cd cgal && mkdir build && cd build
cmake ../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/opt
make -j`nproc` && make install
else
echo "Unknown system!"
exit 1
fi
- if: ${{ matrix.os.ancient }}
name: Legacy Checkout CSXCAD.git
run: |
echo "Clone $GITHUB_REPOSITORY.git (branch $GITHUB_SHA)"
git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git CSXCAD
cd $GITHUB_WORKSPACE/CSXCAD
git fetch --force $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git "+refs/heads/*:refs/remotes/origin/*"
git fetch --force $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git "+refs/pull/*/merge:refs/remotes/origin/pr/*"
git checkout $GITHUB_SHA
- if: ${{ matrix.os.ancient }}
name: Legacy ${{ needs.Dependencies.outputs.fparser_checkout_title }}
run: |
echo "Clone ${{ needs.Dependencies.outputs.fparser_repo }}.git (branch ${{ needs.Dependencies.outputs.fparser_branch }})"
git clone "$GITHUB_SERVER_URL/${{ needs.Dependencies.outputs.fparser_repo }}.git"
cd $GITHUB_WORKSPACE/fparser
git fetch --force "$GITHUB_SERVER_URL/${{ needs.Dependencies.outputs.fparser_repo }}.git" "+refs/heads/*:refs/remotes/origin/*"
git fetch --force "$GITHUB_SERVER_URL/${{ needs.Dependencies.outputs.fparser_repo }}.git" "+refs/pull/*/merge:refs/remotes/origin/pr/*"
git checkout "${{ needs.Dependencies.outputs.fparser_branch }}"
- name: Build and install fparser
run: |
cd $GITHUB_WORKSPACE/fparser
mkdir build && cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=$HOME/opt
make -j`nproc` && make install
- name: Build and install CSXCAD
run: |
# cmake may fail with "fatal: No names found, cannot describe anything."
# if it happens, check if you're using a shallow clone, or if it's a GitHub
# fork created with "Copy the master branch only". If so, you need to FULL
# fork or clone.
#
# MPI may also fail, but this error is not fatal. The real error is often
# the error above! There's no need to install MPI.
cd $GITHUB_WORKSPACE/CSXCAD
mkdir build && cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=$HOME/opt
make -j`nproc` && make install
- name: Build and install CSXCAD Python module with --no-build-isolation
run: |
cd $GITHUB_WORKSPACE/CSXCAD/python
export CSXCAD_INSTALL_PATH="$HOME/opt"
pip_opts=( "--user" "--verbose" )
# some systems don't have --no-build-isolation, some systems don't have
# --break-system-packages, the oldest systems don't have both.
if pip3 install --help | grep -q no-build-isolation; then
pip_opts+=( "--no-build-isolation" )
fi
if pip3 install --help | grep -q break-system-packages; then
pip_opts+=( "--break-system-packages" )
fi
# run in an isolated container without network, ensure
# pip install really works without auto-downloads.
ip netns add no-network
ip netns exec no-network pip3 install . "${pip_opts[@]}"
- name: Smoketest CSXCAD Python module execution
run: |
cd /
python3 -c "import CSXCAD; print(CSXCAD.ContinuousStructure())"
python3 -c "import CSXCAD; print(CSXCAD.__version__)"
- name: Unittest CSXCAD Python module execution
run: |
cd $GITHUB_WORKSPACE/CSXCAD/python/tests
python3 -m unittest
- name: Create Python venv and install dependencies
run: |
cd ~/
if grep -q "ID=ubuntu" /etc/os-release && \
grep -q 'VERSION_ID="14.04"' /etc/os-release; then
# Use Python 3.5 instead of the default Python 3.4 because
# 3.5 is the latest available version on Ubuntu 14.04, and
# also because Python 3.5 is the first Python that supported
# type annotation, while Python 3.4 is locked out from most
# modern packages.
apt-get install -y curl python3.5-dev
# Ubuntu 14.04 is ancient, and the python3.5-venv package is
# broken. So the best approach is to install a bare Python 3.5
# interpreter from apt, and bootstrapping pip ourselves.
python3.5 -m venv ~/venv --without-pip
curl -O https://bootstrap.pypa.io/pip/3.5/get-pip.py
source ~/venv/bin/activate
python3.5 get-pip.py
else
python3 -m venv ~/venv
source ~/venv/bin/activate
fi
pip install --upgrade pip
if [ -f /etc/centos-release ]; then
pip3 install "cython<3.1"
fi
- name: Build and install CSXCAD Python module in venv
run: |
source ~/venv/bin/activate
cd $GITHUB_WORKSPACE/CSXCAD/python
export CSXCAD_INSTALL_PATH="$HOME/opt"
pip3 install . --verbose
- name: Smoketest CSXCAD Python module execution in venv
run: |
source ~/venv/bin/activate
cd /
python3 -c "import CSXCAD; print(CSXCAD.ContinuousStructure())"
python3 -c "import CSXCAD; print(CSXCAD.__version__)"
- name: Unittest CSXCAD Python module execution in venv
run: |
source ~/venv/bin/activate
cd $GITHUB_WORKSPACE/CSXCAD/python/tests
python3 -m unittest
macOS:
name: "macOS (ARM, latest)"
runs-on: macos-latest
needs: Dependencies
steps:
# When checking out repos, I recommend running actions/checkout
# as soon as possible before anything else, and in the reverse
# order, from the project repo to its dependencies. This reduces
# race conditions due to force pushes (they are harmless but
# annoying).
- name: Checkout CSXCAD.git
uses: actions/checkout@v4
with:
path: CSXCAD
# checkout must be deep, not shallow.
# We need tags for "git describe", otherwise build fails.
fetch-depth: 0
- name: ${{ needs.Dependencies.outputs.fparser_checkout_title }}
uses: actions/checkout@v4
with:
repository: "${{ needs.Dependencies.outputs.fparser_repo }}"
ref: "${{ needs.Dependencies.outputs.fparser_branch }}"
path: fparser
- name: Install dependencies
shell: sh
run: |
echo "export NCPUS=$(python3 -c 'import os; print(os.cpu_count())')" >> ~/.zprofile
echo 'export CXXFLAGS="-Wall -Wextra -Wno-error"' >> ~/.zprofile
# already installed on the CI/CD system, disable to avoid warning fatigue
# brew install python3 cmake
brew install hdf5 cgal vtk python-setuptools numpy cython python-matplotlib
# TinyXML has been disabled by Homebrew at it's unmaintained
# since 2011, TinyXML2 is not API-compatible. As a stop-gap,
# build from source.
#
# -L: follow redirect, REQUIRED!
curl -L https://sourceforge.net/projects/tinyxml/files/tinyxml/2.6.2/tinyxml_2_6_2.tar.gz -o tinyxml-2.6.2.tar.gz
tar -xf tinyxml-2.6.2.tar.gz
cd tinyxml
# The first patch enforces use of stl strings, rather than a custom string type.
# The second patch is a fix for incorrect encoding of elements with special characters
# The third and fourth patches are security fixes.
#
# -L: follow redirect, REQUIRED!
# -O: save to disk with an automatic file name.
curl -L -O "https://raw.githubusercontent.com/alpinelinux/aports/b1ff376e83eb49c0127b039b3684eccdf9a60694/community/tinyxml/tinyxml-2.6.2-defineSTL.patch"
curl -L -O "https://raw.githubusercontent.com/alpinelinux/aports/b1ff376e83eb49c0127b039b3684eccdf9a60694/community/tinyxml/tinyxml-2.6.1-entity.patch"
curl -L -O "https://raw.githubusercontent.com/alpinelinux/aports/b1ff376e83eb49c0127b039b3684eccdf9a60694/community/tinyxml/CVE-2021-42260.patch"
curl -L -O "https://raw.githubusercontent.com/alpinelinux/aports/b1ff376e83eb49c0127b039b3684eccdf9a60694/community/tinyxml/CVE-2023-34194.patch"
# The final patch adds a CMakeLists.txt file to build a shared library and provide an install target
# submitted upstream as https://sourceforge.net/p/tinyxml/patches/66/
curl -L -O "https://gist.githubusercontent.com/scpeters/6325123/raw/cfb079be67997cb19a1aee60449714a1dedefed5/tinyxml_CMakeLists.patch"
patch -p1 < tinyxml-2.6.2-defineSTL.patch
patch -p1 < tinyxml-2.6.1-entity.patch
patch -p1 < CVE-2021-42260.patch
patch -p1 < CVE-2023-34194.patch
# You know something is truly deprecated when the patch itself needs
# patching! In CMake 4, 3.10 is deprecated and 3.5 has been removed.
# use 3.0...3.10 so all of these versions are acceptable as min. version.
# (CMake 2 is dropped since openEMS already requires CMake 3, and also
# because CMake 2 is too old that it's not even documented anymore)
#
# https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html
sed -i -e "s/cmake_minimum_required(VERSION 2.4.6)/cmake_minimum_required(VERSION 3.0...3.10)/" \
tinyxml_CMakeLists.patch # -e is not optional in BSD sed
patch -p1 < tinyxml_CMakeLists.patch
mkdir build && cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=$HOME/opt
make -j$NCPUS && make install
- name: Build and install fparser
run: |
source ~/.zprofile
cd $GITHUB_WORKSPACE/fparser
mkdir build && cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=$HOME/opt
make -j$NCPUS && make install
- name: Build and install CSXCAD
run: |
# cmake may fail with "fatal: No names found, cannot describe anything."
# if it happens, check if you're using a shallow clone, or if it's a GitHub
# fork created with "Copy the master branch only". If so, you need to FULL
# fork or clone.
#
# MPI may also fail, but this error is not fatal. The real error is often
# the error above! There's no need to install MPI.
source ~/.zprofile
cd $GITHUB_WORKSPACE/CSXCAD
mkdir build && cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=$HOME/opt
make -j$NCPUS && make install
- name: Build and install CSXCAD Python module with --no-build-isolation
run: |
source ~/.zprofile
cd $GITHUB_WORKSPACE/CSXCAD/python
export CSXCAD_INSTALL_PATH="$HOME/opt"
pip3 install . --user --break-system-packages --no-build-isolation --verbose
- name: Smoketest CSXCAD Python module execution
run: |
cd /
python3 -c "import CSXCAD; print(CSXCAD.ContinuousStructure())"
python3 -c "import CSXCAD; print(CSXCAD.__version__)"
- name: Unittest CSXCAD Python module execution
run: |
cd $GITHUB_WORKSPACE/CSXCAD/python/tests
python3 -m unittest
- name: Create Python venv and install dependencies
run: |
# remove Python dependencies to see if venv really works
pip3 uninstall -y CSXCAD --break-system-packages
brew remove python-setuptools cython numpy python-matplotlib
python3 -m venv ~/venv
source ~/venv/bin/activate
pip3 install --upgrade pip
- name: Build and install CSXCAD Python module in venv
run: |
source ~/venv/bin/activate
cd $GITHUB_WORKSPACE/CSXCAD/python
export CSXCAD_INSTALL_PATH="$HOME/opt"
pip3 install . --verbose
- name: Smoketest CSXCAD Python module execution in venv
run: |
source ~/venv/bin/activate
cd /
python3 -c "import CSXCAD; print(CSXCAD.ContinuousStructure())"
python3 -c "import CSXCAD; print(CSXCAD.__version__)"
- name: Unittest CSXCAD Python module execution in venv
run: |
source ~/venv/bin/activate
cd $GITHUB_WORKSPACE/CSXCAD/python/tests
python3 -m unittest
FreeBSD:
runs-on: ubuntu-latest
needs: Dependencies
strategy:
matrix:
machine:
- name: "FreeBSD 14.2"
os: freebsd
arch: x86-64
version: '14.2'
# macOS already tests ARM for us, so disable the slow ARM emulator
# for now
#- name: "FreeBSD 14.2 (ARM emulator)"
# os: freebsd
# arch: arm64
# version: '14.2'
name: "${{ matrix.machine.name }}"
steps:
# When checking out repos, I recommend running actions/checkout
# as soon as possible before anything else, and in the reverse
# order, from the project repo to its dependencies. This reduces
# race conditions due to force pushes (they are harmless but
# annoying).
- name: Checkout CSXCAD.git
uses: actions/checkout@v4
with:
path: CSXCAD
# checkout must be deep, not shallow.
# We need tags for "git describe", otherwise build fails.
fetch-depth: 0
- name: ${{ needs.Dependencies.outputs.fparser_checkout_title }}
uses: actions/checkout@v4
with:
repository: "${{ needs.Dependencies.outputs.fparser_repo }}"
ref: "${{ needs.Dependencies.outputs.fparser_branch }}"
path: fparser
- name: Test in FreeBSD ${{ matrix.machine.version }} ${{ matrix.machine.arch }}
uses: cross-platform-actions/action@v0.26.0
with:
cpu_count: 4
architecture: ${{ matrix.machine.arch }}
operating_system: ${{ matrix.machine.os }}
version: ${{ matrix.machine.version }}
run: |
echo "Install dependencies..."
sudo pkg install -y cmake git tinyxml vtk9 hdf5 cgal python3 \
py311-pip \
py311-setuptools py311-wheel py311-setuptools-scm \
py311-cython3 py311-numpy py311-matplotlib
# prefix must match FreeBSD's default python
# version. FreeBSD 14.2 uses Python 3.11 so
# use "py311-"
export NCPUS=$(python3 -c 'import os; print(os.cpu_count())')
export CXXFLAGS="-Wall -Wextra -Wno-error"
echo "Build and install fparser..."
cd $GITHUB_WORKSPACE/fparser
mkdir build && cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=$HOME/opt
make -j$NCPUS && make install
echo "Build and install CSXCAD..."
# cmake may fail with "fatal: No names found, cannot describe anything."
# if it happens, check if you're using a shallow clone, or if it's a GitHub
# fork created with "Copy the master branch only". If so, you need to FULL
# fork or clone.
#
# MPI may also fail, but this error is not fatal. The real error is often
# the error above! There's no need to install MPI.
cd $GITHUB_WORKSPACE/CSXCAD
mkdir build && cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=$HOME/opt
make -j$NCPUS && make install
echo "Build and install CSXCAD Python module with --no-build-isolation..."
cd $GITHUB_WORKSPACE/CSXCAD/python
export CSXCAD_INSTALL_PATH="$HOME/opt"
pip install . --user --break-system-packages --no-build-isolation --verbose
echo "Smoketest CSXCAD Python module execution..."
cd /
python3 -c "import CSXCAD; print(CSXCAD.ContinuousStructure())"
python3 -c "import CSXCAD; print(CSXCAD.__version__)"
echo "Unittest CSXCAD Python module execution..."
cd $GITHUB_WORKSPACE/CSXCAD/python/tests
python3 -m unittest
echo "Create Python venv and install dependencies..."
# remove Python dependencies to see if venv really works
pip uninstall -y CSXCAD --break-system-packages
sudo pkg remove -y py311-pip \
py311-setuptools py311-wheel py-setuptools-scm \
py311-cython3 py311-numpy py311-matplotlib
python3 -m venv ~/venv
. ~/venv/bin/activate
pip install --upgrade pip
echo "Build and install CSXCAD Python module in venv..."
cd $GITHUB_WORKSPACE/CSXCAD/python
export CSXCAD_INSTALL_PATH="$HOME/opt"
pip install . --verbose
echo "Smoketest CSXCAD Python module execution in venv..."
cd /
python3 -c "import CSXCAD; print(CSXCAD.ContinuousStructure())"
python3 -c "import CSXCAD; print(CSXCAD.__version__)"
echo "Unittest CSXCAD Python module execution in venv..."
cd $GITHUB_WORKSPACE/CSXCAD/python/tests
python3 -m unittest
Windows:
runs-on: windows-latest
needs: Dependencies
strategy:
# Use "false" means a single failed build won't terminate other combinations
# in the matrix. This wastes CPU time, but is an important debugging tool to
# prevent a single broken platform from stopping the whole matrix.
fail-fast: false
matrix:
toolchain:
# name: toonchain name (only a name for humans to read).
# CC, CXX: C/C++ compiler, environment variables
- name: "MSVC"
CC: "cl"
CXX: "cl"
- name: "clang-cl"
CC: "clang-cl"
CXX: "clang-cl"
env:
VS_ROOT_DIR: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/"
CC: "${{ matrix.toolchain.CC }}"
CXX: "${{ matrix.toolchain.CXX }}"
CFLAGS: "/D_WIN32_WINNT=0x0601"
CXXFLAGS: "/D_WIN32_WINNT=0x0601"
VCPKG_CACHE_PATH: "${{ github.workspace }}/vcpkg-cache/"
VCPKG_BINARY_CACHE_PATH: "${{ github.workspace }}/vcpkg-cache/binary"
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/vcpkg-cache/binary,readwrite"
VCPKG_ASSET_CACHE_PATH: "${{ github.workspace }}/vcpkg-cache/asset"
X_VCPKG_ASSET_SOURCES: "x-azurl,file://${{ github.workspace }}/vcpkg-cache/asset,readwrite"
# allow this job to create and modify vcpkg packages for binary cache
permissions:
packages: write
name: "Windows (${{ matrix.toolchain.name }}, latest)"
steps:
# When checking out repos, I recommend running actions/checkout
# as soon as possible before anything else, and in the reverse
# order, from the project repo to its dependencies. This reduces
# race conditions due to force pushes (they are harmless but
# annoying).
- name: Checkout CSXCAD.git
uses: actions/checkout@v4
with:
path: CSXCAD
# checkout must be deep, not shallow.
# We need tags for "git describe", otherwise build fails.
fetch-depth: 0
- name: ${{ needs.Dependencies.outputs.fparser_checkout_title }}
uses: actions/checkout@v4
with:
repository: "${{ needs.Dependencies.outputs.fparser_repo }}"
ref: "${{ needs.Dependencies.outputs.fparser_branch }}"
path: fparser
# checkout must be deep, not shallow.
# We need tags for "git describe", otherwise build fails.
fetch-depth: 0
# It doesn't really work, because MSVC itself doesn't support long path.
# But for future-proofing (it does work for clang).
- name: Enable long paths
run: |
New-ItemProperty -Path "HKLM:/SYSTEM/CurrentControlSet/Control/FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
- name: Create vcpkg cache directories
run: |
mkdir -p "$env:VCPKG_CACHE_PATH"
mkdir -p "$env:VCPKG_BINARY_CACHE_PATH"
mkdir -p "$env:VCPKG_ASSET_CACHE_PATH"
- name: Restore vcpkg cache
uses: actions/cache/restore@v5
with:
path: ${{ env.VCPKG_CACHE_PATH }}
# almost always nonexistent
key: "Windows - ${{ matrix.toolchain.name }} - ${{ github.sha }}"
# use GitHub's fallback feature to pick the latest cache with this prefix
restore-keys: |
Windows - ${{ matrix.toolchain.name }}
- name: Build and install fparser
run: |
& "$env:VS_ROOT_DIR/Common7/Tools/Launch-VsDevShell.ps1" -Arch amd64 -HostArch amd64
cd "$env:GITHUB_WORKSPACE/fparser"
mkdir build && cd build
cmake ../ -GNinja -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_INSTALL_PREFIX="$HOME/opt"
cmake --build ./ --parallel
cmake --install ./ --parallel 8
- name: Build and install CSXCAD
run: |
& "$env:VS_ROOT_DIR/Common7/Tools/Launch-VsDevShell.ps1" -Arch amd64 -HostArch amd64
cd "$env:GITHUB_WORKSPACE/CSXCAD"
mkdir build && cd build
cmake ../ -GNinja `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_INSTALL_PREFIX="$HOME/opt" `
-DFPARSER_ROOT_DIR="$HOME/opt" `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" `
-DVCPKG_HOST_TRIPLET="x64-windows-release" `
-DVCPKG_TARGET_TRIPLET="x64-windows-release"
cmake --build ./ --parallel
cmake --install ./ --parallel 8
- name: Save vcpkg cache
if: always() # save even after a build failure.
uses: actions/cache/save@v5
with:
path: ${{ env.VCPKG_CACHE_PATH }}
# GitHub cache is immutable and can't be overwritten
# save a new cache key every time
key: Windows - ${{ matrix.toolchain.name }} - ${{ github.sha }}