Files
archived-ballistic/.github/workflows/build.yml
Ronald Caesar c6602c1068 github/runner: improve build.yml
- Add Lint job to reject bad code.
- Add Address Sanatizers.
- Add Test Suite verification.
- Add Static Analysis

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 22:47:30 -04:00

149 lines
5.0 KiB
YAML

name: CI
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
BUILD_DIR: ${{ github.workspace }}/build
jobs:
Lint:
name: Standards & Formatting
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y clang-tidy-18 cmake ninja-build libclang-18-dev libcmark-dev pkg-config
- name: Generate Compilation Database
run: |
ARCH_TRIPLET=$(gcc -dumpmachine)
cmake -S . -B ${{ env.BUILD_DIR }} -G Ninja \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_C_COMPILER=clang-18 \
-DCMAKE_PREFIX_PATH="/usr/lib/llvm-18;/usr/lib/$ARCH_TRIPLET"
- name: Generate Source Headers
run: cmake --build ${{ env.BUILD_DIR }} --target Ballistic --parallel $(nproc)
- name: Run Clang-Tidy
working-directory: ${{ github.workspace }}
run: |
find src include -name "*.[ch]" -not -name "decoder_table_gen.*" | xargs clang-tidy-18 -p ${{ env.BUILD_DIR }} \
--checks='-*,clang-diagnostic-*,bugprone-*,-bugprone-easily-swappable-parameters,-bugprone-reserved-identifier' \
--warnings-as-errors=*
Build:
name: ${{ matrix.os }} / ${{ matrix.type }}
needs: Lint
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-latest, macos-14]
type: [Debug, Release]
include:
- os: ubuntu-24.04
cc: clang-18
cxx: clang++-18
flags_debug: "-fsanitize=address,undefined -fno-omit-frame-pointer"
deps_cmd: sudo apt-get update && sudo apt-get install -y ninja-build ccache clang-18 libclang-18-dev libcmark-dev pkg-config
- os: windows-latest
cc: clang-cl
cxx: clang-cl
flags_debug: "/Zi /Od"
deps_cmd: choco install ninja ccache
- os: macos-14
cc: $(brew --prefix llvm@18)/bin/clang
cxx: $(brew --prefix llvm@18)/bin/clang++
flags_debug: "-fsanitize=address,undefined"
deps_cmd: brew install ninja ccache cmark llvm@18
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 1
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install System Dependencies
shell: bash
run: ${{ matrix.deps_cmd }}
- name: Setup Compiler Cache
uses: actions/cache@v4
with:
path: |
${{ runner.os == 'Windows' && '~/AppData/Local/ccache' || '~/.ccache' }}
key: ${{ runner.os }}-${{ matrix.type }}-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.type }}-
- name: Configure CMake
shell: bash
run: |
EXTRA_FLAGS=""
if [ "${{ matrix.type }}" == "Debug" ]; then
EXTRA_FLAGS="${{ matrix.flags_debug }}"
fi
SEARCH_PATH=""
if [ "$RUNNER_OS" == "Linux" ]; then
SEARCH_PATH="/usr/lib/llvm-18;/usr/lib/$(gcc -dumpmachine)"
elif [ "$RUNNER_OS" == "macOS" ]; then
SEARCH_PATH="$(brew --prefix llvm@18);$(brew --prefix cmark)"
fi
export CCACHE_DIR=${{ runner.os == 'Windows' && '~/AppData/Local/ccache' || '~/.ccache' }}
export CCACHE_MAXSIZE=500M
cmake -G Ninja -B ${{ env.BUILD_DIR }} \
-DCMAKE_BUILD_TYPE=${{ matrix.type }} \
-DCMAKE_C_COMPILER="${{ matrix.cc }}" \
-DCMAKE_CXX_COMPILER="${{ matrix.cxx }}" \
-DCMAKE_C_FLAGS="$EXTRA_FLAGS" \
-DCMAKE_CXX_FLAGS="$EXTRA_FLAGS" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_PREFIX_PATH="$SEARCH_PATH" \
-DBALLISTIC_ENABLE_BUILD_TESTS=ON \
-DBALLISTIC_ENABLE_LINK_TIME_OPTIMIZATION=${{ matrix.type == 'Release' && 'ON' || 'OFF' }}
- name: Build Project & Docs
run: cmake --build ${{ env.BUILD_DIR }} --config ${{ matrix.type }} --target all doc --parallel 4
- name: Run Test Suite
working-directory: ${{ env.BUILD_DIR }}
run: ctest -C ${{ matrix.type }} --output-on-failure
- name: Upload Artifacts
if: matrix.type == 'Release'
uses: actions/upload-artifact@v4
with:
name: ballistic-tools-${{ matrix.os }}
path: |
${{ env.BUILD_DIR }}/ballistic_cli*
${{ env.BUILD_DIR }}/decoder_cli*
${{ env.BUILD_DIR }}/*.exe
if-no-files-found: ignore