name: CI on: push: # Don't run this workflow when a tag is pushed. branches: - '*' pull_request: env: CARGO_TERM_COLOR: always CMAKE_CONFIG: RelWithDebInfo jobs: rustfmt: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Check formatting run: | cargo fmt -- --version cargo fmt --all -- --check clippy: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Run clippy run: | cargo clippy -- --version cargo clippy --all --all-targets -- -Dwarnings rust: strategy: matrix: target: - os: windows-2025 platform: Win32 triple: i686-pc-windows-msvc architecture: x86 - os: windows-2025 platform: x64 triple: x86_64-pc-windows-msvc architecture: x64 - os: ubuntu-24.04 platform: x86_64 triple: x86_64-unknown-linux-gnu architecture: x64 runs-on: ${{ matrix.target.os }} steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ github.job }}-${{ runner.os }}-${{ matrix.target.architecture }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install Rust i686-pc-windows-msvc target run: rustup target add i686-pc-windows-msvc if: matrix.target.platform == 'Win32' - name: Install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov - name: Prepare test resources shell: pwsh run: | Invoke-WebRequest https://github.com/Ortham/testing-plugins/archive/refs/tags/1.6.2.zip -OutFile testing-plugins-1.6.2.zip Expand-Archive testing-plugins-1.6.2.zip . Move-Item testing-plugins-1.6.2 testing-plugins Remove-Item testing-plugins-1.6.2.zip - name: Set LIBLOOT_REVISION shell: bash run: echo "LIBLOOT_REVISION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Build and run tests with code coverage run: cargo llvm-cov --lcov --output-path lcov.info --target ${{ matrix.target.triple }} - name: Upload code coverage to Coveralls uses: coverallsapp/github-action@v2 if: github.event_name == 'push' cpp: strategy: matrix: target: - os: windows-2025 platform: Win32 triple: i686-pc-windows-msvc architecture: x86 - os: windows-2025 platform: x64 triple: x86_64-pc-windows-msvc architecture: x64 - os: ubuntu-24.04 platform: x86_64 triple: x86_64-unknown-linux-gnu architecture: x64 runs-on: ${{ matrix.target.os }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-python@v5 with: python-version: '3.13' - uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ github.job }}-${{ runner.os }}-${{ matrix.target.architecture }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install Rust i686-pc-windows-msvc target run: rustup target add i686-pc-windows-msvc if: matrix.target.platform == 'Win32' - name: Set LIBLOOT_REVISION shell: bash run: echo "LIBLOOT_REVISION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Get descriptive libloot version id: get-libloot-version shell: bash run: | GIT_DESCRIBE=$(git describe --tags --long --always --abbrev=7) LIBLOOT_DESC_REF=${GIT_DESCRIBE}_${GITHUB_REF#refs/*/} LIBLOOT_SAFE_DESC_REF=${LIBLOOT_DESC_REF//[\/<>\"|]/_} echo "version=$LIBLOOT_SAFE_DESC_REF" >> $GITHUB_OUTPUT - name: Build the C++ wrapper (Linux) working-directory: cpp run: | cmake \ -DCMAKE_BUILD_TYPE=${{ env.CMAKE_CONFIG }} \ -DCPACK_PACKAGE_VERSION="${{ steps.get-libloot-version.outputs.version }}" \ -DCPACK_THREADS=0 \ -DRUST_TARGET="${{ matrix.target.triple }}" \ -B build cmake --build build --parallel if: runner.os == 'Linux' - name: Build the C++ wrapper (Windows) working-directory: cpp run: | cmake -G "Visual Studio 17 2022" ` -A ${{ matrix.target.platform }} ` -DCPACK_PACKAGE_VERSION="${{ steps.get-libloot-version.outputs.version }}" ` -DCPACK_THREADS=0 ` -DRUST_TARGET="${{ matrix.target.triple }}" ` -B build cmake --build build --parallel --config ${{ env.CMAKE_CONFIG }} if: runner.os == 'Windows' - name: Run the C++ wrapper tests working-directory: cpp run: ctest --test-dir build --build-config ${{ env.CMAKE_CONFIG }} --output-on-failure --parallel - name: Install packages for building docs (Linux) working-directory: docs run: | sudo apt-get update sudo apt-get install -y --no-upgrade doxygen pipx install uv uv sync if: runner.os == 'Linux' - name: Install packages for building docs (Windows) working-directory: docs run: | curl -sSfLO https://github.com/doxygen/doxygen/releases/download/Release_1_13_2/doxygen-1.13.2.windows.x64.bin.zip Expand-Archive doxygen-1.13.2.windows.x64.bin.zip echo "${{ github.workspace }}\doxygen-1.13.2.windows.x64.bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append pipx install uv uv sync if: runner.os == 'Windows' - name: Build docs working-directory: docs run: uv run -- sphinx-build -b html . build/html - name: Package the C++ wrapper working-directory: cpp/build run: cpack -C ${{ env.CMAKE_CONFIG }} - name: Get archive name id: archive-name shell: bash run: | VERSION="${{ steps.get-libloot-version.outputs.version }}" if [[ "${{ runner.os }}" == "Windows" ]] then EXTENSION=7z if [[ "${{ matrix.target.platform }}" == "Win32" ]] then PLATFORM=win32 else PLATFORM=win64 fi else EXTENSION=tar.xz PLATFORM=Linux fi echo "filename=libloot-${VERSION}-${PLATFORM}.${EXTENSION}" >> $GITHUB_OUTPUT - name: Import GPG key run: echo -n "${{ secrets.GPG_SIGNING_KEY }}" | gpg --import if: github.event_name == 'push' - name: Sign archive working-directory: cpp/build/package run: gpg --output "${{ steps.archive-name.outputs.filename }}.sig" --detach-sig "${{ steps.archive-name.outputs.filename }}" if: github.event_name == 'push' - name: Upload archive uses: actions/upload-artifact@v4 with: name: ${{ steps.archive-name.outputs.filename }} path: | cpp/build/package/${{ steps.archive-name.outputs.filename }} cpp/build/package/${{ steps.archive-name.outputs.filename }}.sig if: github.event_name == 'push' python: strategy: matrix: target: - os: windows-2025 platform: Win32 triple: i686-pc-windows-msvc architecture: x86 - os: windows-2025 platform: x64 triple: x86_64-pc-windows-msvc architecture: x64 - os: ubuntu-24.04 platform: x86_64 triple: x86_64-unknown-linux-gnu architecture: x64 runs-on: ${{ matrix.target.os }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.13' architecture: ${{ matrix.target.architecture }} - uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ github.job }}-${{ runner.os }}-${{ matrix.target.architecture }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install Rust i686-pc-windows-msvc target run: rustup target add i686-pc-windows-msvc if: matrix.target.platform == 'Win32' - name: Set LIBLOOT_REVISION shell: bash run: echo "LIBLOOT_REVISION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Build the Python wrapper shell: bash working-directory: python run: | python -m venv .venv if [[ "${{ runner.os }}" == "Windows" ]] then ./.venv/Scripts/activate else . .venv/bin/activate fi pip install maturin maturin build --target ${{ matrix.target.triple }} --release nodejs: strategy: matrix: target: - os: windows-2025 platform: Win32 triple: i686-pc-windows-msvc architecture: x86 - os: windows-2025 platform: x64 triple: x86_64-pc-windows-msvc architecture: x64 - os: ubuntu-24.04 platform: x86_64 triple: x86_64-unknown-linux-gnu architecture: x64 runs-on: ${{ matrix.target.os }} steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ github.job }}-${{ runner.os }}-${{ matrix.target.architecture }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install Rust i686-pc-windows-msvc target run: rustup target add i686-pc-windows-msvc if: matrix.target.platform == 'Win32' - name: Set LIBLOOT_REVISION shell: bash run: echo "LIBLOOT_REVISION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Build the Node.js wrapper working-directory: nodejs run: | npm install npm run build - name: Run the Node.js wrapper's tests working-directory: nodejs run: npm test