diff --git a/CHANGELOG.md b/CHANGELOG.md index af53971..f8020f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - **rust/build-library** - Build Rust libraries with flexible profile and feature control - **rust/lint** - Run cargo fmt and cargo clippy for code quality checks +- **rust/verify-toolchain** - Reusable action to verify Rust toolchain and components are installed + - Verify cargo, rustfmt, clippy, or llvm-tools-preview + - Outputs version information for all verified tools + - Clear, actionable error messages with setup instructions + - Used internally by other Rust actions (lint, build-binary, build-library, generate-sbom) +- **rust/lint** features: - Configurable fmt and clippy checks (can enable/disable individually) - Custom clippy arguments and lint levels - Feature support (all-features, specific features, no-default-features) @@ -28,8 +34,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Complete workspace workflow examples in documentation ### Changed +- **rust/setup-rust-build** now includes `rustfmt` and `clippy` components by default + - Ensures all Rust tooling is available for linting and code quality checks + - Added new `components` input parameter for customization (default: `rustfmt, clippy`) + - Users can customize components or set to empty string for minimal installation + - No breaking changes - existing workflows continue to work - **rust/generate-sbom** now supports Cargo workspaces with `--workspace` and `--package` flags +- **rust/lint**, **rust/build-binary**, **rust/build-library**, and **rust/generate-sbom** now use **rust/verify-toolchain** action + - Provides consistent toolchain verification across all Rust actions + - Reduces code duplication + - Clearer error messages with actionable guidance - Updated generate-sbom README with workspace examples and best practices +- Updated all Rust action documentation to prioritize `rust/setup-rust-build` over external setup actions ## [1.0.0] - 2025-12-18 diff --git a/README.md b/README.md index e5e3dc6..5910271 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,13 @@ jobs: ### Rust Ecosystem +> **Note**: All Rust actions require the Rust toolchain to be installed. Use [`rust/setup-rust-build`](rust/setup-rust-build/README.md) or [actions-rust-lang/setup-rust-toolchain](https://github.com/actions-rust-lang/setup-rust-toolchain) before using these actions. + | Action | Description | Documentation | |--------|-------------|---------------| | [`rust/cache-cargo`](rust/cache-cargo/README.md) | Cache Cargo registry, index, and build artifacts | [📖 Docs](rust/cache-cargo/README.md) | | [`rust/setup-rust-build`](rust/setup-rust-build/README.md) | Set up Rust toolchain with cross-compilation support | [📖 Docs](rust/setup-rust-build/README.md) | +| [`rust/verify-toolchain`](rust/verify-toolchain/README.md) | Verify Rust toolchain and required components are installed | [📖 Docs](rust/verify-toolchain/README.md) | | [`rust/build-binary`](rust/build-binary/README.md) | Build Rust binaries for x86_64 and ARM64 | [📖 Docs](rust/build-binary/README.md) | | [`rust/build-library`](rust/build-library/README.md) | Build Rust libraries with flexible profile and feature control | [📖 Docs](rust/build-library/README.md) | | [`rust/lint`](rust/lint/README.md) | Run cargo fmt and cargo clippy for code quality | [📖 Docs](rust/lint/README.md) | @@ -299,7 +302,7 @@ These actions are built with the following principles: | Language | Actions Available | Count | |----------|-------------------|-------| -| **Rust** | cache-cargo, setup-rust-build, build-binary, build-library, lint, security-scan, generate-sbom | 7 | +| **Rust** | cache-cargo, setup-rust-build, verify-toolchain, build-binary, build-library, lint, security-scan, generate-sbom | 8 | | **Go** | trivy-scan, cosign-sign, verify-signed-commits, license-check, setup-docker, extract-version | 6 | | **Python** | trivy-scan, cosign-sign, verify-signed-commits, license-check, setup-docker, extract-version | 6 | | **Node.js** | trivy-scan, cosign-sign, verify-signed-commits, license-check, setup-docker, extract-version | 6 | diff --git a/rust/build-binary/action.yaml b/rust/build-binary/action.yaml index bad12f0..155d5d7 100644 --- a/rust/build-binary/action.yaml +++ b/rust/build-binary/action.yaml @@ -17,6 +17,11 @@ inputs: runs: using: composite steps: + - name: Verify Rust toolchain + uses: firestoned/github-actions/rust/verify-toolchain@main + with: + require-cargo: true + - name: Build (release) - x86_64 if: inputs.target == 'x86_64-unknown-linux-gnu' shell: bash diff --git a/rust/build-library/action.yml b/rust/build-library/action.yml index 83f0638..9472cfd 100644 --- a/rust/build-library/action.yml +++ b/rust/build-library/action.yml @@ -58,6 +58,11 @@ outputs: runs: using: composite steps: + - name: Verify Rust toolchain + uses: firestoned/github-actions/rust/verify-toolchain@main + with: + require-cargo: true + - name: Determine build command id: config shell: bash diff --git a/rust/generate-sbom/action.yaml b/rust/generate-sbom/action.yaml index 9210811..e06b0cc 100644 --- a/rust/generate-sbom/action.yaml +++ b/rust/generate-sbom/action.yaml @@ -38,6 +38,11 @@ inputs: runs: using: 'composite' steps: + - name: Verify Rust toolchain + uses: firestoned/github-actions/rust/verify-toolchain@main + with: + require-cargo: true + - name: Cache cargo-cyclonedx id: cache-cyclonedx uses: actions/cache@v4 diff --git a/rust/lint/README.md b/rust/lint/README.md index 05e4c02..dcf29db 100644 --- a/rust/lint/README.md +++ b/rust/lint/README.md @@ -2,6 +2,22 @@ A composite GitHub Action that runs `cargo fmt` and `cargo clippy` to check code formatting and quality for Rust projects. +## Prerequisites + +This action requires the Rust toolchain with `rustfmt` and `clippy` components to be installed. Set up Rust before using this action: + +```yaml +- uses: firestoned/github-actions/rust/setup-rust-build@v1 +``` + +Alternatively, you can use the community action: + +```yaml +- uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt, clippy +``` + ## Features - **Automated Formatting Checks** - Verify code follows Rust style guidelines with `cargo fmt` @@ -17,6 +33,9 @@ A composite GitHub Action that runs `cargo fmt` and `cargo clippy` to check code ### Basic Example ```yaml +- name: Setup Rust + uses: firestoned/github-actions/rust/setup-rust-build@v1 + - name: Lint Rust code uses: firestoned/github-actions/rust/lint@v1 ``` @@ -165,6 +184,9 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup Rust + uses: firestoned/github-actions/rust/setup-rust-build@v1 + - name: Cache dependencies uses: firestoned/github-actions/rust/cache-cargo@v1 @@ -352,13 +374,38 @@ avoid-breaking-exported-api = true ## Troubleshooting +### Rust Toolchain Not Found + +**Problem**: Error "Rust toolchain not found" + +**Solution**: Add Rust setup before the lint action: +```yaml +- uses: firestoned/github-actions/rust/setup-rust-build@v1 + +- uses: firestoned/github-actions/rust/lint@v1 +``` + +### rustfmt or clippy Component Missing + +**Problem**: Error "rustfmt component not found" or "clippy component not found" + +**Solution**: Ensure components are installed. Our setup action includes them by default: +```yaml +- uses: firestoned/github-actions/rust/setup-rust-build@v1 +``` + +Or manually: +```bash +rustup component add rustfmt clippy +``` + ### Formatting Check Fails **Problem**: `cargo fmt --check` fails in CI but passes locally **Solution**: Ensure same Rust version and rustfmt.toml: ```yaml -- uses: actions-rust-lang/setup-rust-toolchain@v1 +- uses: firestoned/github-actions/rust/setup-rust-build@v1 with: toolchain: stable components: rustfmt, clippy diff --git a/rust/lint/action.yml b/rust/lint/action.yml index f2b9818..ebccb57 100644 --- a/rust/lint/action.yml +++ b/rust/lint/action.yml @@ -58,6 +58,13 @@ outputs: runs: using: 'composite' steps: + - name: Verify Rust toolchain + uses: firestoned/github-actions/rust/verify-toolchain@main + with: + require-cargo: true + require-rustfmt: true + require-clippy: true + - name: Check formatting id: fmt if: inputs.check-fmt == 'true' diff --git a/rust/setup-rust-build/README.md b/rust/setup-rust-build/README.md index 5c9727e..49dab2a 100644 --- a/rust/setup-rust-build/README.md +++ b/rust/setup-rust-build/README.md @@ -42,6 +42,24 @@ A composite GitHub Action that sets up a complete Rust build environment with in cache-key: my-feature-branch ``` +### Custom Components + +```yaml +# Minimal setup without linting tools +- name: Setup Rust (build only) + uses: your-org/github-actions/rust/setup-rust-build@v1 + with: + target: x86_64-unknown-linux-gnu + components: '' + +# Add additional components +- name: Setup Rust with extra tools + uses: your-org/github-actions/rust/setup-rust-build@v1 + with: + target: x86_64-unknown-linux-gnu + components: 'rustfmt, clippy, llvm-tools-preview' +``` + ### Multi-Target Matrix Build ```yaml @@ -71,6 +89,7 @@ jobs: | `target` | Rust target triple (e.g., `x86_64-unknown-linux-gnu`, `aarch64-unknown-linux-gnu`) | Yes | N/A | | `cache-key` | Additional cache key component for isolating caches by branch or feature | No | `''` | | `cross-version` | Version of `cross` to install for ARM64 builds (e.g., `v0.2.5`) | No | `v0.2.5` | +| `components` | Comma-separated list of Rust components to install (e.g., `rustfmt, clippy`) | No | `rustfmt, clippy` | ## How It Works @@ -78,8 +97,9 @@ jobs: 1. Installs Rust toolchain using `dtolnay/rust-toolchain@stable` 2. Adds the specified target to the toolchain -3. Caches Rust dependencies using `Swatinem/rust-cache@v2` -4. Uses target and cache-key for cache isolation +3. Installs components (default: `rustfmt, clippy`) +4. Caches Rust dependencies using `Swatinem/rust-cache@v2` +5. Uses target and cache-key for cache isolation ### ARM64 Builds (aarch64) diff --git a/rust/setup-rust-build/action.yaml b/rust/setup-rust-build/action.yaml index 762a502..5ff890e 100644 --- a/rust/setup-rust-build/action.yaml +++ b/rust/setup-rust-build/action.yaml @@ -21,6 +21,10 @@ inputs: description: 'Version of cross to install for ARM64 builds' required: false default: 'v0.2.5' + components: + description: 'Comma-separated list of components to install (e.g., rustfmt, clippy)' + required: false + default: 'rustfmt, clippy' runs: using: composite @@ -29,6 +33,7 @@ runs: uses: dtolnay/rust-toolchain@stable with: targets: ${{ inputs.target }} + components: ${{ inputs.components }} - name: Cache Rust dependencies uses: Swatinem/rust-cache@v2 diff --git a/rust/verify-toolchain/README.md b/rust/verify-toolchain/README.md new file mode 100644 index 0000000..518b673 --- /dev/null +++ b/rust/verify-toolchain/README.md @@ -0,0 +1,423 @@ +# Verify Rust Toolchain + +A composite GitHub Action that verifies the Rust toolchain and required components are installed before running Rust-related tasks. + +## Purpose + +This action provides a reusable way to verify that the Rust toolchain and specific components (rustfmt, clippy, llvm-tools-preview) are available in the workflow environment. It's used internally by other Rust actions in this repository to ensure prerequisites are met. + +## Features + +- **Flexible Component Verification** - Check for cargo, rustfmt, clippy, or llvm-tools-preview +- **Clear Error Messages** - Provides actionable guidance when components are missing +- **Version Outputs** - Returns version information for all verified tools +- **Composable** - Used by other actions to ensure prerequisites are met +- **Fail-Fast** - Exits immediately with clear errors if required components are missing + +## Usage + +### Basic Example (Verify Cargo Only) + +```yaml +- name: Verify Rust toolchain + uses: firestoned/github-actions/rust/verify-toolchain@v1 +``` + +This verifies that cargo is available (the default behavior). + +### Verify Multiple Components + +```yaml +- name: Verify Rust with rustfmt and clippy + uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-rustfmt: true + require-clippy: true +``` + +### Verify All Common Components + +```yaml +- name: Verify complete Rust toolchain + uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-cargo: true + require-rustfmt: true + require-clippy: true + require-llvm-tools: true +``` + +### Skip Cargo Verification (Components Only) + +```yaml +- name: Verify only rustfmt + uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-cargo: false + require-rustfmt: true +``` + +## Inputs + +| Name | Description | Required | Default | +|------|-------------|----------|---------| +| `require-cargo` | Require cargo to be available | No | `true` | +| `require-rustfmt` | Require rustfmt component | No | `false` | +| `require-clippy` | Require clippy component | No | `false` | +| `require-llvm-tools` | Require llvm-tools-preview component | No | `false` | + +## Outputs + +| Name | Description | +|------|-------------| +| `rustc-version` | Rust compiler version (if cargo is available) | +| `cargo-version` | Cargo version (if cargo is available) | +| `rustfmt-version` | rustfmt version (if rustfmt is available) | +| `clippy-version` | clippy version (if clippy is available) | + +## How It Works + +1. **Cargo Verification** (if `require-cargo: true`) + - Checks if `cargo` command is available + - Outputs rustc and cargo versions + - Provides setup instructions if missing + +2. **rustfmt Verification** (if `require-rustfmt: true`) + - Checks if `rustfmt` command is available + - Outputs rustfmt version + - Provides installation instructions if missing + +3. **clippy Verification** (if `require-clippy: true`) + - Checks if `cargo-clippy` command is available + - Outputs clippy version + - Provides installation instructions if missing + +4. **llvm-tools Verification** (if `require-llvm-tools: true`) + - Checks if llvm-tools-preview component is installed + - Confirms installation + - Provides installation instructions if missing + +5. **Exit Handling** + - Exits with error code 1 if any required component is missing + - Provides clear, actionable error messages + - References our setup-rust-build action for easy fixes + +## Examples + +### In a Linting Workflow + +```yaml +name: Lint Rust Code + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Rust + uses: firestoned/github-actions/rust/setup-rust-build@v1 + with: + components: rustfmt, clippy + + - name: Verify toolchain + uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-rustfmt: true + require-clippy: true + + - name: Run linters + run: | + cargo fmt --check + cargo clippy -- -D warnings +``` + +### In a Build Workflow + +```yaml +name: Build Rust Binary + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Rust + uses: firestoned/github-actions/rust/setup-rust-build@v1 + + - name: Verify toolchain + uses: firestoned/github-actions/rust/verify-toolchain@v1 + + - name: Build + run: cargo build --release +``` + +### With Version Outputs + +```yaml +- name: Verify Rust toolchain + id: verify + uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-cargo: true + require-clippy: true + +- name: Display versions + run: | + echo "Rust version: ${{ steps.verify.outputs.rustc-version }}" + echo "Cargo version: ${{ steps.verify.outputs.cargo-version }}" + echo "Clippy version: ${{ steps.verify.outputs.clippy-version }}" +``` + +### In Coverage Workflows + +```yaml +- name: Verify Rust with llvm-tools + uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-cargo: true + require-llvm-tools: true + +- name: Generate coverage + run: | + cargo install cargo-llvm-cov + cargo llvm-cov --all-features --workspace +``` + +## Error Messages + +When a required component is missing, the action provides clear, actionable error messages: + +### Missing Cargo + +``` +❌ Error: Rust toolchain not found + +Please set up Rust before using this action: + + - uses: firestoned/github-actions/rust/setup-rust-build@v1 + +Or use the community action: + - uses: actions-rust-lang/setup-rust-toolchain@v1 +``` + +### Missing rustfmt + +``` +❌ Error: rustfmt component not found + +Install rustfmt: + rustup component add rustfmt + +Or use our setup action with rustfmt included: + - uses: firestoned/github-actions/rust/setup-rust-build@v1 + with: + components: rustfmt +``` + +### Missing clippy + +``` +❌ Error: clippy component not found + +Install clippy: + rustup component add clippy + +Or use our setup action with clippy included: + - uses: firestoned/github-actions/rust/setup-rust-build@v1 + with: + components: clippy +``` + +## Used By + +This action is used internally by other Rust actions in this repository: + +- [**rust/lint**](../lint/README.md) - Requires rustfmt and clippy +- [**rust/build-binary**](../build-binary/README.md) - Requires cargo +- [**rust/build-library**](../build-library/README.md) - Requires cargo +- [**rust/generate-sbom**](../generate-sbom/README.md) - Requires cargo + +## Best Practices + +### 1. Use After Setup Action + +Always run verify-toolchain after setting up the Rust toolchain: + +```yaml +- uses: firestoned/github-actions/rust/setup-rust-build@v1 + +- uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-rustfmt: true +``` + +### 2. Only Verify What You Need + +Don't require components you won't use: + +```yaml +# ❌ Over-verification +- uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-cargo: true + require-rustfmt: true + require-clippy: true + require-llvm-tools: true # Not needed for this workflow + +# ✅ Verify only what's needed +- uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-cargo: true + require-rustfmt: true +``` + +### 3. Use Outputs for Debugging + +Capture version outputs for debugging and audit trails: + +```yaml +- name: Verify toolchain + id: verify + uses: firestoned/github-actions/rust/verify-toolchain@v1 + +- name: Log versions + run: | + echo "::notice::Rust version: ${{ steps.verify.outputs.rustc-version }}" +``` + +### 4. Fail Fast + +Put verification early in your workflow to fail fast if prerequisites are missing: + +```yaml +steps: + - uses: actions/checkout@v4 + + - uses: firestoned/github-actions/rust/setup-rust-build@v1 + + - uses: firestoned/github-actions/rust/verify-toolchain@v1 # Verify early + with: + require-cargo: true + + - name: Build (only runs if verification passes) + run: cargo build +``` + +## Troubleshooting + +### Verification Fails After Setup + +**Problem**: Verification fails even after running setup-rust-build + +**Solution**: Ensure components are specified in setup-rust-build: +```yaml +- uses: firestoned/github-actions/rust/setup-rust-build@v1 + with: + components: rustfmt, clippy # Explicitly include required components + +- uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-rustfmt: true + require-clippy: true +``` + +### Component Installed But Not Found + +**Problem**: Component is installed but verification fails + +**Solution**: Ensure the correct command is available: +- rustfmt requires `rustfmt` command +- clippy requires `cargo-clippy` command +- llvm-tools requires component to be in `rustup component list --installed` + +Check manually: +```bash +rustup component list --installed +which rustfmt +which cargo-clippy +``` + +### Version Output is Empty + +**Problem**: Version outputs are empty + +**Solution**: Outputs are only populated if the component is required and available: +```yaml +- uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-cargo: true # Must be true to get cargo-version output +``` + +## Advanced Usage + +### Custom Verification Logic + +For custom verification needs, use this action as a template and extend it: + +```yaml +- name: Verify toolchain + uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-cargo: true + +- name: Additional custom verification + shell: bash + run: | + # Verify specific cargo plugins + if ! cargo --list | grep -q "audit"; then + echo "Installing cargo-audit..." + cargo install cargo-audit + fi +``` + +### Matrix Testing with Different Components + +Test with different component combinations: + +```yaml +strategy: + matrix: + components: + - name: 'basic' + rustfmt: false + clippy: false + - name: 'linting' + rustfmt: true + clippy: true + - name: 'coverage' + rustfmt: false + clippy: false + llvm-tools: true + +steps: + - uses: firestoned/github-actions/rust/verify-toolchain@v1 + with: + require-rustfmt: ${{ matrix.components.rustfmt }} + require-clippy: ${{ matrix.components.clippy }} + require-llvm-tools: ${{ matrix.components.llvm-tools || false }} +``` + +## Related Actions + +- [**rust/setup-rust-build**](../setup-rust-build/README.md) - Set up Rust toolchain with components +- [**rust/lint**](../lint/README.md) - Lint Rust code (uses this action internally) +- [**rust/build-binary**](../build-binary/README.md) - Build Rust binaries (uses this action internally) +- [**rust/build-library**](../build-library/README.md) - Build Rust libraries (uses this action internally) + +## Compatibility + +- **GitHub-hosted runners**: ✅ ubuntu-latest, macos-latest, windows-latest +- **Self-hosted runners**: ✅ Supported (requires Rust toolchain to be pre-installed or installed via setup action) +- **Rust versions**: Any stable, beta, or nightly with requested components available + +## License + +This action is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details. + +--- + +**Author**: Erick Bourgeois +**Organization**: firestoned +**Repository**: [firestoned/github-actions](https://github.com/firestoned/github-actions) diff --git a/rust/verify-toolchain/action.yml b/rust/verify-toolchain/action.yml new file mode 100644 index 0000000..7957d96 --- /dev/null +++ b/rust/verify-toolchain/action.yml @@ -0,0 +1,141 @@ +# Copyright (c) 2025 Erick Bourgeois, firestoned +# SPDX-License-Identifier: MIT + +name: 'Verify Rust Toolchain' +description: 'Verify Rust toolchain and required components are installed' +author: 'Erick Bourgeois ' + +branding: + icon: 'check-circle' + color: 'orange' + +inputs: + require-cargo: + description: 'Require cargo to be available' + required: false + default: 'true' + require-rustfmt: + description: 'Require rustfmt component to be available' + required: false + default: 'false' + require-clippy: + description: 'Require clippy component to be available' + required: false + default: 'false' + require-llvm-tools: + description: 'Require llvm-tools-preview component to be available' + required: false + default: 'false' + +outputs: + rustc-version: + description: 'Rust compiler version (if cargo is available)' + value: ${{ steps.verify.outputs.rustc-version }} + cargo-version: + description: 'Cargo version (if cargo is available)' + value: ${{ steps.verify.outputs.cargo-version }} + rustfmt-version: + description: 'rustfmt version (if rustfmt is available)' + value: ${{ steps.verify.outputs.rustfmt-version }} + clippy-version: + description: 'clippy version (if clippy is available)' + value: ${{ steps.verify.outputs.clippy-version }} + +runs: + using: 'composite' + steps: + - name: Verify Rust toolchain + id: verify + shell: bash + run: | + # Track if any verification fails + VERIFICATION_FAILED=0 + + # Verify cargo + if [ "${{ inputs.require-cargo }}" = "true" ]; then + if ! command -v cargo &> /dev/null; then + echo "❌ Error: Rust toolchain not found" + echo "" + echo "Please set up Rust before using this action:" + echo "" + echo " - uses: firestoned/github-actions/rust/setup-rust-build@v1" + echo "" + echo "Or use the community action:" + echo " - uses: actions-rust-lang/setup-rust-toolchain@v1" + echo "" + VERIFICATION_FAILED=1 + else + RUSTC_VERSION=$(rustc --version) + CARGO_VERSION=$(cargo --version) + echo "rustc-version=$RUSTC_VERSION" >> $GITHUB_OUTPUT + echo "cargo-version=$CARGO_VERSION" >> $GITHUB_OUTPUT + echo "✓ Rust toolchain: $RUSTC_VERSION" + echo "✓ Cargo: $CARGO_VERSION" + fi + fi + + # Verify rustfmt + if [ "${{ inputs.require-rustfmt }}" = "true" ]; then + if ! command -v rustfmt &> /dev/null; then + echo "❌ Error: rustfmt component not found" + echo "" + echo "Install rustfmt:" + echo " rustup component add rustfmt" + echo "" + echo "Or use our setup action with rustfmt included:" + echo " - uses: firestoned/github-actions/rust/setup-rust-build@v1" + echo " with:" + echo " components: rustfmt" + echo "" + VERIFICATION_FAILED=1 + else + RUSTFMT_VERSION=$(rustfmt --version) + echo "rustfmt-version=$RUSTFMT_VERSION" >> $GITHUB_OUTPUT + echo "✓ rustfmt: $RUSTFMT_VERSION" + fi + fi + + # Verify clippy + if [ "${{ inputs.require-clippy }}" = "true" ]; then + if ! command -v cargo-clippy &> /dev/null; then + echo "❌ Error: clippy component not found" + echo "" + echo "Install clippy:" + echo " rustup component add clippy" + echo "" + echo "Or use our setup action with clippy included:" + echo " - uses: firestoned/github-actions/rust/setup-rust-build@v1" + echo " with:" + echo " components: clippy" + echo "" + VERIFICATION_FAILED=1 + else + CLIPPY_VERSION=$(cargo clippy --version) + echo "clippy-version=$CLIPPY_VERSION" >> $GITHUB_OUTPUT + echo "✓ clippy: $CLIPPY_VERSION" + fi + fi + + # Verify llvm-tools-preview + if [ "${{ inputs.require-llvm-tools }}" = "true" ]; then + if ! rustup component list --installed | grep -q "llvm-tools-preview"; then + echo "❌ Error: llvm-tools-preview component not found" + echo "" + echo "Install llvm-tools-preview:" + echo " rustup component add llvm-tools-preview" + echo "" + echo "Or use our setup action:" + echo " - uses: firestoned/github-actions/rust/setup-rust-build@v1" + echo " with:" + echo " components: llvm-tools-preview" + echo "" + VERIFICATION_FAILED=1 + else + echo "✓ llvm-tools-preview: installed" + fi + fi + + # Exit with error if any verification failed + if [ $VERIFICATION_FAILED -eq 1 ]; then + exit 1 + fi