From f2e9ed58bdbfcd620ddbb1bdb2af5e676e9a17fd Mon Sep 17 00:00:00 2001 From: gruebel Date: Fri, 12 Jan 2024 18:41:01 +0100 Subject: [PATCH 1/3] add workspaces input field to support non-root projects --- README.md | 17 +++++++++-------- action.yml | 5 +++++ 2 files changed, 14 insertions(+), 8 deletions(-) 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 45eda54..c5b5e5c 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}} From 922cc935eba0313aadf10debf4b777609f674024 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 13 Jan 2024 17:25:41 +0000 Subject: [PATCH 2/3] ci: add cache-workspaces test --- .github/workflows/ci.yml | 17 +++++++++++++++++ test-workspace/Cargo.lock | 16 ++++++++++++++++ test-workspace/Cargo.toml | 9 +++++++++ test-workspace/src/main.rs | 3 +++ 4 files changed, 45 insertions(+) create mode 100644 test-workspace/Cargo.lock create mode 100644 test-workspace/Cargo.toml create mode 100644 test-workspace/src/main.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 521e3f6..96ea814 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,3 +70,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 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!"); +} From 15d0afaad9a057d55c8c95034bfb3aacb990a6b0 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 13 Jan 2024 17:36:31 +0000 Subject: [PATCH 3/3] ci: fix cache test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96ea814..2300322 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,4 +86,4 @@ jobs: cache-workspaces: |- ./test-workspace - - run: cargo clippy + - run: cargo clippy --manifest-path=./test-workspace/Cargo.toml