diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f3020a..db77662 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,3 +87,20 @@ jobs: - run: cargo add serde_as - run: cargo clippy + + cache: + name: Cache + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - id: toolchain + name: Install Rust + uses: ./ + with: + components: clippy + cache: true + cache-workspaces: |- + ./test-workspace + + - run: cargo clippy --manifest-path=./test-workspace/Cargo.toml diff --git a/README.md b/README.md index 03677a4..c87afef 100644 --- a/README.md +++ b/README.md @@ -48,14 +48,15 @@ If no `toolchain` value or toolchain file is present, it will default to `stable First, all items specified in the toolchain file are installed. Afterward, the `components` and `target` specified via inputs are installed in addition to the items from the toolchain file. -| Name | Description | Default | -| ------------ | -------------------------------------------------------------------------------------- | ------------- | -| `toolchain` | Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. | stable | -| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | | -| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | | -| `cache` | Automatically configure Rust cache (using `Swatinem/rust-cache`) | true | -| `matcher` | Enable problem matcher to surface build messages and formatting issues | true | -| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | +| Name | Description | Default | +|--------------------|----------------------------------------------------------------------------------------|---------------| +| `toolchain` | Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. | stable | +| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | | +| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | | +| `cache` | Automatically configure Rust cache (using `Swatinem/rust-cache`) | true | +| `cache-workspaces` | Propagates the value to `Swatinem/rust-cache` | | +| `matcher` | Enable problem matcher to surface build messages and formatting issues | true | +| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | ### RUSTFLAGS diff --git a/action.yml b/action.yml index 997b954..aa618b2 100644 --- a/action.yml +++ b/action.yml @@ -25,6 +25,9 @@ inputs: description: "Automatically configure Rust cache" required: false default: "true" + cache-workspaces: + description: "Paths to multiple Cargo workspaces and their target directories, separated by newlines." + required: false matcher: description: "Enable the Rust problem matcher" required: false @@ -171,3 +174,5 @@ runs: - name: Setup Rust Caching if: inputs.cache == 'true' uses: Swatinem/rust-cache@v2 + with: + workspaces: ${{inputs.cache-workspaces}} diff --git a/test-workspace/Cargo.lock b/test-workspace/Cargo.lock new file mode 100644 index 0000000..f0ff31f --- /dev/null +++ b/test-workspace/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ci" +version = "0.1.0" +dependencies = [ + "serde_as", +] + +[[package]] +name = "serde_as" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee4afe4c5c3b69699c4267ae42b838e911466d7ca0005046adc93ac95bb16dd" diff --git a/test-workspace/Cargo.toml b/test-workspace/Cargo.toml new file mode 100644 index 0000000..431b03d --- /dev/null +++ b/test-workspace/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "ci" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde_as = "0.0.1" diff --git a/test-workspace/src/main.rs b/test-workspace/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/test-workspace/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}