name: Setup Soldr Action on: pull_request: paths: - action.yml - install.sh - rust-toolchain.toml - Cargo.toml - Cargo.lock - .github/actions/setup-soldr/** - .github/workflows/setup-soldr-action.yml # Run on main pushes too so the dogfood zccache gets saved at the base # branch scope (refs/heads/main). GitHub Actions caches are scoped per ref: # a PR run can read caches from its base branch but cannot read other PRs' # caches. Without a push:main trigger every PR starts cold because nothing # has ever populated the prefix at the base scope. See issue #249. push: branches: - main paths: - action.yml - install.sh - rust-toolchain.toml - Cargo.toml - Cargo.lock - .github/actions/setup-soldr/** - .github/workflows/setup-soldr-action.yml workflow_dispatch: permissions: contents: read jobs: smoke: name: ${{ matrix.name }} runs-on: ${{ matrix.runner }} env: # Managed zccache is fetched from zackees/zccache, which is a # cross-repo GitHub Releases lookup from this workflow. Use soldr's # explicit opt-in token env so release metadata requests are # authenticated without weakening the generic GITHUB_TOKEN guard. SOLDR_GITHUB_TOKEN: ${{ github.token }} strategy: fail-fast: false matrix: include: - name: Linux runner: ubuntu-24.04 - name: macOS runner: macos-15 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: submodules: recursive - name: Verify setup-soldr pin matches v0 shell: bash # Non-blocking: a stale pin warns visibly in the PR checks list # (the step turns yellow) but does not fail the job. We'll handle # the pin bump out-of-band rather than gating every unrelated PR # on an upstream tag move. continue-on-error: true run: | set -uo pipefail if command -v python3 >/dev/null 2>&1; then python3 .github/scripts/verify_setup_soldr_pin.py else python .github/scripts/verify_setup_soldr_pin.py fi status=$? if [[ $status -ne 0 ]]; then echo "::warning title=setup-soldr pin stale::Pin in .github/workflows/setup-soldr-action.yml does not match @v0 — non-blocking; bump out-of-band." exit $status fi - id: setup # This is zackees/setup-soldr@v0 pinned to a full SHA # because this repository's ruleset requires SHA-pinned actions. uses: zackees/setup-soldr@cca74625e75e70b56f1805fa6eeee9069f945d48 with: cache: true zccache-seed-strict: true linker: platform-default # Keep the action runtime cache separate from the Soldr build under # test. The dogfood build below overrides SOLDR_CACHE_DIR so soldr # owns zccache under that separate root. cache-dir: ${{ runner.temp }}/setup-soldr-action-state cache-key-suffix: dogfood-action-state build-cache: false target-cache: true prebuild-deps: soldr-cook prebuild-deps-flags: "" - name: Restore checkout after soldr-cook shell: pwsh run: git restore --worktree -- . - name: Show action outputs shell: pwsh run: | Write-Host "soldr-path=${{ steps.setup.outputs.soldr-path }}" Write-Host "soldr-version=${{ steps.setup.outputs.soldr-version }}" Write-Host "cache-dir=${{ steps.setup.outputs.cache-dir }}" Write-Host "cache-hit=${{ steps.setup.outputs.cache-hit }}" Write-Host "build-cache-hit=${{ steps.setup.outputs.build-cache-hit }}" Write-Host "target-cache-hit=${{ steps.setup.outputs.target-cache-hit }}" Write-Host "toolchain=${{ steps.setup.outputs.toolchain }}" - name: Verify setup state shell: pwsh run: | if (-not (Test-Path $env:SOLDR_CACHE_DIR)) { throw "missing SOLDR_CACHE_DIR" } if (-not (Test-Path $env:CARGO_HOME)) { throw "missing CARGO_HOME" } if (-not (Test-Path $env:RUSTUP_HOME)) { throw "missing RUSTUP_HOME" } soldr version --json cargo --version rustc --version - name: Verify cache isolation shell: pwsh env: SOLDR_DOGFOOD_BUILD_CACHE_DIR: ${{ runner.temp }}/soldr-build-under-test run: | $actionCache = [System.IO.Path]::GetFullPath($env:SOLDR_CACHE_DIR) $buildCache = [System.IO.Path]::GetFullPath($env:SOLDR_DOGFOOD_BUILD_CACHE_DIR) $actionPrefix = $actionCache.TrimEnd([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar) + [System.IO.Path]::DirectorySeparatorChar $buildPrefix = $buildCache.TrimEnd([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar) + [System.IO.Path]::DirectorySeparatorChar if ($actionCache -eq $buildCache -or $buildCache.StartsWith($actionPrefix) -or $actionCache.StartsWith($buildPrefix)) { throw "setup-soldr action cache must be disjoint from the Soldr build-under-test cache" } New-Item -ItemType Directory -Force -Path $buildCache | Out-Null $zccacheDir = Join-Path -Path (Join-Path -Path $buildCache -ChildPath "cache") -ChildPath "zccache" New-Item -ItemType Directory -Force -Path $zccacheDir | Out-Null Write-Host "action-cache=$actionCache" Write-Host "build-under-test-cache=$buildCache" Write-Host "build-under-test-zccache=$zccacheDir" - id: dogfood-build-cache name: Restore dogfood build cache uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: ${{ runner.temp }}/soldr-build-under-test/cache/zccache key: setup-soldr-dogfood-zccache-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}-${{ github.sha }} restore-keys: | setup-soldr-dogfood-zccache-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}- setup-soldr-dogfood-zccache-v1-${{ runner.os }}-${{ runner.arch }}- - name: Stop setup-soldr builder cache before dogfood build uses: zackees/setup-soldr/cleanup@cca74625e75e70b56f1805fa6eeee9069f945d48 - name: Build through soldr shell: pwsh env: SOLDR_CACHE_DIR: ${{ runner.temp }}/soldr-build-under-test SOLDR_CACHE_LIFECYCLE: command SOLDR_CACHE_SHUTDOWN_TIMEOUT_SECS: "30" ZCCACHE_CACHE_DIR: ${{ runner.temp }}/soldr-build-under-test/cache/zccache run: | Write-Host "dogfood-build-cache-hit=${{ steps.dogfood-build-cache.outputs.cache-hit }}" $timer = [Diagnostics.Stopwatch]::StartNew() soldr cargo build --package soldr-cli --locked $exitCode = $LASTEXITCODE $timer.Stop() Write-Host ([string]::Format([Globalization.CultureInfo]::InvariantCulture, "dogfood-build-seconds={0:F3}", $timer.Elapsed.TotalSeconds)) exit $exitCode - name: Test through soldr shell: pwsh env: SOLDR_CACHE_DIR: ${{ runner.temp }}/soldr-build-under-test run: | Remove-Item Env:ZCCACHE_CACHE_DIR -ErrorAction SilentlyContinue $timer = [Diagnostics.Stopwatch]::StartNew() soldr --no-cache cargo test -p soldr-cli --tests --locked $exitCode = $LASTEXITCODE $timer.Stop() Write-Host ([string]::Format([Globalization.CultureInfo]::InvariantCulture, "dogfood-test-seconds={0:F3}", $timer.Elapsed.TotalSeconds)) exit $exitCode - name: Show dogfood cache status if: always() shell: pwsh env: SOLDR_CACHE_DIR: ${{ runner.temp }}/soldr-build-under-test ZCCACHE_CACHE_DIR: ${{ runner.temp }}/soldr-build-under-test/cache/zccache run: | $soldr = Get-Command soldr -ErrorAction SilentlyContinue if (-not $soldr) { Write-Host "soldr is unavailable; skipping dogfood cache status" exit 0 } & $soldr.Source cache if ($LASTEXITCODE -ne 0) { Write-Host "soldr cache status unavailable after dogfood build" exit 0 } - name: Stop dogfood zccache before cache save if: always() continue-on-error: true shell: pwsh env: SOLDR_CACHE_DIR: ${{ runner.temp }}/soldr-build-under-test ZCCACHE_CACHE_DIR: ${{ runner.temp }}/soldr-build-under-test/cache/zccache run: | $exeName = if ($IsWindows) { "zccache.exe" } else { "zccache" } $zccache = $null $soldrBin = Join-Path -Path $env:SOLDR_CACHE_DIR -ChildPath "bin" if (Test-Path -LiteralPath $soldrBin) { $zccache = Get-ChildItem -LiteralPath $soldrBin -Recurse -Filter $exeName -File -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName } if ([string]::IsNullOrWhiteSpace($zccache)) { Write-Host "zccache binary is unavailable; nothing to stop." exit 0 } & $zccache stop