Skip to content

CI

CI #1143

Workflow file for this run

on:
push:
pull_request:
workflow_dispatch:
# Run automatically every monday
schedule:
- cron: 1 12 * * 1
name: CI
permissions:
actions: read
contents: read
jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Get runner version
run: |
# There is currently no way to access the runner version nicely,
# so enjoy this lovely bodge.
# (from: https://github.com/actions/runner/discussions/2838)
tarball=$(ls /opt/runner-cache/)
if [[ $tarball =~ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
echo "RUNNER_VERSION=${BASH_REMATCH[1]}" >> "$GITHUB_ENV"
else
echo "RUNNER_VERSION=unknown" >> "$GITHUB_ENV"
fi
if: startsWith(matrix.os, 'ubuntu-')
- name: Checkout repository
uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libgtk-4-dev build-essential
version: "${{ env.RUNNER_VERSION }}"
- name: Install toolchain
run: |
rustup toolchain install stable --component clippy
rustup default stable
- uses: Swatinem/rust-cache@v2
- name: Run clippy
run: cargo clippy -- --deny warnings
build_and_test:
name: Build and test
strategy:
fail-fast: false
matrix:
os: ['macos-latest', 'ubuntu-latest', 'windows-latest']
rust: ['stable', '1.85.1']
runs-on: ${{ matrix.os }}
env:
VCPKG_COMMIT: 2041718d8942de33c7d10e9e2fbf22b5e24d352e # vcpkg PR 48711
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg/installed
steps:
- name: Get runner version
run: |
tarball=$(ls /opt/runner-cache/)
if [[ $tarball =~ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
echo "RUNNER_VERSION=${BASH_REMATCH[1]}" >> "$GITHUB_ENV"
else
echo "RUNNER_VERSION=unknown" >> "$GITHUB_ENV"
fi
if: startsWith(matrix.os, 'ubuntu-')
- uses: actions/checkout@v4
# Workaround for https://github.com/rust-lang/rustup/issues/3709
- name: Disable rustup self-update
run: rustup set auto-self-update disable
if: runner.os == 'Windows'
- name: Install toolchain
run: |
rustup toolchain install ${{ matrix.rust }}
rustup default ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
with:
env-vars: VCPKG_COMMIT
if: runner.os == 'Windows'
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libgtk-4-dev build-essential
version: "${{ env.RUNNER_VERSION }}"
if: startsWith(matrix.os, 'ubuntu-')
- name: Install dependencies (macOS)
run: brew install gtk4
if: matrix.os == 'macos-latest'
- name: Install cargo-all-features
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: [email protected]
- name: Install cargo-wix (Windows)
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: [email protected]
if: matrix.os == 'windows-latest'
- name: Install cargo-license (Windows)
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: [email protected]
if: matrix.os == 'windows-latest'
- name: Restore vcpkg cache (Windows)
id: vcpkg-cache
uses: TAServers/vcpkg-cache@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
if: matrix.os == 'windows-latest'
- name: Install dependencies (Windows)
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT }}
runVcpkgInstall: true
doNotCache: true
env:
VCPKG_FEATURE_FLAGS: "binarycaching"
VCPKG_BINARY_SOURCES: "clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite"
if: matrix.os == 'windows-latest'
- name: Set PKG_CONFIG (Windows)
run: echo "PKG_CONFIG=$env:VCPKG_INSTALLED_DIR/x64-windows/tools/pkgconf/pkgconf.exe" | Out-File -FilePath $env:GITHUB_ENV -Append
if: matrix.os == 'windows-latest'
- name: Set PKG_CONFIG_PATH (Windows)
run: echo "PKG_CONFIG_PATH=$env:VCPKG_INSTALLED_DIR/x64-windows/lib/pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Append
if: matrix.os == 'windows-latest'
- name: Set PATH (Windows)
run: echo "$env:VCPKG_INSTALLED_DIR/x64-windows/bin" | Out-File -FilePath $env:GITHUB_PATH -Append
if: matrix.os == 'windows-latest'
- name: Build
run: cargo build --release
- name: Test
run: cargo test
if: runner.os != 'Linux'
- name: Test under XVFB (Linux)
run: xvfb-run cargo test
if: runner.os == 'Linux'
- name: Check all feature combinations are buildable
run: cargo check-all-features
- name: Build fuzzer
run: cargo +nightly rustc --features fuzzer --example fuzzer -- -C passes='sancov-module' -C llvm-args='-sanitizer-coverage-level=3' -C llvm-args='-sanitizer-coverage-inline-8bit-counters' -Z sanitizer=address
if: runner.os != 'Windows'
- name: Run fuzzer
run: target/debug/examples/fuzzer -seed=31337 -runs=10000
if: runner.os != 'Windows'
- name: Compile glib schemas (Windows)
run: |
& "$env:VCPKG_INSTALLED_DIR/x64-windows/tools/glib/glib-compile-schemas.exe" "$env:VCPKG_INSTALLED_DIR/x64-windows/share/glib-2.0/schemas"
if: matrix.os == 'windows-latest'
- name: Gather licenses (Windows)
# If the default shell is used, one command failing does not fail the action.
shell: bash
run: |
pip install license-expression
python -X utf8 wix/rust_licenses.py > wix/LICENSE-static-libraries.txt
python -X utf8 wix/vcpkg_licenses.py > wix/LICENSE-dynamic-libraries.txt
if: matrix.os == 'windows-latest'
- name: Generate components (Windows)
run: |
python wix/generate_components.py
if: matrix.os == 'windows-latest'
- name: Build installer (Windows)
run: cargo wix --no-build --nocapture -v
if: matrix.os == 'windows-latest'
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: Binaries for ${{ matrix.os }}
path: |
target/release/packetry
target/release/packetry.exe
target/release/packetry-cli
target/release/packetry-cli.exe
if-no-files-found: error
if: matrix.rust == 'stable'
- name: Upload installer (Windows)
uses: actions/upload-artifact@v4
with:
name: Windows installer
path: |
target/wix/*.msi
if-no-files-found: error
if: runner.os == 'Windows' && matrix.rust == 'stable'