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

crates installed for CI dependencies aren't cached #134

Closed
stevenh opened this issue May 9, 2023 · 4 comments · Fixed by #137 or #138
Closed

crates installed for CI dependencies aren't cached #134

stevenh opened this issue May 9, 2023 · 4 comments · Fixed by #137 or #138

Comments

@stevenh
Copy link
Contributor

stevenh commented May 9, 2023

If the workflow includes the install of additional cargo crates for example the install of cargo-udeps to validate that unused dependencies don't exist in Cargo.toml the depencent crates for the install don't appear to be cached, resulting in extended workflow build times.

In our case we're seeing over 11mins added to some builds due to this missing items.

It seems like these tool dependencies are been explicitly cleaned out before the cache is persisted?

Another related issue seems to be the key might not be taking into account items in the bin directory. If this is the case when the workflow changes to install additional tools the cache doesn't include them forcing rebuilds until the old cache expires.

@stevenh
Copy link
Contributor Author

stevenh commented May 10, 2023

Would be simple to add an option to override the default behaviour, if this is a correct analysis?

If so I can put together a PR.

@stevenh
Copy link
Contributor Author

stevenh commented May 10, 2023

Reading through the code that generates the lock key it does seem that the contents of the bin directory isn't considered just rust-toolchain, rusttoolchain.toml, Cargo.toml and Cargo.lock which seems to confirm that external tools aren't considered.

One workaround could be to customise key with the hash of the relevant binaries, but that would need everyone to do so.

What about adding the output from cargo install --list to the hash?

@Boshen
Copy link

Boshen commented May 15, 2023

@stevenh For cargo-udeps, I wonder if this helps with your build times (it's working for me)

  check-dependencies:
    name: Check Unused Dependencies
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - uses: dorny/paths-filter@v2
        id: filter
        with:
          filters: |
            src:
              - 'Cargo.lock'

      - name: Install cargo-udeps
        if: steps.filter.outputs.src == 'true'
        uses: taiki-e/install-action@cargo-udeps

      - if: steps.filter.outputs.src == 'true'
        run: cargo udeps

@stevenh
Copy link
Contributor Author

stevenh commented May 16, 2023

Ooo thanks for sharing that @Boshen nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants