Skip to content

Init CODE_OF_CONDUCT.md #30

Init CODE_OF_CONDUCT.md

Init CODE_OF_CONDUCT.md #30

Workflow file for this run

name: CI
# Full build + test matrix for every push to main and every pull request.
#
# Matrix (6 jobs total):
#
# Windows Release static <- bundled thirdparty on Windows, fast baseline
# Windows Release shared <- validates DLL + import-lib path
# Windows Debug static <- catches debug-only issues (asserts, iterator debug)
# Linux Release static <- system protobuf via apt; flatbuffers + zstd from FetchContent
# Linux Release shared <- validates .so + RPATH install layout
# Linux Debug static <- catches UBsan-friendly issues under Debug asserts
#
# GUI tools (vtx_inspector, vtx_schema_creator) are disabled in CI -- they
# fetch ImGui + GLFW, take ~2x as long to build, and still contain Windows-only
# glue that makes them flaky on Linux. They get tested manually until someone
# ports the INI-based settings persistence to XDG.
#
# The CLI tool (vtx_cli) and all five samples stay ON. `ctest` runs the full
# 187-test suite plus the sample smoke tests registered in tests/CMakeLists.txt.
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
# When a new commit lands on the same PR, cancel the previous CI run.
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ==========================================================================
# clang-format check. Runs on LINES changed by the current PR / push, not
# on the whole file -- 90% of the codebase pre-dates the .clang-format
# file so a strict full-repo check (or even full-file check on any file
# that happens to be touched) would be permanently red. This "diff gate"
# catches new formatting regressions without requiring a one-time style-
# sweep commit. When you're ready to sweep, run locally:
#
# clang-format -i $(find sdk tools samples tests \
# -type f \( -name "*.cpp" -o -name "*.cc" -o -name "*.h" -o -name "*.hpp" \) \
# -not -path "*/generated/*" -not -path "*arena_generated.h" \
# -not -path "*portable-file-dialogs.h")
#
# and commit with --git-blame-ignore-revs to preserve blame.
# ==========================================================================
clang-format:
name: clang-format (changed lines)
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout (with history for diff)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format-15
sudo ln -sf "$(command -v clang-format-15)" /usr/local/bin/clang-format
clang-format --version
- name: clang-format (changed lines only)
run: |
# Diff-only gate: we run clang-format-diff against the unified
# diff between BASE and HEAD so only lines actually modified get
# checked. Checking the whole file would reject legacy files
# (pre .clang-format) that a PR only touched a handful of lines
# of -- that's exactly the sweep we're trying to avoid.
#
# PR: diff against the merge base of the PR. Push: diff against
# the previous commit on the same branch.
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE="origin/${{ github.base_ref }}"
git fetch origin "${{ github.base_ref }}" --depth=1
else
BASE="HEAD~1"
fi
# Scope to .cpp/.cc/.h/.hpp added or modified, excluding vendored
# and generated code.
FILES=$(git diff --name-only --diff-filter=ACM "$BASE" HEAD \
| grep -E '\.(cpp|cc|h|hpp)$' \
| grep -v -E '^(thirdparty/|.*generated/|.*arena_generated\.h$|.*portable-file-dialogs\.h$)' \
|| true)
if [ -z "$FILES" ]; then
echo "No in-scope C++ files changed."
exit 0
fi
echo "Files in scope:"
echo "$FILES"
echo ""
# clang-format-diff-15 ships with the clang-format-15 apt package.
# -p1 strips the a/ b/ prefix that git diff emits.
# -style=file tells it to discover .clang-format in the repo root.
PATCH=$(git diff -U0 "$BASE" HEAD -- $FILES | clang-format-diff-15 -p1 -style=file)
if [ -n "$PATCH" ]; then
echo "::error::Formatting violations on changed lines:"
echo "$PATCH"
echo ""
echo "To fix locally for a given file:"
echo " git diff -U0 $BASE HEAD -- <file> | clang-format-diff-15 -p1 -i"
echo "Or format the whole file (may touch unrelated legacy lines):"
echo " clang-format -i <file>"
exit 1
fi
echo "All changed lines conform to .clang-format."
build-test:
name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
# ---- Windows ------------------------------------------------------
- label: Windows / Release / static
os: windows-latest
build_type: Release
vtx_shared: "OFF"
extra_cmake: -A x64
- label: Windows / Release / shared
os: windows-latest
build_type: Release
vtx_shared: "ON"
extra_cmake: -A x64
- label: Windows / Debug / static
os: windows-latest
build_type: Debug
vtx_shared: "OFF"
extra_cmake: -A x64
# ---- Linux --------------------------------------------------------
- label: Linux / Release / static
os: ubuntu-latest
build_type: Release
vtx_shared: "OFF"
extra_cmake: -DCMAKE_BUILD_TYPE=Release
- label: Linux / Release / shared
os: ubuntu-latest
build_type: Release
vtx_shared: "ON"
extra_cmake: -DCMAKE_BUILD_TYPE=Release
- label: Linux / Debug / static
os: ubuntu-latest
build_type: Debug
vtx_shared: "OFF"
extra_cmake: -DCMAKE_BUILD_TYPE=Debug
- label: Linux / ASan+UBSan / Debug
os: ubuntu-latest
build_type: Debug
vtx_shared: "OFF"
extra_cmake: -DCMAKE_BUILD_TYPE=Debug -DVTX_SANITIZE=address,undefined
sanitizer: "asan_ubsan"
- label: Linux / TSan / Debug
os: ubuntu-latest
build_type: Debug
vtx_shared: "OFF"
extra_cmake: -DCMAKE_BUILD_TYPE=Debug -DVTX_SANITIZE=thread
sanitizer: "tsan"
steps:
- name: Checkout
uses: actions/checkout@v4
# ----------------------------------------------------------------------
# Linux needs protobuf + protoc from apt. FlatBuffers and zstd are
# both built from source through FetchContent -- see
# cmake/VtxDependencies.cmake -- so no libflatbuffers-dev /
# libzstd-dev packages. Windows uses the bundled thirdparty
# binaries (VTX dependency resolver falls back to BUNDLED when no
# vcpkg toolchain is provided).
# ----------------------------------------------------------------------
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
cmake \
g++ \
ninja-build \
protobuf-compiler \
libprotobuf-dev
# ----------------------------------------------------------------------
# TSan's shadow-memory layout breaks on kernels with high ASLR entropy
# (vm.mmap_rnd_bits=32 by default on recent Ubuntu). Pin to 28 for
# sanitizer jobs only. See https://github.com/google/sanitizers/issues/1716
# ----------------------------------------------------------------------
- name: Relax ASLR entropy for sanitizer runtime
if: matrix.sanitizer != ''
run: sudo sysctl -w vm.mmap_rnd_bits=28
# ----------------------------------------------------------------------
# Cache CMake FetchContent output (GoogleTest) so repeat CI runs don't
# re-clone + re-compile gtest. Keyed on every CMakeLists + cmake module
# so any change to the build graph invalidates the cache.
# ----------------------------------------------------------------------
- name: Cache FetchContent
uses: actions/cache@v4
with:
path: build/_deps
key: ${{ matrix.os }}-deps-${{ hashFiles('CMakeLists.txt', 'cmake/*.cmake', 'tests/CMakeLists.txt', 'tools/CMakeLists.txt', 'sdk/src/**/CMakeLists.txt', 'samples/CMakeLists.txt') }}
restore-keys: |
${{ matrix.os }}-deps-
# ----------------------------------------------------------------------
# Configure. GUI tools disabled everywhere for CI speed.
# ----------------------------------------------------------------------
- name: Configure
run: >
cmake -S . -B build
${{ matrix.extra_cmake }}
-DVTX_BUILD_SHARED=${{ matrix.vtx_shared }}
-DBUILD_VTX_INSPECTOR=OFF
-DBUILD_VTX_SCHEMA_CREATOR=OFF
- name: Build
run: cmake --build build --config ${{ matrix.build_type }} --parallel
- name: Test
working-directory: build
env:
# Sanitizer runtime options -- harmless when no sanitizer is active
# (the uninstrumented binary ignores them).
ASAN_OPTIONS: "detect_leaks=1:check_initialization_order=1:strict_init_order=1:abort_on_error=1:symbolize=1"
UBSAN_OPTIONS: "print_stacktrace=1:halt_on_error=1:symbolize=1"
TSAN_OPTIONS: "halt_on_error=1:second_deadlock_stack=1:history_size=7:symbolize=1"
LSAN_OPTIONS: "suppressions=${{ github.workspace }}/tests/sanitizer_suppressions/lsan.supp"
run: ctest --output-on-failure -C ${{ matrix.build_type }} --parallel --timeout 180
# ----------------------------------------------------------------------
# On failure, upload ctest logs + any artefacts the test suite dropped
# under tests/test_output so the dev can inspect what went wrong.
# ----------------------------------------------------------------------
- name: Upload test artefacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: failure-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.vtx_shared }}
path: |
build/Testing/**
build/tests/test_output/**
if-no-files-found: ignore
retention-days: 7