mirror of
https://github.com/pound-emu/ballistic.git
synced 2026-01-31 01:15:21 +01:00
The tests take 5-8 minutes to run in debug builds, which is ridiculous. Signed-off-by: Ronald Caesar <github43132@proton.me>
156 lines
5.1 KiB
YAML
156 lines
5.1 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 -Wno-unknown-argument"
|
|
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
|
|
# Prevent bash from converting /Zi and /Od to file paths.
|
|
env:
|
|
MSYS_NO_PATHCONV: 1
|
|
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 build \
|
|
-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
|
|
# Disable address sanatizer when building CDoc.
|
|
env:
|
|
ASAN_OPTIONS: detect_leaks=0
|
|
run: cmake --build build --config ${{ matrix.type }} --target all --parallel 4
|
|
|
|
- name: Run Test Suite
|
|
if: matrix.type == 'Release'
|
|
working-directory: build
|
|
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: |
|
|
build/ballistic_cli*
|
|
build/decoder_cli*
|
|
build/*.exe
|
|
if-no-files-found: ignore
|