add missing include #167
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # .github/workflows/build-linux.yml | |
| # | |
| # SPDX-License-Identifier: MIT | |
| # SPDX-FileCopyrightText: 2026 Jens A. Koch. | |
| # This file is part of fifengine/fifechan. | |
| # | |
| name: "Build on Linux" | |
| on: | |
| - push | |
| - pull_request | |
| # You can manually run this workflow. | |
| - workflow_dispatch | |
| # improve CI concurrency by automatically cancelling outdated jobs | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # --------------------------------------------------------------------------------------- | |
| build: | |
| # --------------------------------------------------------------------------------------- | |
| name: "${{ matrix.config.job_name }}" | |
| runs-on: ${{ matrix.config.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - { | |
| job_name: "Linux | GCC14 | Shared | Release", | |
| cache_key: "linux-gcc14-x64-shared-release", | |
| os: "ubuntu-24.04", | |
| cc: "gcc-14", | |
| cxx: "g++-14", | |
| preset: "gcc14-x64-linux-rel", | |
| build_dir: "out/build/gcc14-x64-linux-rel", | |
| install_dir: "out/install/gcc14-x64-linux-rel", | |
| vcpkg_triplet: "x64-linux", | |
| shared_libs: "ON" | |
| } | |
| - { | |
| job_name: "Linux | GCC14 | Static | Release", | |
| cache_key: "linux-gcc14-x64-static-release", | |
| os: "ubuntu-24.04", | |
| cc: "gcc-14", | |
| cxx: "g++-14", | |
| preset: "gcc14-x64-linux-static-rel", | |
| build_dir: "out/build/gcc14-x64-linux-static-rel", | |
| install_dir: "out/install/gcc14-x64-linux-static-rel", | |
| vcpkg_triplet: "x64-linux-static", | |
| shared_libs: "OFF" | |
| } | |
| - { | |
| job_name: "Linux | GCC14 | Static | Debug", | |
| cache_key: "linux-gcc14-x64-static-debug", | |
| os: "ubuntu-24.04", | |
| cc: "gcc-14", | |
| cxx: "g++-14", | |
| preset: "gcc14-x64-linux-static-dbg", | |
| build_dir: "out/build/gcc14-x64-linux-static-dbg", | |
| install_dir: "out/install/gcc14-x64-linux-static-dbg", | |
| vcpkg_triplet: "x64-linux-static", | |
| shared_libs: "OFF" | |
| } | |
| - { | |
| job_name: "Linux | Clang18 | Shared | Release", | |
| cache_key: "linux-clang18-x64-shared-release", | |
| os: "ubuntu-24.04", | |
| cc: "clang-18", | |
| cxx: "clang++-18", | |
| preset: "clang18-x64-linux-rel", | |
| build_dir: "out/build/clang18-x64-linux-rel", | |
| install_dir: "out/install/clang18-x64-linux-rel", | |
| vcpkg_triplet: "x64-linux", | |
| shared_libs: "ON" | |
| } | |
| - { | |
| job_name: "Linux | Clang18 | Static | Release", | |
| cache_key: "linux-clang18-x64-static-release", | |
| os: "ubuntu-24.04", | |
| cc: "clang-18", | |
| cxx: "clang++-18", | |
| preset: "clang18-x64-linux-static-rel", | |
| build_dir: "out/build/clang18-x64-linux-static-rel", | |
| install_dir: "out/install/clang18-x64-linux-static-rel", | |
| vcpkg_triplet: "x64-linux-static", | |
| shared_libs: "OFF" | |
| } | |
| env: | |
| VCPKG_DISABLE_METRICS: 1 | |
| VCPKG_FORCE_SYSTEM_BINARIES: 1 | |
| VCPKG_FEATURE_FLAGS: manifests,versions,binarycaching,registries | |
| SOURCE_DIR: ${{ github.workspace }} | |
| VCPKG_ROOT: ${{ github.workspace }}/vcpkg | |
| ARTIFACT_NAME: fifechan | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: 🤘 Checkout Code | |
| uses: actions/checkout@v6 # https://github.com/actions/checkout | |
| - name: 🔽 Install Build Tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| software-properties-common \ | |
| ninja-build \ | |
| cmake \ | |
| jq \ | |
| wget \ | |
| git \ | |
| pkg-config | |
| - name: 🔽 Set Compiler Environment | |
| run: | | |
| echo "CC=${{ matrix.config.cc }}" >> "$GITHUB_ENV" | |
| echo "CXX=${{ matrix.config.cxx }}" >> "$GITHUB_ENV" | |
| - name: Get latest CMake and Ninja | |
| uses: lukka/get-cmake@latest # https://github.com/lukka/get-cmake | |
| with: | |
| cmakeVersion: latest | |
| ninjaVersion: latest | |
| - name: ℹ Show Tool Versions | |
| run: | | |
| ${CC} --version | |
| ${CXX} --version | |
| cmake --version | |
| ninja --version | |
| # Use runner vcpkg when present, otherwise clone vcpkg into workspace. | |
| - name: 🔽 Define VCPKG_ROOT | |
| run: | | |
| if [[ -n "${VCPKG_INSTALLATION_ROOT}" && -d "${VCPKG_INSTALLATION_ROOT}" ]]; then | |
| echo "VCPKG_ROOT=${VCPKG_INSTALLATION_ROOT}" >> "$GITHUB_ENV" | |
| else | |
| echo "VCPKG_ROOT=${GITHUB_WORKSPACE}/vcpkg" >> "$GITHUB_ENV" | |
| fi | |
| - name: 🎯 Setup Package Cache (vcpkg) | |
| id: cache-vcpkg | |
| uses: actions/cache@v5 # https://github.com/actions/cache | |
| with: | |
| path: | | |
| ${{ env.VCPKG_ROOT }}/packages | |
| ~/.cache/vcpkg/archives | |
| key: cache-vcpkg-${{ matrix.config.cache_key }}-${{ github.ref }} | |
| restore-keys: | | |
| cache-vcpkg-${{ matrix.config.cache_key }}-${{ github.ref }} | |
| cache-vcpkg-${{ matrix.config.cache_key }} | |
| - name: 🔽 Clone VCPKG (if missing) | |
| run: | | |
| if [[ ! -d "${VCPKG_ROOT}" ]]; then | |
| git clone https://github.com/microsoft/vcpkg.git "${VCPKG_ROOT}" | |
| fi | |
| - name: 🔽 Update VCPKG (latest TAG) | |
| #if: steps.cache-vcpkg.outputs.cache-hit != 'true' | |
| run: | | |
| cd "${VCPKG_ROOT}" | |
| git fetch --tags --force | |
| # GitHub-hosted runner vcpkg can contain local edits; stash to allow checkout. | |
| if [[ -n "$(git status --porcelain)" ]]; then | |
| git stash push --include-untracked --message "ci-temp-before-tag-checkout" | |
| fi | |
| LATEST_VCPKG_TAG="$(git for-each-ref --sort=-creatordate --format='%(refname:short)' refs/tags | head -n 1)" | |
| if [[ -z "${LATEST_VCPKG_TAG}" ]]; then | |
| echo "Failed to resolve latest vcpkg tag" >&2 | |
| exit 1 | |
| fi | |
| git checkout "${LATEST_VCPKG_TAG}" | |
| - name: 🛠️ Setup VCPKG | |
| if: steps.cache-vcpkg.outputs.cache-hit != 'true' | |
| run: | | |
| "${VCPKG_ROOT}/bootstrap-vcpkg.sh" | |
| "${VCPKG_ROOT}/vcpkg" integrate install | |
| - name: 🛠️ CMake ➔ Configure (Preset) | |
| run: | | |
| cmake --preset "${{ matrix.config.preset }}" | |
| - name: 🙏 CMake ➔ Build | |
| run: | | |
| cmake --build "${{ matrix.config.build_dir }}" | |
| - name: 📦 CMake ➔ Install | |
| run: | | |
| cmake --install "${{ matrix.config.build_dir }}" \ | |
| --prefix "${{ matrix.config.install_dir }}" \ | |
| --verbose | |
| - name: 🧪 CTest ➔ Run Tests | |
| run: | | |
| ctest \ | |
| --test-dir "${{ matrix.config.build_dir }}" \ | |
| --output-on-failure | |
| - name: ❔ CHECK folders, to see if everything is present (after building) | |
| run: | | |
| find "${{ matrix.config.install_dir }}" -type f | sort | |
| # Build Artifact Name: fifechan-1.2.3-0cda6a2-clang18-x64-static | |
| # Scheme for CI artifacts: $NAME-$VERSION-$SHORT_HASH-$COMPILER_SHORT-$TRIPLET | |
| # '-release' is removed from cache_key, e.g.: linux-gcc14-x64-shared-release => gcc14-x64-shared | |
| - name: ✏ Build Artifact Name | |
| run: | | |
| NAME='fifechan' | |
| VERSION="$(jq -r .version vcpkg.json)" | |
| SHORT_HASH="${GITHUB_SHA::7}" | |
| SUFFIX="${{ matrix.config.cache_key }}" | |
| SUFFIX="${SUFFIX#linux-}" | |
| SUFFIX="${SUFFIX%-release}" | |
| ARTIFACT_NAME="${NAME}-${VERSION}-${SHORT_HASH}-${SUFFIX}" | |
| echo "ARTIFACT_NAME: ${ARTIFACT_NAME}" | |
| echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> "$GITHUB_ENV" | |
| echo "VERSION=${VERSION}" >> "$GITHUB_ENV" | |
| - name: 🔼 Upload Build Artifact | |
| uses: actions/upload-artifact@v7 # https://github.com/actions/upload-artifact | |
| if: always() | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }} | |
| path: ${{ matrix.config.install_dir }}/**/* | |
| # --------------------------------------------------------------------------------------- | |
| build-on-container: | |
| # --------------------------------------------------------------------------------------- | |
| name: ${{ matrix.config.job_name }} | |
| # Note on "image_version": | |
| # - The image versions are based on tags of the https://github.com/jakoch/cpp-devbox repo. | |
| # - Use rolling tags (e.g., "trixie-latest") for bleeding-edge updates, | |
| # but expect potential instability due to changes in the included software. | |
| # - Pin to a fixed version (e.g., "trixie-20260329") for reproducible and stable builds. | |
| runs-on: ubuntu-latest | |
| container: ghcr.io/jakoch/cpp-devbox:${{ matrix.config.image_version }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - { | |
| job_name: "Linux | Clang20 | Release", | |
| image_version: "bookworm-latest", | |
| preset: "clang20-x64-linux-rel", | |
| artifact_suffix: "clang20-x64" | |
| } | |
| - { | |
| job_name: "Linux | Clang22 | Release", | |
| image_version: "trixie-latest", | |
| preset: "clang22-x64-linux-rel", | |
| artifact_suffix: "clang22-x64" | |
| } | |
| - { | |
| job_name: "Linux | Clang22 | Debug", | |
| image_version: "trixie-latest", | |
| preset: "clang22-x64-linux-dbg", | |
| artifact_suffix: "clang22-x64-dbg" | |
| } | |
| - { | |
| job_name: "Linux | Clang22 | Coverage", | |
| image_version: "trixie-latest", | |
| preset: "clang22-x64-linux-dbg-cov", | |
| artifact_suffix: "clang22-x64-cov" | |
| } | |
| permissions: | |
| # Required for codecov upload with "use_oidc: true" | |
| # See https://github.com/codecov/codecov-action?tab=readme-ov-file#using-oidc | |
| id-token: write | |
| env: | |
| VCPKG_DISABLE_METRICS: 1 | |
| VCPKG_FORCE_SYSTEM_BINARIES: 1 | |
| VCPKG_FEATURE_FLAGS: manifests,versions,binarycaching,registries | |
| SOURCE_DIR: ${{ github.workspace }} | |
| VCPKG_ROOT: /opt/vcpkg | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: 🤘 Checkout Code | |
| uses: actions/checkout@v6 # https://github.com/actions/checkout | |
| - name: ℹ Show Tool Versions | |
| run: | | |
| ${CC} --version | |
| ${CXX} --version | |
| cmake --version | |
| ninja --version | |
| # Derive build/install directories directly from the preset name. | |
| - name: ✏ Define Build Paths | |
| run: | | |
| echo "BUILD_DIR=out/build/${{ matrix.config.preset }}" >> "$GITHUB_ENV" | |
| echo "INSTALL_DIR=out/install/${{ matrix.config.preset }}" >> "$GITHUB_ENV" | |
| # Prefer container-provided vcpkg at /opt/vcpkg. | |
| - name: 🔽 Define VCPKG_ROOT | |
| run: | | |
| if [[ -d "/opt/vcpkg" ]]; then | |
| echo "VCPKG_ROOT=/opt/vcpkg" >> "$GITHUB_ENV" | |
| elif [[ -n "${VCPKG_INSTALLATION_ROOT}" && -d "${VCPKG_INSTALLATION_ROOT}" ]]; then | |
| echo "VCPKG_ROOT=${VCPKG_INSTALLATION_ROOT}" >> "$GITHUB_ENV" | |
| else | |
| echo "VCPKG_ROOT=${GITHUB_WORKSPACE}/vcpkg" >> "$GITHUB_ENV" | |
| fi | |
| - name: 🎯 Setup Package Cache (vcpkg) | |
| id: cache-vcpkg | |
| uses: actions/cache@v5 # https://github.com/actions/cache | |
| with: | |
| path: | | |
| ${{ env.VCPKG_ROOT }}/packages | |
| ~/.cache/vcpkg/archives | |
| key: cache-vcpkg-container-${{ matrix.config.preset }}-${{ github.ref }} | |
| restore-keys: | | |
| cache-vcpkg-container-${{ matrix.config.preset }}-${{ github.ref }} | |
| cache-vcpkg-container-${{ matrix.config.preset }} | |
| - name: 🔽 Clone VCPKG (if missing) | |
| run: | | |
| if [[ ! -d "${VCPKG_ROOT}" ]]; then | |
| git clone https://github.com/microsoft/vcpkg.git "${VCPKG_ROOT}" | |
| fi | |
| - name: 🔽 Update VCPKG (latest TAG) | |
| #if: steps.cache-vcpkg.outputs.cache-hit != 'true' | |
| run: | | |
| cd "${VCPKG_ROOT}" | |
| git fetch --tags --force | |
| # GitHub-hosted runner vcpkg can contain local edits; stash to allow checkout. | |
| if [[ -n "$(git status --porcelain)" ]]; then | |
| git stash push --include-untracked --message "ci-temp-before-tag-checkout" | |
| fi | |
| LATEST_VCPKG_TAG="$(git for-each-ref --sort=-creatordate --format='%(refname:short)' refs/tags | head -n 1)" | |
| if [[ -z "${LATEST_VCPKG_TAG}" ]]; then | |
| echo "Failed to resolve latest vcpkg tag" >&2 | |
| exit 1 | |
| fi | |
| git checkout "${LATEST_VCPKG_TAG}" | |
| - name: 🛠️ Setup VCPKG | |
| if: steps.cache-vcpkg.outputs.cache-hit != 'true' | |
| run: | | |
| "${VCPKG_ROOT}/bootstrap-vcpkg.sh" | |
| "${VCPKG_ROOT}/vcpkg" integrate install | |
| - name: 🛠️ CMake ➔ Configure (Preset) | |
| run: | | |
| cmake --preset "${{ matrix.config.preset }}" | |
| - name: 🙏 CMake ➔ Build | |
| run: | | |
| cmake --build "${BUILD_DIR}" | |
| - name: 📦 CMake ➔ Install | |
| run: | | |
| cmake --install "${BUILD_DIR}" \ | |
| --prefix "${INSTALL_DIR}" \ | |
| --verbose | |
| - name: ⚙️ Prepare Coverage Environment | |
| if: ${{ matrix.config.preset == 'clang22-x64-linux-dbg-cov' }} | |
| run: | | |
| mkdir -p "${BUILD_DIR}/coverage" | |
| echo "LLVM_PROFILE_FILE=${GITHUB_WORKSPACE}/${BUILD_DIR}/coverage/%p.profraw" >> "$GITHUB_ENV" | |
| - name: 🧪 CTest ➔ Run Tests | |
| run: | | |
| ctest \ | |
| --test-dir "${BUILD_DIR}" \ | |
| --output-on-failure | |
| - name: ❔ CHECK folders, to see if everything is present (after building) | |
| run: | | |
| find "${INSTALL_DIR}" -type f | sort | |
| - name: ✏ Build Artifact Name | |
| run: | | |
| NAME='fifechan' | |
| VERSION="$(jq -r .version vcpkg.json)" | |
| SHORT_HASH="${GITHUB_SHA::7}" | |
| SUFFIX="${{ matrix.config.artifact_suffix }}" | |
| ARTIFACT_NAME="${NAME}-${VERSION}-${SHORT_HASH}-${SUFFIX}" | |
| echo "ARTIFACT_NAME: ${ARTIFACT_NAME}" | |
| echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> "$GITHUB_ENV" | |
| echo "VERSION=${VERSION}" >> "$GITHUB_ENV" | |
| - name: 🔼 Upload Build Artifact | |
| uses: actions/upload-artifact@v7 # https://github.com/actions/upload-artifact | |
| if: ${{ always() && matrix.config.preset != 'clang22-x64-linux-dbg-cov' && github.event_name != 'pull_request' }} | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }} | |
| path: ${{ env.INSTALL_DIR }}/**/* | |
| # ------------------------------------------------------------------------ | |
| # Code Coverage Steps (only for "clang22-x64-linux-dbg-cov" preset) | |
| # ------------------------------------------------------------------------ | |
| - name: 🧾 Merge Coverage Data | |
| if: ${{ matrix.config.preset == 'clang22-x64-linux-dbg-cov' }} | |
| run: | | |
| set -euo pipefail | |
| echo "Merging .profraw files from ${{ env.BUILD_DIR }}/coverage" | |
| shopt -s nullglob | |
| profraw_files=("${{ env.BUILD_DIR }}/coverage"/*.profraw) | |
| if [ ${#profraw_files[@]} -eq 0 ]; then | |
| echo "::warning::No .profraw files found. Did tests run with LLVM_PROFILE_FILE set?" | |
| exit 0 | |
| fi | |
| llvm-profdata merge -sparse "${profraw_files[@]}" -o "${{ env.BUILD_DIR }}/coverage/coverage.profdata" | |
| - name: 📊 Generate Coverage Reports (lcov + HTML) | |
| if: ${{ matrix.config.preset == 'clang22-x64-linux-dbg-cov' }} | |
| env: | |
| COV_EXCLUDE_REGEX: '(vcpkg_installed|build|tests)' | |
| run: | | |
| set -euo pipefail | |
| # Find all instrumented test binaries (ending with "_test" or "_tests") in the build directory. | |
| mapfile -t BINARIES < <(find "${{ env.BUILD_DIR }}" -maxdepth 3 -type f -executable \( -name "*_test" -o -name "*_tests" \) -print || true) | |
| if [ ${#BINARIES[@]} -eq 0 ]; then | |
| echo "::warning::No instrumented binaries found. Skipping llvm-cov." | |
| exit 0 | |
| fi | |
| # Export LCOV report | |
| llvm-cov export -format=lcov -instr-profile="${{ env.BUILD_DIR }}/coverage/coverage.profdata" \ | |
| "${BINARIES[@]}" --ignore-filename-regex="${COV_EXCLUDE_REGEX}" \ | |
| > "${{ env.BUILD_DIR }}/coverage/coverage.lcov" | |
| # Generate HTML report | |
| #llvm-cov show -format=html -instr-profile="${{ env.BUILD_DIR }}/coverage/coverage.profdata" \ | |
| # "${BINARIES[@]}" --ignore-filename-regex="${COV_EXCLUDE_REGEX}" \ | |
| # -o "${{ env.BUILD_DIR }}/coverage/html" \ | |
| # Print summary to CI logs for visibility | |
| llvm-cov report -instr-profile="${{ env.BUILD_DIR }}/coverage/coverage.profdata" \ | |
| "${BINARIES[@]}" --ignore-filename-regex="${COV_EXCLUDE_REGEX}" | |
| - name: 🔼 Upload Coverage Artifact | |
| if: ${{ matrix.config.preset == 'clang22-x64-linux-dbg-cov' && github.event_name != 'pull_request' }} | |
| uses: actions/upload-artifact@v7 # https://github.com/actions/upload-artifact | |
| with: | |
| name: Coverage-Report-${{ matrix.config.preset }} | |
| path: ${{ env.BUILD_DIR }}/coverage/** | |
| - name: 📦 Upload Coverage to Codecov | |
| if: ${{ matrix.config.preset == 'clang22-x64-linux-dbg-cov' && github.event_name != 'pull_request' }} | |
| uses: codecov/codecov-action@v6 # https://github.com/codecov/codecov-action | |
| with: | |
| files: ${{ env.BUILD_DIR }}/coverage/coverage.lcov | |
| disable_search: true | |
| name: ${{ matrix.config.preset }} | |
| flags: ${{ matrix.config.preset }} | |
| use_oidc: true | |
| fail_ci_if_error: true |