ci: switch to commit-message triggers (replace issue_comment)

issue_comment triggers had two problems: Gitea did not reliably fire
them, and the refs/pull/N/head checkout was fragile.  Commit-message
keywords are simpler and guaranteed to work on any push event.

Trigger keywords (add anywhere in the commit message):
  /test-cgal      → CGAL test suite (277 tests, LOW_MEMORY_BUILD)
  /quality-gates  → license/codespell/shellcheck/cgal-conventions
  /docs           → Doxygen build + warning summary
  /links          → Markdown internal link check

test-fast still runs on every push (no keyword needed).

All `issue_comment` event handlers and `refs/pull/N/head` checkouts
removed from all three workflow files.  review/** added to push branch
filters so this PR branch triggers normally.

CLAUDE.md CI table updated.

/test-cgal /quality-gates
This commit is contained in:
Tarik Moussa
2026-05-31 01:14:53 +02:00
parent 018484a94d
commit 7df47c0435
4 changed files with 59 additions and 90 deletions

View File

@@ -1,5 +1,14 @@
name: C++ Tests
# Trigger keywords in commit message (checked via head_commit.message):
# /test-cgal — full CGAL test suite (277 tests, ~5 min build)
# /quality-gates — license, codespell, shellcheck, CGAL conventions
#
# Example commit:
# git commit -m "fix: correct angle formula /test-cgal"
#
# test-fast always runs on every push — it is fast (< 5 s) and cheap.
on:
push:
branches:
@@ -7,15 +16,13 @@ on:
- dev
- "claude/**"
- "feature/**"
- "review/**"
pull_request:
# /test-cgal comment on any PR triggers the CGAL test suite manually.
issue_comment:
types: [created]
# ─────────────────────────────────────────────────────────────────────────────
# Job 1 — test-fast
# Pure-math tests (Clausen, ImLi₂, Hyper-ideal geometry).
# No CGAL, no Boost. Eigen + GTest only. Runs on ALL branches.
# No CGAL, no Boost. Eigen + GTest only. Runs on EVERY push.
# ─────────────────────────────────────────────────────────────────────────────
jobs:
test-fast:
@@ -51,59 +58,32 @@ jobs:
# ─────────────────────────────────────────────────────────────────────────────
# Job 2 — test-cgal
# Full CGAL test suite (Phase 37, 158 tests).
# Runs ONLY on pull requests (not on direct pushes to dev/main).
# Starts only after test-fast succeeds.
#
# Uses -DWITH_CGAL_TESTS=ON (not -DWITH_CGAL=ON) to avoid building
# Viewer/GLFW — the CI container has no wayland-scanner.
# Trigger: include "/test-cgal" anywhere in the commit message.
#
# Boost (libboost-dev) is already present in the container since the image rebuild.
# git commit -m "fix: correct angle formula /test-cgal"
#
# Why keyword-triggered (not automatic on every push):
# The Pi runner (3-4 GB RAM, swap heavily loaded) cannot sustain a
# CGAL build on every WIP commit. Adding the keyword to a commit
# message explicitly signals "this commit is ready for full testing".
#
# LOW_MEMORY_BUILD applies four RAM-saving measures so the build fits in
# a 2000 MB container: -O0, no PCH, unity batch 1, --no-keep-memory.
# See code/tests/cgal/CMakeLists.txt for the full explanation.
# ─────────────────────────────────────────────────────────────────────────────
# ─── CGAL tests: manual trigger via PR comment ───────────────────────────
#
# Trigger: write "/test-cgal" as a comment on any pull request.
#
# Why comment-triggered (not automatic on every PR push):
# The Pi runner has 3-4 GB RAM total with swap constantly loaded.
# Even with LOW_MEMORY_BUILD the CGAL build takes ~5 min and stresses
# the runner. Triggering on every push would queue builds faster than
# the Pi can drain them. A manual trigger gives full control: run the
# 277-test suite when a PR is ready for review, not on every WIP commit.
#
# How it works:
# - `issue_comment` fires on all PR + issue comments.
# - The `if:` condition checks:
# 1. Event is a comment (not a push or PR sync)
# 2. The comment is on a PR (issue.pull_request != null)
# 3. The comment body contains "/test-cgal"
# - The checkout uses refs/pull/N/head to get the PR branch, because
# `issue_comment` does not set GITHUB_REF to the PR branch by default.
#
# LOW_MEMORY_BUILD applies four RAM-saving measures so the build fits in
# 2000 MB: -O0, PCH off, unity batch 1, --no-keep-memory linker.
# See code/tests/cgal/CMakeLists.txt for the full explanation.
test-cgal:
needs: test-fast
if: |
github.event_name == 'issue_comment' &&
github.event.issue.pull_request != null &&
contains(github.event.comment.body, '/test-cgal')
if: contains(github.event.head_commit.message, '/test-cgal')
runs-on: eulernest
container:
image: git.eulernest.eu/conformallab/ci-cpp:latest
# 2000 MB hard limit; 1000 MB swap headroom (memory-swap = RAM + swap).
# Uses ~half of the Pi's 3-4 GB, leaving margin for OS + runner daemon.
# With LOW_MEMORY_BUILD peak per TU is ~150-200 MB → well within limit.
options: "--memory=2000m --memory-swap=3000m"
steps:
# Check out the PR branch, not the default branch.
# issue_comment events set GITHUB_REF to the default branch; we need
# refs/pull/N/head to get the actual PR code.
- uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Configure (LOW_MEMORY_BUILD — -O0, no PCH, unity batch 1)
run: |
@@ -133,44 +113,29 @@ jobs:
echo "CGAL ▸ TOTAL ${total:-0} | PASSED $passed | FAILED ${failed:-0} | SKIPPED ${skipped:-0}"
fi
# ── Structural gate: doc/api/tests.md totals match ctest reality ───
# Single source of truth for test counts (see doc/release-policy.md).
# Reuses the already-built ./build dir via BUILD_DIR env var, so this
# adds ~5 s on top of the existing CGAL job.
- name: Verify test-count consistency (doc/api/tests.md)
run: BUILD_DIR=build bash scripts/check-test-counts.sh
# ── Structural gate: end-to-end smoke (try_it.sh) ──────────────────
# The user-facing quick-start script: configure + build + run the
# full ctest + run the Euclidean example on a bundled mesh. If
# this regresses, README quick-start instructions are broken.
# try_it.sh creates its own build-try/ — accept the ~3 min cost as
# the price of guaranteeing the documented workflow stays working.
- name: End-to-end smoke test (scripts/try_it.sh)
run: bash scripts/try_it.sh
# ─────────────────────────────────────────────────────────────────────────────
# Job 3 — quality-gates (style + convention block)
# Job 3 — quality-gates
#
# Trigger: write "/quality-gates" as a comment on any pull request.
# Trigger: include "/quality-gates" anywhere in the commit message.
#
# Cheap, deterministic checks (~30 s): license headers, CGAL conventions,
# codespell, shellcheck. Runs independently of test-fast when comment-
# triggered (no `needs:` — the caller decides when to invoke it).
# git commit -m "chore: update docs /quality-gates"
#
# Cheap (~30 s): license headers, CGAL conventions, codespell, shellcheck.
# ─────────────────────────────────────────────────────────────────────────────
quality-gates:
if: |
github.event_name == 'issue_comment' &&
github.event.issue.pull_request != null &&
contains(github.event.comment.body, '/quality-gates')
if: contains(github.event.head_commit.message, '/quality-gates')
runs-on: eulernest
container:
image: git.eulernest.eu/conformallab/ci-cpp:latest
steps:
- uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Install codespell + shellcheck (job-local)
run: |