-
Notifications
You must be signed in to change notification settings - Fork 61
423 lines (394 loc) · 14.4 KB
/
ci.yml
File metadata and controls
423 lines (394 loc) · 14.4 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
name: CI
on:
push:
branches:
- master
paths-ignore:
- "docs/**"
- "Formula/**"
pull_request:
paths-ignore:
- "docs/**"
- "Formula/**"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
# ──────────────────────────────────────────────────────────────────────────────
# Stage 1: Style checks
# ──────────────────────────────────────────────────────────────────────────────
jobs:
style:
name: Style Check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install tools
run: |
sudo apt-get update -qq
sudo apt-get install -y clang-format perltidy
- name: Check formatting of changed lines
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE=${{ github.event.pull_request.base.sha }}
else
git fetch origin master
BASE=$(git merge-base origin/master HEAD)
fi
DIFF=$(git clang-format --diff "$BASE" --extensions c,h,cpp,hpp,cc,hh)
if echo "$DIFF" | grep -q '^diff'; then
echo "$DIFF"
echo ""
echo "::error::Changed lines are not correctly formatted."
echo "::error::To fix, run: git clang-format ${{ github.base_ref || 'master' }}"
exit 1
fi
echo "All changed C/C++ lines are correctly formatted."
- name: Check perltidy on changed Perl files
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE=${{ github.event.pull_request.base.sha }}
else
git fetch origin master
BASE=$(git merge-base origin/master HEAD)
fi
# Collect changed Perl files: by extension and by shebang
PERL_FILES=()
while IFS= read -r f; do
[ -z "$f" ] && continue
case "$f" in
*.pl|*.pm|*.t) PERL_FILES+=("$f") ;;
*) if head -1 "$f" 2>/dev/null | grep -q '^#!.*perl'; then
PERL_FILES+=("$f")
fi ;;
esac
done < <(git diff --diff-filter=ACMR --name-only "$BASE")
if [ ${#PERL_FILES[@]} -eq 0 ]; then
echo "No changed Perl files to check."
exit 0
fi
FAILED=0
for f in "${PERL_FILES[@]}"; do
if ! perltidy -st -se -nb "$f" | diff -u "$f" -; then
echo "::error file=$f::$f is not perltidy-compliant."
FAILED=1
fi
done
if [ $FAILED -ne 0 ]; then
echo ""
echo "::error::To fix, run: perltidy -b <file>"
exit 1
fi
echo "All changed Perl files are correctly formatted."
# TODO: Once the codebase is fully formatted, switch to whole-file checking:
#
# - name: Check formatting of changed files
# run: |
# set -euo pipefail
#
# if [ "${{ github.event_name }}" = "pull_request" ]; then
# BASE=${{ github.event.pull_request.base.sha }}
# else
# git fetch origin master
# BASE=$(git merge-base origin/master HEAD)
# fi
#
# FAILED=0
# while IFS= read -r f; do
# [ -z "$f" ] && continue
# if ! clang-format -n --Werror --style=file "$f"; then
# echo "::error file=$f::$f is not correctly formatted."
# FAILED=1
# fi
# done < <(git diff --diff-filter=ACMR --name-only "$BASE" -- \
# '*.[hc]pp' '*.cc' '*.[ch]' '*.hh')
#
# if [ $FAILED -ne 0 ]; then
# echo ""
# echo "::error::To fix, run: clang-format -i --style=file <file>"
# exit 1
# fi
# echo "All changed C/C++ files are correctly formatted."
# ──────────────────────────────────────────────────────────────────────────
# Stage 2: Build & test
# ──────────────────────────────────────────────────────────────────────────
test-linux:
name: Linux (${{ matrix.cfg.os }} ${{ matrix.cfg.tag }})
needs: [style]
runs-on: ubuntu-latest
container: docker://${{ matrix.cfg.image }}:${{ matrix.cfg.tag }}
strategy:
fail-fast: false
matrix:
cfg:
- { os: ubuntu, tag: 24.04, arch: debian, image: ubuntu }
- { os: ubuntu, tag: 26.04, arch: debian, image: ubuntu }
- { os: oraclelinux, tag: 8, arch: rhel, image: oraclelinux }
- { os: rockylinux, tag: 8, arch: rhel, image: rockylinux/rockylinux }
- { os: rockylinux, tag: 9, arch: rhel, image: rockylinux/rockylinux }
- { os: rockylinux, tag: 10, arch: rhel, image: rockylinux/rockylinux }
include:
- cfg: {}
deps: >-
bison
clang
flex
git
llvm
make
maven
cmake
swig
zip
gdb
conf_pkg: echo package manager already configured
enable_repo: ""
install_cmd: install -y
#-------- Debian-based Dependencies ----------------
- cfg: { arch: debian }
pkg_mgr: apt-get
conf_pkg: apt-get update
arch_deps: >-
curl
g++
libx11-dev
libxml2-dev
libxt-dev
libmotif-common
libmotif-dev
zlib1g-dev
llvm-dev
libclang-dev
libudunits2-dev
libgtest-dev
libgmock-dev
default-jdk
python3-dev
python3-pip
python3-venv
#-------- RHEL-based Dependencies (all versions) ----------------
- cfg: { arch: rhel }
pkg_mgr: dnf
conf_pkg: |
dnf -y install epel-release
dnf -y update
dnf install -y 'dnf-command(config-manager)'
arch_deps: >-
clang-devel
diffutils
gcc
gcc-c++
gtest-devel
gmock-devel
java-21-openjdk-devel
libxml2-devel
llvm-devel
llvm-static
ncurses-devel
openmotif
openmotif-devel
perl
perl-Digest-MD5
udunits2
udunits2-devel
which
zlib-devel
python3-devel
#-------- RHEL 8: gtest lives in powertools ----------------
- cfg: { arch: rhel, tag: 8 }
enable_repo: dnf config-manager --enable powertools
#-------- RHEL 9/10: gtest lives in crb ----------------
- cfg: { arch: rhel, tag: 9 }
enable_repo: dnf config-manager --enable crb
- cfg: { arch: rhel, tag: 10 }
enable_repo: dnf config-manager --enable crb
#-------- OL 8: gtest lives in codeready_builder ----------------
- cfg: { os: oraclelinux, tag: 8 }
enable_repo: dnf config-manager --enable ol8_codeready_builder
steps:
- name: Set noninteractive mode
run: echo "DEBIAN_FRONTEND=noninteractive" >> "$GITHUB_ENV"
if: matrix.cfg.arch == 'debian'
- name: Update Package Manager
run: |
${{ matrix.conf_pkg }}
${{ matrix.enable_repo }}
- name: Install Dependencies
run: >
${{ matrix.pkg_mgr }}
${{ matrix.install_cmd }}
${{ matrix.deps }}
${{ matrix.arch_deps }}
- name: Checkout repository
uses: actions/checkout@v6
- name: Configure Trick
run: |
echo "MAKEFLAGS=-j$(nproc)" >> "$GITHUB_ENV"
echo "JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))" >> "$GITHUB_ENV"
./configure
- name: Build Trick
run: make
- name: Test Trick
run: |
python3 -m venv share/trick/trickops/.venv
. share/trick/trickops/.venv/bin/activate
pip3 install -r share/trick/trickops/requirements.txt
make test
- name: Upload Tests
uses: actions/upload-artifact@v7
if: ${{ !cancelled() }}
with:
name: Trick_${{ matrix.cfg.os }}${{ matrix.cfg.tag }}
path: trick_test/*.xml
if-no-files-found: warn
retention-days: 1
test-macos:
name: macOS
needs: [style]
runs-on: macos-15
env:
MAKEFLAGS: -j4
steps:
- name: Checkout repository
uses: actions/checkout@v6
# Install googletest version 1.17.0 — the latest stable release as of 6/6/25
# Note: Need to periodically update googletest version to ensure tests can run
# against the latest.
# Specifying the version to ensure CI builds are stable and not unexpectedly
# broken by upstream changes.
- name: Install gtest 1.17.0
run: |
wget https://github.com/google/googletest/archive/refs/tags/v1.17.0.tar.gz
tar -xvf v1.17.0.tar.gz
cd googletest-1.17.0
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/opt/homebrew
cmake --build build
sudo cmake --install build
- name: Install dependencies
run: |
brew update || true
brew upgrade || true
brew install --cask xquartz
brew install udunits openmotif maven
brew install swig llvm
- name: Build Trick
run: |
./configure
make
- name: Test
run: |
python3 -m venv share/trick/trickops/.venv
. share/trick/trickops/.venv/bin/activate
pip3 install -r share/trick/trickops/requirements.txt
make test
- name: Upload Tests
uses: actions/upload-artifact@v7
if: ${{ !cancelled() }}
with:
name: Trick_macos
path: trick_test/*.xml
if-no-files-found: warn
retention-days: 1
trickops:
name: TrickOps (${{ matrix.name }})
needs: [style]
runs-on: ubuntu-latest
container: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
include:
- name: Ubuntu 24.04
image: ubuntu:24.04
install: |
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y git python3 python3-venv perl perl-modules-5.38 qtbase5-dev wget unzip g++ make flex bison
qmake: qmake
- name: RockyLinux 8
image: rockylinux:8
install: |
dnf install -y git python3-devel which perl perl-Digest-MD5 qt5-qtbase-devel bison clang flex make gcc gcc-c++ wget
qmake: qmake-qt5
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install dependencies
run: ${{ matrix.install }}
- name: Create virtual environment
run: |
python3 -m venv share/trick/trickops/.venv
. share/trick/trickops/.venv/bin/activate
pip3 install --upgrade pip && pip3 install -r share/trick/trickops/requirements.txt
- name: Build koviz
run: |
git clone --depth 1 https://github.com/nasa/koviz.git /tmp/koviz
cd /tmp/koviz && ${{ matrix.qmake }} && make
- name: Run unit and doc tests
run: |
. share/trick/trickops/.venv/bin/activate
export PATH="/tmp/koviz/bin:${PATH}"
cd share/trick/trickops/tests && ./run_tests.py
- name: Upload test logs
uses: actions/upload-artifact@v7
if: always()
with:
name: trickops_${{ strategy.job-index }}
path: |
share/trick/trickops/tests/*_doctest_log.txt
/tmp/log.*
code-coverage:
name: Code Coverage
needs: [style]
runs-on: ubuntu-latest
env:
CFLAGS: "-fprofile-arcs -ftest-coverage -fprofile-update=atomic -O0"
CXXFLAGS: "-fprofile-arcs -ftest-coverage -fprofile-update=atomic -O0"
LDFLAGS: "-fprofile-arcs -ftest-coverage -O0"
TRICK_CFLAGS: "-fprofile-arcs -ftest-coverage -fprofile-update=atomic -O0"
TRICK_CXXFLAGS: "-fprofile-arcs -ftest-coverage -fprofile-update=atomic -O0"
TRICK_SYSTEM_LDFLAGS: "-fprofile-arcs -ftest-coverage -O0"
TRICK_SYSTEM_CFLAGS: "-fprofile-arcs -ftest-coverage -fprofile-update=atomic -O0"
TRICK_SYSTEM_CXXFLAGS: "-fprofile-arcs -ftest-coverage -fprofile-update=atomic -O0"
steps:
- name: Install Dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y \
bison clang flex git llvm make maven cmake zip \
g++ libclang-dev llvm-dev \
default-jdk libxml2-dev libmotif-dev libxt-dev \
perl libdigest-md5-perl libudunits2-dev zlib1g-dev \
python3-dev python3-pip python3-venv swig \
libgtest-dev libgmock-dev lcov
- name: Checkout repository
uses: actions/checkout@v6
- name: Configure Trick
run: |
echo "MAKEFLAGS=-j$(nproc)" >> "$GITHUB_ENV"
echo "JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))" >> "$GITHUB_ENV"
./configure
- name: Build Trick
run: make
- name: Generate Code Coverage
run: |
python3 -m venv share/trick/trickops/.venv
. share/trick/trickops/.venv/bin/activate
pip3 install -r share/trick/trickops/requirements.txt
make code-coverage
- name: Upload to Coveralls
uses: coverallsapp/github-action@v2
continue-on-error: true
with:
file: coverage.info
format: lcov