Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Rm workspace crates version before caching #147

Merged
merged 1 commit into from
Jun 18, 2023
Merged

feat: Rm workspace crates version before caching #147

merged 1 commit into from
Jun 18, 2023

Conversation

NobodyXu
Copy link
Contributor

@NobodyXu NobodyXu commented Jun 14, 2023

Fixed #146

  • Set all package.version in Cargo.toml to 0.0.0
  • Set {build-, dev-, }dependencies of workspace crates to 0.0.0
  • Remove workspace crates from Cargo.lock before caching
  • Sort all toml objects before hashing them as json

Signed-off-by: Jiahao XU Jiahao_XU@outlook.com

Copy link
Owner

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really interesting approach, and I believe this works, as we are indeed only interested in non-workspace crates.

Can you check that the relevant files are still listed in the info output of the action?

Also, I think you would have to do the same filtering/nulling of workspace dependencies in the Cargo.toml files, as you can have dependencies such as workspace-crate = { path = "path/for/local/development", version = "1.0.0-version-for-installing-via-cratesio" }

@NobodyXu
Copy link
Contributor Author

Can you check that the relevant files are still listed in the info output of the action?

Sorry I am confused.
Can you elaborate on what you would like me to check for?

@NobodyXu NobodyXu requested a review from Swatinem June 17, 2023 13:11
@NobodyXu
Copy link
Contributor Author

Also, I think you would have to do the same filtering/nulling of workspace dependencies in the Cargo.toml files, as you can have dependencies such as workspace-crate = { path = "path/for/local/development", version = "1.0.0-version-for-installing-via-cratesio" }

Thanks!
I've updated the PR and also sort the objects before using JSON.stringify to convert them to strings for hashing.

src/config.ts Show resolved Hide resolved
@Swatinem
Copy link
Owner

Sorry I am confused. Can you elaborate on what you would like me to check for?

By that I mean the summary information that is printed by the action, this thing here:


Cache Configuration
  Workspaces:
      /home/runner/work/rust-cache/rust-cache/tests
  Cache Paths:
      /home/runner/.cargo
      /home/runner/work/rust-cache/rust-cache/tests/target
  Restore Key:
      v0-rust-coverage-0308f3c6
  Cache Key:
      v0-rust-coverage-0308f3c6-f80d3fb4
  .. Prefix:
    - v0-rust-coverage
  .. Environment considered:
    - Rust Version: 1.69.0 x86_64-unknown-linux-gnu (84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc)
    - CARGO_INCREMENTAL
    - CARGO_TERM_COLOR
  .. Lockfiles considered:
    - /home/runner/work/rust-cache/rust-cache/tests/Cargo.lock
    - /home/runner/work/rust-cache/rust-cache/tests/Cargo.toml
    - /home/runner/work/rust-cache/rust-cache/tests/wasm-workspace/Cargo.lock
    - /home/runner/work/rust-cache/rust-cache/tests/wasm-workspace/Cargo.toml
    - /home/runner/work/rust-cache/rust-cache/tests/wasm-workspace/crates/one/Cargo.toml
    - /home/runner/work/rust-cache/rust-cache/tests/wasm-workspace/crates/two/Cargo.toml

It should still list these files in the "lockfiles considered" section. Even though you are not hashing the literal file, but rather using more targeted information from them.

src/config.ts Show resolved Hide resolved
src/config.ts Outdated Show resolved Hide resolved
@NobodyXu
Copy link
Contributor Author

It should still list these files in the "lockfiles considered" section. Even though you are not hashing the literal file, but rather using more targeted information from them.

Thanks!
I've fixed this by adding these files to self.keyFiles after hashing is done.

@NobodyXu NobodyXu requested a review from Swatinem June 18, 2023 02:28
Fixed #146

 - Set all `package.version` in `Cargo.toml` to `0.0.0`
 - Set `{build-, dev-, }dependencies` of workspace crates to `0.0.0`
 - Remove workspace crates from `Cargo.lock` before caching
 - Sort all toml objects before hashing them as json

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@NobodyXu
Copy link
Contributor Author

@Swatinem Sorry I forgot to update the dist/ using npm run prepare, I've updated it now and it should be ready to merge.

@Swatinem Swatinem merged commit 3d40001 into Swatinem:master Jun 18, 2023
@Swatinem
Copy link
Owner

Thanks for sticking with this, great work!

@NobodyXu NobodyXu deleted the feat/rm-workspace-from-dep branch June 18, 2023 07:31
zharinov referenced this pull request in zharinov/verver Jun 19, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache) |
action | minor | `v2.4.0` -> `v2.5.0` |

---

### Release Notes

<details>
<summary>Swatinem/rust-cache</summary>

###
[`v2.5.0`](https://github.com/Swatinem/rust-cache/releases/tag/v2.5.0)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.4.0...v2.5.0)

#### What's Changed

- feat: Rm workspace crates version before caching by
[@&#8203;NobodyXu](https://github.com/NobodyXu) in
[https://github.com/Swatinem/rust-cache/pull/147](https://github.com/Swatinem/rust-cache/pull/147)
- feat: Add hash of `.cargo/config.toml` to key by
[@&#8203;NobodyXu](https://github.com/NobodyXu) in
[https://github.com/Swatinem/rust-cache/pull/149](https://github.com/Swatinem/rust-cache/pull/149)

#### New Contributors

- [@&#8203;NobodyXu](https://github.com/NobodyXu) made their first
contribution in
[https://github.com/Swatinem/rust-cache/pull/147](https://github.com/Swatinem/rust-cache/pull/147)

**Full Changelog**:
Swatinem/rust-cache@v2.4.0...v2.5.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/zharinov/verver).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMjYuMCIsInVwZGF0ZWRJblZlciI6IjM1LjEyNi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
github-merge-queue bot referenced this pull request in knope-dev/knope Jan 12, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache) |
minor | `v2` -> `v2.7.2` |

---

### Release Notes

<details>
<summary>Swatinem/rust-cache (Swatinem/rust-cache)</summary>

###
[`v2.7.2`](https://github.com/Swatinem/rust-cache/releases/tag/v2.7.2)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.7.0...v2.7.2)

#### What's Changed

- Update action runtime to `node20` by
[@&#8203;rhysd](https://github.com/rhysd) in
[https://github.com/Swatinem/rust-cache/pull/175](https://github.com/Swatinem/rust-cache/pull/175)
- Only key by `Cargo.toml` and `Cargo.lock` files of workspace members
by [@&#8203;max-heller](https://github.com/max-heller) in
[https://github.com/Swatinem/rust-cache/pull/180](https://github.com/Swatinem/rust-cache/pull/180)

#### New Contributors

- [@&#8203;rhysd](https://github.com/rhysd) made their first
contribution in
[https://github.com/Swatinem/rust-cache/pull/175](https://github.com/Swatinem/rust-cache/pull/175)
- [@&#8203;max-heller](https://github.com/max-heller) made their first
contribution in
[https://github.com/Swatinem/rust-cache/pull/180](https://github.com/Swatinem/rust-cache/pull/180)

**Full Changelog**:
Swatinem/rust-cache@v2.7.1...v2.7.2

###
[`v2.7.0`](https://github.com/Swatinem/rust-cache/releases/tag/v2.7.0)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.6.2...v2.7.0)

##### What's Changed

- Fix save-if documentation in readme by
[@&#8203;rukai](https://github.com/rukai) in
[https://github.com/Swatinem/rust-cache/pull/166](https://github.com/Swatinem/rust-cache/pull/166)
- Support for `trybuild` and similar macro testing tools by
[@&#8203;neysofu](https://github.com/neysofu) in
[https://github.com/Swatinem/rust-cache/pull/168](https://github.com/Swatinem/rust-cache/pull/168)

##### New Contributors

- [@&#8203;rukai](https://github.com/rukai) made their first
contribution in
[https://github.com/Swatinem/rust-cache/pull/166](https://github.com/Swatinem/rust-cache/pull/166)
- [@&#8203;neysofu](https://github.com/neysofu) made their first
contribution in
[https://github.com/Swatinem/rust-cache/pull/168](https://github.com/Swatinem/rust-cache/pull/168)

**Full Changelog**:
Swatinem/rust-cache@v2.6.2...v2.7.0

###
[`v2.6.2`](https://github.com/Swatinem/rust-cache/releases/tag/v2.6.2)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.6.1...v2.6.2)

##### What's Changed

- dep: Use `smol-toml` instead of `toml` by
[@&#8203;NobodyXu](https://github.com/NobodyXu) in
[https://github.com/Swatinem/rust-cache/pull/164](https://github.com/Swatinem/rust-cache/pull/164)

**Full Changelog**:
Swatinem/rust-cache@v2...v2.6.2

###
[`v2.6.1`](https://github.com/Swatinem/rust-cache/releases/tag/v2.6.1)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.6.0...v2.6.1)

-   Fix hash contributions of `Cargo.lock`/`Cargo.toml` files.

###
[`v2.6.0`](https://github.com/Swatinem/rust-cache/releases/tag/v2.6.0)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.5.1...v2.6.0)

##### What's Changed

- Add "buildjet" as a second `cache-provider` backend
[@&#8203;joroshiba](https://github.com/joroshiba) in
[https://github.com/Swatinem/rust-cache/pull/154](https://github.com/Swatinem/rust-cache/pull/154)
-   Clean up sparse registry index.
-   Do not clean up src of `-sys` crates.
-   Remove `.cargo/credentials.toml` before saving.

##### New Contributors

- [@&#8203;joroshiba](https://github.com/joroshiba) made their first
contribution in
[https://github.com/Swatinem/rust-cache/pull/154](https://github.com/Swatinem/rust-cache/pull/154)

**Full Changelog**:
Swatinem/rust-cache@v2.5.1...v2.6.0

###
[`v2.5.1`](https://github.com/Swatinem/rust-cache/releases/tag/v2.5.1)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.5.0...v2.5.1)

-   Fix hash contribution of `Cargo.lock`.

###
[`v2.5.0`](https://github.com/Swatinem/rust-cache/releases/tag/v2.5.0)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.4.0...v2.5.0)

##### What's Changed

- feat: Rm workspace crates version before caching by
[@&#8203;NobodyXu](https://github.com/NobodyXu) in
[https://github.com/Swatinem/rust-cache/pull/147](https://github.com/Swatinem/rust-cache/pull/147)
- feat: Add hash of `.cargo/config.toml` to key by
[@&#8203;NobodyXu](https://github.com/NobodyXu) in
[https://github.com/Swatinem/rust-cache/pull/149](https://github.com/Swatinem/rust-cache/pull/149)

##### New Contributors

- [@&#8203;NobodyXu](https://github.com/NobodyXu) made their first
contribution in
[https://github.com/Swatinem/rust-cache/pull/147](https://github.com/Swatinem/rust-cache/pull/147)

**Full Changelog**:
Swatinem/rust-cache@v2.4.0...v2.5.0

###
[`v2.4.0`](https://github.com/Swatinem/rust-cache/releases/tag/v2.4.0)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.3.0...v2.4.0)

-   Fix cache key stability.
- Use 8 character hash components to reduce the key length, making it
more readable.

###
[`v2.3.0`](https://github.com/Swatinem/rust-cache/releases/tag/v2.3.0)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.2.1...v2.3.0)

- Add `cache-all-crates` option, which enables caching of crates
installed by workflows.
- Add installed packages to cache key, so changes to workflows that
install rust tools are detected and cached properly.
-   Fix cache restore failures due to upstream bug.
-   Fix `EISDIR` error due to globed directories.
- Update runtime `@actions/cache`, `@actions/io` and dev `typescript`
dependencies.
- Update `npm run prepare` so it creates distribution files with the
right line endings.

###
[`v2.2.1`](https://github.com/Swatinem/rust-cache/releases/tag/v2.2.1)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.2.0...v2.2.1)

- Update `@actions/cache` dependency to fix usage of `zstd` compression.

###
[`v2.2.0`](https://github.com/Swatinem/rust-cache/releases/tag/v2.2.0)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.1.0...v2.2.0)

- Add new `save-if` option to always restore, but only conditionally
save the cache.

###
[`v2.1.0`](https://github.com/Swatinem/rust-cache/releases/tag/v2.1.0)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.0.2...v2.1.0)

- Only hash `Cargo.{lock,toml}` files in the configured workspace
directories.

###
[`v2.0.2`](https://github.com/Swatinem/rust-cache/releases/tag/v2.0.2)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2.0.1...v2.0.2)

-   Avoid calling cargo metadata on pre-cleanup.
-   Added `prefix-key`, `cache-directories` and `cache-targets` options.

###
[`v2.0.1`](https://github.com/Swatinem/rust-cache/releases/tag/v2.0.1)

[Compare
Source](https://github.com/Swatinem/rust-cache/compare/v2...v2.0.1)

- Primarily just updating dependencies to fix GitHub deprecation
notices.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/knope-dev/knope).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjcuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyNy4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
bors added a commit to rust-lang/rust-analyzer that referenced this pull request Mar 21, 2024
internal: Bump rust-cache action

Fixes a Node 16 deprecation warning and also pulls in Swatinem/rust-cache#147, which sounds interesting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rm workspace from Cargo.lock before caching
2 participants