Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 67 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ env:
BUILD_TYPE: Release

jobs:
# Formatting, changelog, generated sources, Clang build, clang-tidy, the
# full test suite with audit and fault injection, packages, and docs.
# Formatting, changelog, generated sources, Clang build, the full test suite
# with audit and fault injection, packages, and docs. The lint job runs
# clang-tidy on this configuration.
check-extended:
runs-on: ubuntu-24.04

Expand Down Expand Up @@ -76,7 +77,7 @@ jobs:

- name: Run all checks
shell: bash
run: uv run misc/check.py all --build-dir build/check-extended --jobs 4
run: uv run misc/check.py all --build-dir build/check-extended --jobs 4 --skip-lint

- name: Qt/Gist consumer smoke test
shell: bash
Expand All @@ -92,6 +93,69 @@ jobs:
CXX: clang++-22
run: bash .github/ci/cmake-custom-vis-smoke.sh

# clang-tidy on the check-extended configuration, limited to the sources and
# headers that the change touches. The release matrix lints everything.
lint:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
# A pull request checks out its merge commit; the first parent is the base.
fetch-depth: 2

- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39
with:
enable-cache: false

- name: Install LLVM 22 and build dependencies
shell: bash
run: |
curl --fail --location --retry 3 https://apt.llvm.org/llvm-snapshot.gpg.key -o "$RUNNER_TEMP/llvm.asc"
sudo install -m 644 "$RUNNER_TEMP/llvm.asc" /usr/share/keyrings/llvm.asc
echo 'deb [signed-by=/usr/share/keyrings/llvm.asc] https://apt.llvm.org/noble/ llvm-toolchain-noble-22 main' | sudo tee /etc/apt/sources.list.d/llvm.list
# The runner's packages.microsoft.com source has failed apt-get update with 403; no job needs it.
sudo find /etc/apt/sources.list.d -type f -exec grep -q packages.microsoft.com {} \; -delete
# Ubuntu mirrors have answered 503 for minutes; apt backs off between retries.
echo 'Acquire::Retries "10";' | sudo tee /etc/apt/apt.conf.d/80-retries
sudo apt-get update
sudo apt-get install -y clang-22 clang-format-22 clang-tidy-22 clang-tools-22 \
ninja-build libgmp-dev libmpfr-dev qt6-base-dev qt6-base-dev-tools libgl1-mesa-dev

- name: Configure the check-extended build
shell: bash
run: >
cmake -S . -B build/lint -G Ninja
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_C_COMPILER=clang-22 -DCMAKE_CXX_COMPILER=clang++-22
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DGECODE_ENABLE_EXPERIMENTAL=ON -DGECODE_ENABLE_CBS=ON
-DGECODE_ENABLE_AUDIT=ON -DGECODE_ENABLE_FAULT_INJECTION=ON
-DGECODE_ENABLE_QT=ON -DGECODE_ENABLE_GIST=ON -DGECODE_ENABLE_MPFR=ON
-DGECODE_ENABLE_EXAMPLES=ON -DGECODE_REGENERATE_VARIMP=ON

# clang-tidy parses sources, so only the generated headers are built.
- name: Generate variable headers
shell: bash
run: cmake --build build/lint --target gecode-varimp-gen

- name: Lint changed sources
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
BEFORE: ${{ github.event.before }}
run: |
set -euo pipefail
# A new branch, or a force push whose old tip is gone, lints everything.
base=""
if [ "$EVENT_NAME" = pull_request ]; then
base=HEAD^1
elif [[ -n "$BEFORE" && ! "$BEFORE" =~ ^0+$ ]] && git fetch --no-tags --depth=1 origin "$BEFORE"; then
base="$BEFORE"
fi
uv run misc/check.py lint --build-dir build/lint --jobs 4 ${base:+--changed-from "$base"}

# GCC Release build without experimental APIs, plus the installed-package,
# FlatZinc, allocator, and 32-bit smokes.
build-linux:
Expand Down
51 changes: 50 additions & 1 deletion .github/workflows/release-matrix.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Release matrix

# Broader checks for release preparation, or whenever wanted: the standard
# test suite, plus the platforms and build variants that per-PR CI leaves out.
# test suite, clang-tidy on every source, plus the platforms and build variants
# that per-PR CI leaves out.
# It runs on release candidate branches, on pull requests that change it, and
# on demand:
# gh workflow run release-matrix.yml --repo Gecode/gecode --ref <branch>
Expand Down Expand Up @@ -75,6 +76,54 @@ jobs:
GECODE_TEST_BLACKBOX_LOG="$build/gecode-test-blackbox" \
"$build/bin/gecode-test" -tag standard -threads 0

# CI lints only the changed sources. This lints every source in the
# check-extended configuration.
lint-full:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0

- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39
with:
enable-cache: false

- name: Install LLVM 22 and build dependencies
shell: bash
run: |
curl --fail --location --retry 3 https://apt.llvm.org/llvm-snapshot.gpg.key -o "$RUNNER_TEMP/llvm.asc"
sudo install -m 644 "$RUNNER_TEMP/llvm.asc" /usr/share/keyrings/llvm.asc
echo 'deb [signed-by=/usr/share/keyrings/llvm.asc] https://apt.llvm.org/noble/ llvm-toolchain-noble-22 main' | sudo tee /etc/apt/sources.list.d/llvm.list
# The runner's packages.microsoft.com source has failed apt-get update with 403; no job needs it.
sudo find /etc/apt/sources.list.d -type f -exec grep -q packages.microsoft.com {} \; -delete
# Ubuntu mirrors have answered 503 for minutes; apt backs off between retries.
echo 'Acquire::Retries "10";' | sudo tee /etc/apt/apt.conf.d/80-retries
sudo apt-get update
sudo apt-get install -y clang-22 clang-format-22 clang-tidy-22 clang-tools-22 \
ninja-build libgmp-dev libmpfr-dev qt6-base-dev qt6-base-dev-tools libgl1-mesa-dev

- name: Configure the check-extended build
shell: bash
run: >
cmake -S . -B build/lint -G Ninja
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_C_COMPILER=clang-22 -DCMAKE_CXX_COMPILER=clang++-22
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DGECODE_ENABLE_EXPERIMENTAL=ON -DGECODE_ENABLE_CBS=ON
-DGECODE_ENABLE_AUDIT=ON -DGECODE_ENABLE_FAULT_INJECTION=ON
-DGECODE_ENABLE_QT=ON -DGECODE_ENABLE_GIST=ON -DGECODE_ENABLE_MPFR=ON
-DGECODE_ENABLE_EXAMPLES=ON -DGECODE_REGENERATE_VARIMP=ON

# clang-tidy parses sources, so only the generated headers are built.
- name: Generate variable headers
shell: bash
run: cmake --build build/lint --target gecode-varimp-gen

- name: Lint every source
shell: bash
run: uv run misc/check.py lint --build-dir build/lint --jobs 4

build-macos:
runs-on: macos-15

Expand Down
10 changes: 9 additions & 1 deletion docs/code-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ major versions are rejected):
uv run misc/check.py format
uv run misc/check.py format-check
uv run misc/check.py lint --build-dir build/local
uv run misc/check.py lint --build-dir build/local --changed-from origin/main
uv run misc/check.py all --build-dir build/local --jobs 4
```

Expand All @@ -167,12 +168,19 @@ headers, and the owned C++ action ranges inside the generated FlatZinc parser
and lexer, and lists any sources outside the build so disabled modules are
visible. Lint undefines `NDEBUG` so assertions are always analyzed.

With `--changed-from`, lint checks only the sources that differ from the given
commit, and each changed header through one source that includes it; this needs
`clang-scan-deps` 22 (or `CLANG_SCAN_DEPS`). A change to `.clang-tidy` or the
checker lints everything. Per-PR CI lints this way; the release matrix lints
every source.

`all` / `check-extended` runs formatting, lint, changelog and generated-source
freshness checks, build, CTest integrity and enabled fault suites, package
installation and downstream consumer tests, and Doxygen (`1.18.0+`). It needs
LLVM 22, `uv`, Bison 3.8.2, Flex 2.6.4, Ninja, Doxygen 1.18.0+, and a build
with `BUILD_TESTING`, `GECODE_INSTALL`, `GECODE_ENABLE_ALLOCATOR`, search, int,
minimodel, and driver enabled. The full `check-standard` and `check-sweep`
minimodel, and driver enabled. `--skip-lint` leaves linting the build to a
separate lint run. The full `check-standard` and `check-sweep`
suites remain separate targets.

## Clang-tidy check selection
Expand Down
Loading
Loading