Files
IronRDP/.github/workflows/ci.yml
Marc-André Moreau 649ac65d0c ci: keep Rust cache keys stable and cancel superseded runs (#2268)
Swatinem/rust-cache hashes every installed toolchain into its key,
including the runner's preinstalled stable. Runner images currently ship
either stable 1.99.0 or 1.99.1, so the key splits while master saves
only one variant: macOS Checks found no cache in about half of pull
request runs and compiled all 1164 crates (about 22 minutes instead of
11), and Linux restored a stale cache. Uninstalling every toolchain
except the one pinned in rust-toolchain.toml before the cache step makes
the key depend only on the pinned toolchain and the lockfiles. The fuzz,
agentic RDP and release binary workflows get the same step; the release
workflow inlines it because it checks out the release tag, which may
predate the shared action.

Stacked pull requests receive two `synchronize` events per push (base
and head branch), which started two full CI runs on the same commit, and
a new push left the previous run going to completion. CI now keeps only
the latest run per pull request.

The build jobs no longer wait for the formatting check, which only
delayed them; `Success` still requires it.

The cache keys change, so pull request runs build without a cache until
the first master run after merge saves the new caches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 19:19:22 -04:00

379 lines
11 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: CI
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
concurrency:
# Stacked PRs get two `synchronize` events per push (base and head branch), and a new push makes
# the previous run obsolete: keep only the latest run per PR. Other events never share a group.
group: ci-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
env:
# Disable incremental compilation. CI builds are often closer to from-scratch builds, as changes
# are typically bigger than from a local edit-compile cycle.
# Incremental compilation also significantly increases the amount of IO and the size of ./target
# folder, which makes caching less effective.
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: short
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
# Cache should never takes more than a few seconds to get downloaded.
# If it does, let’s just rebuild from scratch instead of hanging "forever".
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
# Disabling debug info so compilation is faster and ./target folder is smaller.
CARGO_PROFILE_DEV_DEBUG: 0
jobs:
formatting:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Check formatting
run: cargo xtask check fmt -v
test-settings:
name: Check test settings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
# PR checkout uses a merge commit; depth 2 includes its base parent as HEAD^1.
fetch-depth: 2
- name: Check protected settings
if: github.event_name == 'pull_request'
run: cargo xtask check test-settings --base 'HEAD^1' --head 'HEAD' -v
typos:
name: Check typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Binary cache
uses: actions/cache@v5
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}
- name: typos (prepare)
run: cargo xtask check install -v
- name: typos (check)
run: cargo xtask check typos -v
# release-binaries.yml cannot use the shared action (it checks out the release tag), so it
# carries a copy that must stay identical.
- name: Inlined prune step matches shared action
run: |
shared="$(yq '.runs.steps[] | select(.name == "Uninstall unpinned Rust toolchains") | .run' .github/actions/prune-rust-toolchains/action.yml)"
release="$(yq '.jobs.build.steps[] | select(.name == "Prune Rust toolchains") | .run' .github/workflows/release-binaries.yml)"
test -n "$shared"
diff -u <(echo "$shared") <(echo "$release")
# TODO: Move this action to a dedicated repository.
openai-agent:
name: OpenAI agent action [${{ matrix.os }}]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v6
- name: Install dependencies
working-directory: .github/actions/openai-agent
run: npm ci
- name: Test PR automation
run: node --test .github/pr-automation/automation.test.js
- name: Run tests
working-directory: .github/actions/openai-agent
run: npm test
- name: Build action
working-directory: .github/actions/openai-agent
run: npm run build
- name: Verify bundled action
working-directory: .github/actions/openai-agent
run: git diff --exit-code -- dist
checks:
name: Checks [${{ matrix.os }}]
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
os: [windows, linux, macos]
include:
- os: windows
runner: windows-latest
- os: linux
runner: ubuntu-latest
- os: macos
runner: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install build dependencies
uses: ./.github/actions/install-build-deps
- name: Prune Rust toolchains
uses: ./.github/actions/prune-rust-toolchains
- name: Rust cache
uses: Swatinem/rust-cache@v2.9.1
with:
save-if: ${{ github.ref == 'refs/heads/master' }}
- name: Binary cache
uses: actions/cache@v5
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}
# Compilation is separated from execution so we know exactly the time for each step.
- name: Tests (compile)
run: cargo xtask check tests --no-run -v
- name: Tests (run)
run: cargo xtask check tests -v
- name: Build ActiveX host harness
if: matrix.os == 'windows'
run: dotnet build .\crates\ironrdp-activex\tests\ironrdp-axhost\IronRdpAxHost.csproj --configuration Release
- name: Lints
run: cargo xtask check lints -v
- name: Dependencies
run: cargo xtask check dependencies -v
- name: Packet captures
run: cargo xtask check captures -v
- name: WASM (prepare)
run: cargo xtask wasm install -v
- name: WASM (check)
run: cargo xtask wasm check -v
- name: Lock files
run: cargo xtask check locks -v
fuzz:
name: Fuzzing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Prune Rust toolchains
uses: ./.github/actions/prune-rust-toolchains
- name: Rust cache
uses: Swatinem/rust-cache@v2.9.1
with:
workspaces: fuzz -> target
save-if: ${{ github.ref == 'refs/heads/master' }}
- name: Binary cache
uses: actions/cache@v5
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}
- name: Prepare
run: cargo xtask fuzz install -v
# Simply run all fuzz targets for a few seconds, just checking there is nothing obviously wrong at a quick glance
- name: Fuzz
run: cargo xtask fuzz run -v
- name: Lock files
run: cargo xtask check locks -v
web:
name: Web Client
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Prune Rust toolchains
uses: ./.github/actions/prune-rust-toolchains
- name: Rust cache
uses: Swatinem/rust-cache@v2.9.1
with:
save-if: ${{ github.ref == 'refs/heads/master' }}
- name: Binary cache
uses: actions/cache@v5
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}
- name: Prepare
run: cargo xtask web install -v
- name: Check
run: cargo xtask web check -v
- name: Lock files
run: cargo xtask check locks -v
ffi:
name: FFI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up the pinned diplomat-tool
uses: ./.github/actions/setup-diplomat-tool
- name: Build native library
run: cargo xtask ffi build -v
- name: Generate bindings
run: cargo xtask ffi bindings -v
- name: Build .NET projects
run: cd ./ffi/dotnet && dotnet build
- name: Run .NET smoke tests
run: dotnet run --project ./ffi/dotnet/Devolutions.IronRdp.Tests --no-build
ffi-bindings-check:
name: FFI bindings reproducibility
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Set up the pinned diplomat-tool
uses: ./.github/actions/setup-diplomat-tool
# The solution is built below, after the regenerated bindings pass the drift check.
- name: Regenerate C# bindings
run: cargo xtask ffi bindings --skip-dotnet-build -v
- name: Check generated binding drift
shell: pwsh
run: |
$paths = @(
"ffi/dotnet/Devolutions.IronRdp/Generated",
"ffi/dotnet-interop-conf.toml"
)
$changes = git status --porcelain=v1 --untracked-files=all -- $paths
if ($changes) {
[Console]::Error.WriteLine('FFI bindings are not reproducible. Regenerate them with `cargo xtask ffi install` then `cargo xtask ffi bindings` and commit the result.')
$changes
git --no-pager diff -- $paths
exit 1
}
- name: Build native library
run: cargo xtask ffi build -v
- name: Build IronRdp.sln
run: dotnet build ffi/dotnet/IronRdp.sln -c Release
- name: Run .NET smoke tests
run: dotnet run --project ffi/dotnet/Devolutions.IronRdp.Tests -c Release --no-build
feature-matrix-setup:
name: feature matrix setup
runs-on: ubuntu-latest
outputs:
feature-matrix: ${{ steps.setup-matrix.outputs.feature-matrix }}
steps:
- uses: actions/checkout@v6
- name: Prune Rust toolchains
uses: ./.github/actions/prune-rust-toolchains
- name: Rust cache
uses: Swatinem/rust-cache@v2.9.1
with:
save-if: ${{ github.ref == 'refs/heads/master' }}
- name: Setup matrix
id: setup-matrix
run: |
MATRIX="$(cargo xtask check features --list --format github-matrix)"
echo "feature-matrix=$MATRIX" >> "$GITHUB_OUTPUT"
feature-matrix:
name: feature matrix [${{ matrix.case }}]
needs: [feature-matrix-setup]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.feature-matrix-setup.outputs.feature-matrix) }}
steps:
- uses: actions/checkout@v6
- name: Install build dependencies
uses: ./.github/actions/install-build-deps
- name: Prune Rust toolchains
uses: ./.github/actions/prune-rust-toolchains
- name: Rust cache
uses: Swatinem/rust-cache@v2.9.1
with:
save-if: ${{ github.ref == 'refs/heads/master' }}
- name: Binary cache
uses: actions/cache@v5
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}
- name: Prepare
run: cargo xtask check install -v
- name: Run feature-matrix case
run: cargo xtask check features --case '${{ matrix.case }}' -v
- name: Lock files
run: cargo xtask check locks -v
success:
name: Success
if: ${{ always() }}
needs: [formatting, test-settings, typos, openai-agent, checks, fuzz, web, ffi, ffi-bindings-check, feature-matrix-setup, feature-matrix]
runs-on: ubuntu-latest
steps:
- name: Check success
run: |
$results = '${{ toJSON(needs.*.result) }}' | ConvertFrom-Json
$succeeded = $($results | Where { $_ -Ne "success" }).Count -Eq 0
exit $(if ($succeeded) { 0 } else { 1 })
shell: pwsh