Enhance CI workflow by adding vcpkg caching and conditional steps for… #67
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
| name: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-and-test: | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| triplet: x64-linux | |
| build_type: Release | |
| - os: ubuntu-latest | |
| triplet: x64-linux | |
| build_type: Debug | |
| - os: ubuntu-24.04-arm | |
| triplet: arm64-linux | |
| build_type: Release | |
| - os: ubuntu-24.04-arm | |
| triplet: arm64-linux | |
| build_type: Debug | |
| - os: windows-latest | |
| triplet: x64-windows | |
| build_type: Release | |
| - os: windows-latest | |
| triplet: x64-windows | |
| build_type: Debug | |
| - os: macos-latest | |
| triplet: arm64-osx | |
| build_type: Release | |
| - os: macos-latest | |
| triplet: arm64-osx | |
| build_type: Debug | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache vcpkg | |
| id: vcpkg-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ${{ github.workspace }}/vcpkg | |
| !${{ github.workspace }}/vcpkg/buildtrees | |
| !${{ github.workspace }}/vcpkg/packages | |
| !${{ github.workspace }}/vcpkg/downloads | |
| key: vcpkg-${{ runner.os }}-${{ matrix.triplet }}-2025.12.12-${{ hashFiles('.github/workflows/ci.yml') }} | |
| restore-keys: vcpkg-${{ runner.os }}-${{ matrix.triplet }}-2025.12.12- | |
| - name: Setup vcpkg (using git clone) | |
| if: steps.vcpkg-cache.outputs.cache-hit != 'true' | |
| run: | | |
| git clone https://github.com/Microsoft/vcpkg.git ${{ github.workspace }}/vcpkg | |
| cd ${{ github.workspace }}/vcpkg | |
| git checkout 2025.12.12 | |
| - name: Bootstrap vcpkg (Windows) | |
| if: runner.os == 'Windows' && steps.vcpkg-cache.outputs.cache-hit != 'true' | |
| run: | | |
| cd ${{ github.workspace }}/vcpkg | |
| .\bootstrap-vcpkg.bat | |
| shell: pwsh | |
| - name: Bootstrap vcpkg (Linux/macOS) | |
| if: runner.os != 'Windows' && steps.vcpkg-cache.outputs.cache-hit != 'true' | |
| run: | | |
| cd ${{ github.workspace }}/vcpkg | |
| ./bootstrap-vcpkg.sh | |
| - name: Setup GCC 14 (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-14 g++-14 | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 | |
| sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100 | |
| gcc --version | |
| g++ --version | |
| - name: Install vcpkg dependencies | |
| if: steps.vcpkg-cache.outputs.cache-hit != 'true' | |
| env: | |
| VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }} | |
| run: | | |
| ${{ github.workspace }}/vcpkg/vcpkg install boost-asio boost-beast boost-context boost-system openssl nlohmann-json gtest | |
| - name: Configure CMake | |
| run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_PREFIX_PATH="${{ github.workspace }}/vcpkg/installed/${{ matrix.triplet }}" | |
| - name: Build | |
| run: cmake --build build --config ${{ matrix.build_type }} | |
| - name: Run Tests | |
| working-directory: build | |
| run: ctest -C ${{ matrix.build_type }} --output-on-failure |