|
34 | 34 | DEFAULT_BRANCH: main |
35 | 35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
36 | 36 |
|
| 37 | + - name: Install system deps |
| 38 | + run: | |
| 39 | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - |
| 40 | + sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main" |
| 41 | + sudo apt-get update |
| 42 | + sudo apt-get install -y build-essential cmake clang clang-tidy-20 clang-format perl libarmadillo-dev libopenblas-dev libsuperlu-dev libeigen3-dev |
| 43 | +
|
| 44 | + - name: Gather source files |
| 45 | + id: files |
| 46 | + run: | |
| 47 | + # list C/C++ source files tracked by git |
| 48 | + echo "::set-output name=sources::$(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hpp' '*.hh' | tr '\n' ' ')" |
| 49 | + |
| 50 | + - name: Configure with CMake (generate compile_commands.json) |
| 51 | + run: | |
| 52 | + mkdir -p build |
| 53 | + ls -al /usr/share/eigen3/cmake |
| 54 | + cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DEigen3_DIR=/usr/share/eigen3/cmake |
| 55 | + ls -la build/compile_commands.json |
| 56 | + |
| 57 | + - name: clang-tidy (fail on warnings/errors) |
| 58 | + run: | |
| 59 | + if [ -z "${{ steps.files.outputs.sources }}" ]; then |
| 60 | + echo "No C/C++ sources found — skipping clang-tidy." |
| 61 | + else |
| 62 | + # Run clang-tidy using compile_commands.json. Collect output and fail if diagnostics are present. |
| 63 | + # Note: clang-tidy often prints diagnostics to stdout/stderr; we capture and grep for "warning:" or "error:". |
| 64 | + printf '%s\n' ${{ steps.files.outputs.sources }} > /tmp/clang_tidy_files.txt |
| 65 | + set -o pipefail |
| 66 | + perl -pi -e 's/-I(.*?)third_party_install/-isystem \1third_party_install/g' build/compile_commands.json |
| 67 | + clang-tidy-20 --format-style='llvm' -p build $(cat /tmp/clang_tidy_files.txt) 2>&1 | tee clang-tidy.out || true |
| 68 | + if grep -E "warning:|error:" clang-tidy.out >/dev/null; then |
| 69 | + echo "clang-tidy reported warnings/errors — failing the job." |
| 70 | + echo "" |
| 71 | + tail -n +1 clang-tidy.out |
| 72 | + exit 1 |
| 73 | + else |
| 74 | + echo "clang-tidy: no warnings/errors detected." |
| 75 | + fi |
| 76 | + fi |
| 77 | +
|
37 | 78 | build-MOLE-ubuntu: |
38 | 79 | runs-on: ubuntu-latest |
39 | 80 | needs: lint-new-code |
@@ -167,11 +208,11 @@ jobs: |
167 | 208 | fi |
168 | 209 |
|
169 | 210 | if [ -n "$CHANGED" ]; then |
170 | | - echo "changed=true" >> $GITHUB_OUTPUT |
| 211 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
171 | 212 | echo "Documentation sources have changed:" |
172 | 213 | echo "$CHANGED" |
173 | 214 | else |
174 | | - echo "changed=false" >> $GITHUB_OUTPUT |
| 215 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
175 | 216 | echo "No documentation sources changed" |
176 | 217 | fi |
177 | 218 |
|
|
0 commit comments