Files
ConformalLabpp/scripts/quality/multi-compiler 2.sh
Tarik Moussa 7b097fbdd1
Some checks failed
C++ Tests / test-fast (pull_request) Successful in 2m2s
API Docs / doc-build (pull_request) Successful in 46s
Markdown link check / check (pull_request) Successful in 47s
C++ Tests / test-cgal (pull_request) Failing after 10m51s
C++ Tests / quality-gates (pull_request) Successful in 2m21s
ci+licenses: promote 4 trivial gates to required CI + third-party license doc
Two reviewer-facing additions:

1. New `quality-gates` job in .gitea/workflows/cpp-tests.yml
   ──────────────────────────────────────────────────────────
   Runs in parallel with test-cgal after test-fast.  Installs
   `codespell` + `shellcheck` (apt) into the existing ci-cpp container,
   then executes four scripts strictly (exit 1 on any finding):
     * license-headers.sh   — 66/66 files carry SPDX MIT
     * cgal-conventions.py  — 0 violations across 6 CGAL public headers
     * codespell.sh         — 0 typos across docs + source + scripts
     * shellcheck.sh        — 0 findings across 16 shell scripts

   Each ran at 0 findings locally for weeks before promotion.  The
   gates are now contractual: a regression fails the PR.  Total
   wall-time on the eulernest runner: ~30 s.

2. New code/deps/THIRD-PARTY-LICENSES.md
   ──────────────────────────────────────
   Enumerates every vendored dependency under code/deps/, plus the
   auto-fetched GoogleTest, plus the system-required Boost, with:
     * upstream project + version + SPDX identifier
     * compatibility note for MIT distribution
     * a downstream-packager license matrix (header-only consumer
       vs CLI binary) clarifying the LGPL §3 vs §4 distinction
       relevant to CGAL's header-only consumption

   Required for any future Linux-distribution packaging and for the
   CGAL submission's compliance check.  Cross-referenced from
   doc/architecture/dependencies.md.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 20:06:58 +02:00

120 lines
3.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# scripts/quality/multi-compiler.sh
#
# Build and test the fast (non-CGAL) suite against multiple C++
# compilers in sequence. Catches compiler-specific issues:
# * gcc-only extensions accidentally used
# * clang's stricter template-error handling
# * libstdc++ vs libc++ ABI assumptions
#
# Local-only. Each compiler gets its own build-multi-<cc>/ directory.
#
# Usage:
# bash scripts/quality/multi-compiler.sh # auto-detect
# bash scripts/quality/multi-compiler.sh g++ clang++ # specific list
#
# Exit codes:
# 0 every detected/selected compiler builds + tests cleanly
# 1 at least one compiler failed
# 2 fewer than 2 compilers available
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "$ROOT"
# ── Pick compilers ──────────────────────────────────────────────────────────
if [ $# -gt 0 ]; then
COMPILERS=("$@")
else
COMPILERS=()
for cand in g++ g++-13 g++-12 g++-11 clang++ clang++-17 clang++-16 clang++-15; do
if command -v "$cand" >/dev/null 2>&1; then
COMPILERS+=("$cand")
fi
done
fi
if [ "${#COMPILERS[@]}" -lt 1 ]; then
echo "FAIL: no C++ compilers detected. Install gcc and/or clang." >&2
exit 2
fi
echo "========================================"
echo " Multi-compiler build matrix"
echo " compilers: ${COMPILERS[*]}"
echo "========================================"
echo
# De-duplicate by resolving each to its absolute path.
declare -a UNIQ_BINS=()
declare -a UNIQ_NAMES=()
seen=""
for cc in "${COMPILERS[@]}"; do
if ! command -v "$cc" >/dev/null 2>&1; then
echo " skip $cc (not in PATH)"
continue
fi
full="$(command -v "$cc")"
if echo "$seen" | grep -qx "$full"; then
continue
fi
seen="$seen
$full"
UNIQ_BINS+=("$full")
# Use a sanitised name for the build dir (replace + and / etc.).
safe="$(echo "$cc" | sed 's|[/+]|_|g')"
UNIQ_NAMES+=("$safe")
done
if [ "${#UNIQ_BINS[@]}" -lt 2 ]; then
echo "WARNING: only ${#UNIQ_BINS[@]} unique compiler(s) — matrix is degenerate."
echo " (continuing anyway; install a second toolchain for full coverage)"
fi
# ── Run each ────────────────────────────────────────────────────────────────
overall=0
i=0
for cc in "${UNIQ_BINS[@]}"; do
name="${UNIQ_NAMES[$i]}"
i=$((i + 1))
build="build-multi-$name"
echo
echo "── [$i/${#UNIQ_BINS[@]}] $name ─────────────────────"
echo " bin: $cc"
echo " build: $build"
if ! cmake -S code -B "$build" \
-DCMAKE_CXX_COMPILER="$cc" \
-DCMAKE_BUILD_TYPE=Release \
-Wno-dev >/dev/null 2>&1; then
echo " CONFIGURE FAILED"
overall=1
continue
fi
if ! nice -n 19 cmake --build "$build" --target conformallab_tests \
-j"$(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 2)" \
>"$build/build.log" 2>&1; then
echo " BUILD FAILED — see $build/build.log"
overall=1
continue
fi
if ! ( cd "$build" && ctest -E "^cgal\." --output-on-failure >"test.log" 2>&1 ); then
echo " TESTS FAILED — see $build/test.log"
overall=1
continue
fi
pass=$(grep -oE "tests passed.*out of [0-9]+" "$build/test.log" | head -1)
echo " OK ($pass)"
done
echo
if [ $overall -eq 0 ]; then
echo "OK: every selected compiler built + passed the fast test suite."
else
echo "FAIL: at least one compiler did not produce a green test run."
fi
exit $overall