ci: install full Vix SDK system dependencies #4
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 | |
| - dev | |
| - release/** | |
| pull_request: | |
| branches: | |
| - main | |
| - dev | |
| - release/** | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: rix-auth-ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| VIX_VERSION: v2.6.1 | |
| BUILD_JOBS: 2 | |
| jobs: | |
| build-test-install: | |
| name: ${{ matrix.os }} / ${{ matrix.build_type }} / tests=${{ matrix.tests }} / examples=${{ matrix.examples }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04 | |
| build_type: Debug | |
| tests: ON | |
| examples: OFF | |
| - os: ubuntu-24.04 | |
| build_type: Release | |
| tests: ON | |
| examples: ON | |
| - os: macos-14 | |
| build_type: Release | |
| tests: ON | |
| examples: ON | |
| - os: windows-2022 | |
| build_type: Release | |
| tests: ON | |
| examples: OFF | |
| steps: | |
| - name: Checkout rix/auth | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup CMake and Ninja | |
| uses: lukka/get-cmake@latest | |
| - name: Setup MSVC | |
| if: runner.os == 'Windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Install Windows dependencies | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $ErrorActionPreference = "Stop" | |
| choco install pkgconfiglite -y | |
| git clone https://github.com/microsoft/vcpkg "$env:GITHUB_WORKSPACE/vcpkg" | |
| & "$env:GITHUB_WORKSPACE/vcpkg/bootstrap-vcpkg.bat" | |
| & "$env:GITHUB_WORKSPACE/vcpkg/vcpkg.exe" install ` | |
| fmt:x64-windows ` | |
| spdlog:x64-windows ` | |
| nlohmann-json:x64-windows ` | |
| openssl:x64-windows ` | |
| zlib:x64-windows ` | |
| brotli:x64-windows ` | |
| sqlite3:x64-windows ` | |
| libmysql:x64-windows ` | |
| sdl2:x64-windows ` | |
| sdl2-image:x64-windows ` | |
| gtest:x64-windows | |
| "VCPKG_ROOT=$env:GITHUB_WORKSPACE/vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| "CMAKE_TOOLCHAIN_FILE=$env:GITHUB_WORKSPACE/vcpkg/scripts/buildsystems/vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Install Linux dependencies | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| sudo apt-get update | |
| sudo apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| cmake \ | |
| ninja-build \ | |
| git \ | |
| curl \ | |
| ca-certificates \ | |
| tar \ | |
| zip \ | |
| unzip \ | |
| pkg-config \ | |
| libasio-dev \ | |
| libssl-dev \ | |
| zlib1g-dev \ | |
| libbrotli-dev \ | |
| libsqlite3-dev \ | |
| nlohmann-json3-dev \ | |
| libfmt-dev \ | |
| libspdlog-dev \ | |
| libmysqlcppconn-dev \ | |
| libsdl2-dev \ | |
| libsdl2-image-dev \ | |
| libgl1-mesa-dev \ | |
| libgtest-dev | |
| - name: Install macOS dependencies | |
| if: runner.os == 'macOS' | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| brew update | |
| brew install \ | |
| cmake \ | |
| ninja \ | |
| git \ | |
| curl \ | |
| pkg-config \ | |
| openssl@3 \ | |
| zlib \ | |
| brotli \ | |
| sqlite \ | |
| nlohmann-json \ | |
| spdlog \ | |
| fmt \ | |
| mysql-client \ | |
| sdl2 \ | |
| sdl2_image \ | |
| googletest | |
| - name: Clean workspace | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| rm -rf \ | |
| build \ | |
| install \ | |
| smoke-rix-auth \ | |
| logs | |
| - name: Install Vix SDK Unix | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| curl -fsSL https://vixcpp.com/install.sh | VIX_VERSION="${VIX_VERSION}" VIX_INSTALL_KIND=sdk sh | |
| test -f "$HOME/.local/lib/cmake/Vix/VixConfig.cmake" | |
| test -f "$HOME/.local/include/vix.hpp" | |
| echo "VIX_PREFIX=$HOME/.local" >> "$GITHUB_ENV" | |
| - name: Install Vix SDK Windows | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $ErrorActionPreference = "Stop" | |
| $vixPrefix = "$env:GITHUB_WORKSPACE/deps/vix-sdk" | |
| $asset = "vix-sdk-windows-x86_64.zip" | |
| $url = "https://github.com/vixcpp/vix/releases/download/$env:VIX_VERSION/$asset" | |
| New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE/deps" | Out-Null | |
| Invoke-WebRequest -Uri "$url" -OutFile "$asset" | |
| New-Item -ItemType Directory -Force -Path "$vixPrefix" | Out-Null | |
| Expand-Archive -Path "$asset" -DestinationPath "$vixPrefix" -Force | |
| if (!(Test-Path "$vixPrefix/lib/cmake/Vix/VixConfig.cmake")) { | |
| Write-Host "VixConfig.cmake not found in SDK" | |
| Get-ChildItem -Recurse "$vixPrefix" | Select-Object FullName | |
| exit 1 | |
| } | |
| if (!(Test-Path "$vixPrefix/include/vix.hpp")) { | |
| Write-Host "vix.hpp not found in SDK" | |
| Get-ChildItem -Recurse "$vixPrefix" | Select-Object FullName | |
| exit 1 | |
| } | |
| "VIX_PREFIX=$vixPrefix" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Show Vix SDK prefix | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| echo "VIX_PREFIX=$VIX_PREFIX" | |
| test -n "$VIX_PREFIX" | |
| test -f "$VIX_PREFIX/lib/cmake/Vix/VixConfig.cmake" | |
| test -f "$VIX_PREFIX/include/vix.hpp" | |
| - name: Configure rix/auth | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| CMAKE_ARGS=( | |
| -S . -B build -G Ninja | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
| "-DCMAKE_PREFIX_PATH=$VIX_PREFIX" | |
| -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" | |
| -DRIX_AUTH_BUILD_TESTS=${{ matrix.tests }} | |
| -DRIX_AUTH_BUILD_EXAMPLES=${{ matrix.examples }} | |
| -DRIX_AUTH_INSTALL=ON | |
| -DRIX_AUTH_ENABLE_LOCAL_DEPS=OFF | |
| ) | |
| if [ "${{ runner.os }}" = "Windows" ]; then | |
| CMAKE_ARGS+=( | |
| "-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" | |
| -DVCPKG_TARGET_TRIPLET=x64-windows | |
| ) | |
| fi | |
| cmake "${CMAKE_ARGS[@]}" | |
| - name: Build rix/auth | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| cmake --build build --config ${{ matrix.build_type }} -j"${BUILD_JOBS}" | |
| - name: Run rix/auth tests | |
| if: matrix.tests == 'ON' | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| ctest --test-dir build --build-config ${{ matrix.build_type }} --output-on-failure | |
| - name: Install rix/auth | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| cmake --install build --config ${{ matrix.build_type }} | |
| - name: Validate installed rix/auth package tree | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| test -d install/include/rix/auth | |
| test -f install/lib/cmake/rix_auth/RixAuthConfig.cmake | |
| test -f install/lib/cmake/rix_auth/RixAuthConfigVersion.cmake | |
| test -f install/lib/cmake/rix_auth/RixAuthTargets.cmake | |
| find install/include -maxdepth 5 -type f | sort > installed-rix-auth-headers.txt | |
| find install/lib/cmake -maxdepth 5 -type f | sort > installed-rix-auth-cmake.txt | |
| sed -n '1,120p' installed-rix-auth-headers.txt | |
| cat installed-rix-auth-cmake.txt | |
| - name: Smoke test installed rix/auth package | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| rm -rf smoke-rix-auth | |
| mkdir -p smoke-rix-auth | |
| cat > smoke-rix-auth/CMakeLists.txt <<'CMAKE_EOF' | |
| cmake_minimum_required(VERSION 3.20) | |
| project(rix_auth_consumer LANGUAGES CXX) | |
| set(CMAKE_CXX_STANDARD 20) | |
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
| set(CMAKE_CXX_EXTENSIONS OFF) | |
| find_package(RixAuth CONFIG REQUIRED) | |
| add_executable(app main.cpp) | |
| target_link_libraries(app PRIVATE rix::auth) | |
| CMAKE_EOF | |
| cat > smoke-rix-auth/main.cpp <<'CPP_EOF' | |
| #include <rix/auth/AuthConfig.hpp> | |
| #include <rix/auth/PasswordHasher.hpp> | |
| int main() | |
| { | |
| rixlib::auth::AuthConfig config; | |
| rixlib::auth::PasswordHasher hasher{config}; | |
| auto hash = hasher.hash("correct-password"); | |
| if (hash.failed()) | |
| { | |
| return 1; | |
| } | |
| if (!hasher.verify("correct-password", hash.value())) | |
| { | |
| return 2; | |
| } | |
| return 0; | |
| } | |
| CPP_EOF | |
| SMOKE_ARGS=( | |
| -S smoke-rix-auth -B smoke-rix-auth/build -G Ninja | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
| "-DCMAKE_PREFIX_PATH=${{ github.workspace }}/install;$VIX_PREFIX" | |
| ) | |
| if [ "${{ runner.os }}" = "Windows" ]; then | |
| SMOKE_ARGS+=( | |
| "-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" | |
| -DVCPKG_TARGET_TRIPLET=x64-windows | |
| ) | |
| fi | |
| cmake "${SMOKE_ARGS[@]}" | |
| cmake --build smoke-rix-auth/build --config ${{ matrix.build_type }} -j"${BUILD_JOBS}" | |
| if [ "${{ runner.os }}" = "Windows" ]; then | |
| ./smoke-rix-auth/build/app.exe | |
| else | |
| ./smoke-rix-auth/build/app | |
| fi | |
| - name: Collect logs | |
| if: always() | |
| shell: bash | |
| run: | | |
| set +e | |
| OUT="logs/${{ matrix.os }}-${{ matrix.build_type }}" | |
| mkdir -p "$OUT" | |
| echo "runner.os=${{ runner.os }}" > "$OUT/context.txt" | |
| echo "matrix.os=${{ matrix.os }}" >> "$OUT/context.txt" | |
| echo "matrix.build_type=${{ matrix.build_type }}" >> "$OUT/context.txt" | |
| echo "VIX_PREFIX=${VIX_PREFIX:-}" >> "$OUT/context.txt" | |
| for file in \ | |
| build/CMakeCache.txt \ | |
| build/CMakeFiles/CMakeOutput.log \ | |
| build/CMakeFiles/CMakeError.log \ | |
| build/CMakeFiles/CMakeConfigureLog.yaml \ | |
| build/Testing/Temporary/LastTest.log \ | |
| smoke-rix-auth/build/CMakeCache.txt \ | |
| smoke-rix-auth/build/CMakeFiles/CMakeOutput.log \ | |
| smoke-rix-auth/build/CMakeFiles/CMakeError.log | |
| do | |
| if [ -f "$file" ]; then | |
| mkdir -p "$OUT/$(dirname "$file")" | |
| cp -f "$file" "$OUT/$file" | |
| fi | |
| done | |
| find "$OUT" -type f | sort || true | |
| - name: Upload logs on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rix-auth-logs-${{ matrix.os }}-${{ matrix.build_type }} | |
| path: logs/**/* | |
| if-no-files-found: ignore |