-
Notifications
You must be signed in to change notification settings - Fork 12
175 lines (162 loc) · 6.15 KB
/
build-and-test.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
# Connected to the status badge
name: Build
on:
push:
branches: [ stable ]
jobs:
#Before doing anything, make sure that the code is linted
run-linters:
name: Run linters
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Install ClangFormat
run: sudo apt-get install -y clang-format
- name: Set up Python
uses: actions/setup-python@v4
- name: Install Python dependencies
run: pip install black flake8
- name: Run cpp linter
uses: wearerequired/lint-action@v2
with:
auto_fix: true
clang_format: true
clang_format_extensions: "c,cc,cpp,h,hpp,tpp"
clang_format_dir: "src/"
clang_format_auto_fix: true
# black: true
# black_extensions: "py"
# black_dir: #ignoring python formatting for now, as the github action does not support multiple directories
# -"src/"
# -"tests/"
# -"magritte/"
# -"docs/"
# black_auto_fix: true
#Before testing, we increase the version number. Otherwise, some delay (>30 mins) may occur between updating the code and doing the version increase.
UpdateVersion:
needs: run-linters
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v3
with:
ref: ${{ github.ref }} #err, version.txt file should not be linted; but still checking out latest commit to be sure
- name: Update version (locally) using commit message to determine version increase
run: echo "NewVersion=$(python updateVersion.py "${{github.event.head_commit.message}}")" >> $GITHUB_ENV
working-directory: CI
- name: Auto commit the version change
uses: test-room-7/action-update-file@v1
with:
file-path: version.txt
commit-msg: "CI: increment version number to ${{env.NewVersion}}"
github-token: ${{ secrets.GITHUB_TOKEN}}
branch: stable
BuildAndTest:
needs: UpdateVersion
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
C-COMPILER: gcc-14
CXX-COMPILER: g++-14
- os: ubuntu-latest
C-COMPILER: gcc
CXX-COMPILER: g++
defaults:
run:
shell: bash -l {0} # necessary for conda
steps:
- name: (linux) install libegl1
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libegl1 libglu1-mesa
#I think these dependencies are all required for gmsh; TODO: remove them after I remove gmsh
# retrying checkout: 3 tries, with 5 seconds wait inbetween
- name: Check out repository code (try 1)
id: checkouttry1
uses: actions/checkout@v3
with: #no ref: thus checks out commit which triggered workflow
submodules: true
ref: ${{ github.ref }} #note: linter might create new commit; that one needs to be tested (github.ref points to branch -> latest commit on branch)
- name: wait 5 s if attempt failed
if: steps.checkouttry1.outcome == 'failure'
run: sleep 5
- name: Check out repository code (try 2)
id: checkouttry2
if: steps.checkouttry1.outcome == 'failure'
uses: actions/checkout@v3
with: #no ref: thus checks out commit which triggered workflow
submodules: true
ref: ${{ github.ref }}
- name: wait 5 s if attempt failed
if: steps.checkouttry2.outcome == 'failure'
run: sleep 5
- name: Check out repository code (try 3)
id: checkouttry3
if: steps.checkouttry2.outcome == 'failure'
uses: actions/checkout@v3
with: #no ref: thus checks out commit which triggered workflow
submodules: true
ref: ${{ github.ref }}
# end retrying checkout
- name: install gmsh
run: |
bash ./dependencies/get_gmsh.sh
echo "$GITHUB_WORKSPACE/dependencies/gmsh/bin/" >> $GITHUB_PATH
#err, relies a bit too much on absolute path for which the script install gmsh
- name: gsmh version
run: gmsh --version
- name: setup python
uses: actions/setup-python@v4
# retrying setting up conda: 3 tries, with 5 seconds wait inbetween
- name: Install conda packages (try 1)
id: setupcondatry1
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: magritte
environment-file: dependencies/conda_env.yml
auto-activate-base: false
miniforge-variant: Mambaforge
channels: conda-forge, defaults
- name: wait 5 s if attempt failed
if: steps.setupcondatry1.outcome == 'failure'
run: sleep 5
- name: Install conda packages (try 2)
id: setupcondatry2
if: steps.setupcondatry1.outcome == 'failure'
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: magritte
environment-file: dependencies/conda_env.yml
auto-activate-base: false
miniforge-variant: Mambaforge
channels: conda-forge, defaults
- name: wait 5 s if attempt failed
if: steps.setupcondatry2.outcome == 'failure'
run: sleep 5
- name: Install conda packages (try 3)
id: setupcondatry3
if: steps.setupcondatry2.outcome == 'failure'
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: magritte
environment-file: dependencies/conda_env.yml
auto-activate-base: false
miniforge-variant: Mambaforge
channels: conda-forge, defaults
# end retrying conda
- name: build Magritte
run: bash build.sh
env:
CC : ${{ matrix.C-COMPILER }}
CXX: ${{ matrix.CXX-COMPILER }}
#and finally do our tests (located in the benchmarks folder)
- name: run analytic tests
run: pytest --verbose
working-directory: tests/benchmarks/analytic
- name: run numeric tests
run: pytest --verbose
working-directory: tests/benchmarks/numeric