name: Setup Rust Toolchain description: Install Rust toolchain and enable dependency caching inputs: toolchain: description: Rust toolchain version (stable, nightly, or specific like 1.95) default: stable components: description: Comma-separated list of components (e.g. rustfmt, clippy) default: "" cache-workspaces: description: >- Whitespace-separated list of workspace paths for rust-cache. Each entry may use "path -> target-dir" syntax. Example: ". fuzz" to cache both the root and fuzz workspaces. default: "" shared-key: description: Shared cache key for rust-cache (useful for matrix jobs that should share a build cache) default: "" cache-on-failure: description: Whether to save the cache even when the job fails (useful for fuzz targets) default: "false" runs: using: composite steps: - uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master with: toolchain: ${{ inputs.toolchain }} components: ${{ inputs.components }} - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 with: workspaces: ${{ inputs.cache-workspaces || '.' }} shared-key: ${{ inputs.shared-key || '' }} cache-on-failure: ${{ inputs.cache-on-failure }} # schedule runs on main and is the unattended seed for PR restores # (ci.yml has no push-on-main). merge_group also compiles and should # seed the cache. Fork PRs still cannot save. save-if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event_name == 'merge_group' }}