Repository navigation
167 lines (143 loc) · 5.61 KB
/
Copy pathci.yml
File metadata and controls
167 lines (143 loc) · 5.61 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
name: CI
# Build, test and lint CppNCorr. Triggered on pushes and pull requests targeting
# main and newversion. Kept deliberately fast: GCC on ubuntu-latest, system
# dependencies from apt (no GPU, no large dataset downloads, no source builds of
# OpenCV etc.).
on:
push:
branches: [main, newversion]
pull_request:
branches: [main, newversion]
workflow_dispatch:
# Cancel superseded runs on the same ref to save CI minutes.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
DEBIAN_FRONTEND: noninteractive
# CMake >= 3.21 on the runner sets PROJECT_IS_TOP_LEVEL automatically.
CMAKE_ARGS: -DCMAKE_POLICY_VERSION_MINIMUM=3.5
jobs:
build:
name: build (gcc, ubuntu-latest)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential cmake \
libopencv-dev libfftw3-dev libsuitesparse-dev \
libopenblas-dev liblapack-dev nlohmann-json3-dev libomp-dev
- name: Configure (top-level, tests enabled)
run: cmake -S . -B build $CMAKE_ARGS
- name: Build library + tests
run: cmake --build build -j "$(nproc)"
test:
name: test (unit + integration via ctest)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential cmake \
libopencv-dev libfftw3-dev libsuitesparse-dev \
libopenblas-dev liblapack-dev nlohmann-json3-dev libomp-dev
- name: Configure
run: cmake -S . -B build $CMAKE_ARGS
- name: Build test targets
run: cmake --build build --target ncorr_unit_tests ncorr_engine_tests -j "$(nproc)"
- name: Run unit tests (fast)
working-directory: build
run: ctest --output-on-failure -L unit
- name: Run integration tests (ohtcfrp)
working-directory: build
env:
OMP_NUM_THREADS: "2"
# Integration DIC is compute-heavy; give it a generous timeout. The very
# slow end-to-end cases (label "e2e") are excluded here to keep CI fast —
# they run locally / on demand (see docs/developer_guide.md).
run: ctest --output-on-failure --timeout 1200 -L integration
lint:
name: lint (clang-format on changed files)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install clang-format (pinned)
# Pin the exact version: apt ships different clang-format majors across
# runner images, which disagree with the version used to format the tree.
run: python3 -m pip install --quiet "clang-format==18.1.8"
- name: clang-format --dry-run on changed C/C++ files
run: |
# Always use the pinned pip binary explicitly (the runner image also
# ships a different-major clang-format on PATH).
CF="$(python3 -c 'import clang_format, os; print(os.path.join(os.path.dirname(clang_format.__file__), "data", "bin", "clang-format"))')"
"$CF" --version
# Determine the base ref to diff against.
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE="origin/${{ github.base_ref }}"
git fetch origin "${{ github.base_ref }}" || true
else
BASE="${{ github.event.before }}"
fi
# Lint files ADDED on this branch (diff-filter=A). Pre-existing legacy
# files that only received small edits are intentionally not reformatted
# wholesale; the .clang-format style applies to new code on this branch.
CHANGED=$(git diff --name-only --diff-filter=A "$BASE" HEAD 2>/dev/null \
| grep -E '\.(c|cc|cpp|cxx|h|hpp)$' || true)
if [ -z "$CHANGED" ]; then
echo "No newly added C/C++ files to lint."
exit 0
fi
echo "Linting:"; echo "$CHANGED"
# --dry-run --Werror fails if any file is not formatted.
"$CF" --dry-run --Werror $CHANGED
coverage:
name: Coverage (gcov → Codecov)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
cmake build-essential \
libopencv-dev \
libfftw3-dev \
libsuitesparse-dev \
liblapack-dev libblas-dev \
libomp-dev \
gcovr
- name: Configure (coverage instrumentation)
run: >
cmake -S . -B build
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_FLAGS="--coverage -O0 -g"
-DCMAKE_C_FLAGS="--coverage -O0 -g"
-DCMAKE_EXE_LINKER_FLAGS="--coverage"
- name: Build
run: cmake --build build -j"$(nproc)"
- name: Run tests
working-directory: build
run: ctest --output-on-failure || echo "ctest returned non-zero (continuing for coverage)"
- name: Generate coverage report (Cobertura XML)
run: >
gcovr --root .
--exclude 'build/'
--exclude 'test/'
--exclude 'tests/'
--xml-pretty --output coverage.xml
--print-summary || true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
flags: unittests
name: cppncorr-coverage
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false