Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rhysd
Copy link
Contributor

@rhysd rhysd commented Oct 31, 2019

This PR adds example for Cargo, which is an official build tool for Rust toolchain. In addtion to local target build directory, ~/.cargo/registry (packages registry) and ~/.cargo/git (packages index) were necessary to be cached for reusing cached build directory.

I already tried this on my project kiro-editor and cargo test was improved as follows.

  • Before (without cache): job
    • Linux: 1m26s (1m32s in total)
    • macOS: 41s (1m4s in total)
  • After (with cache): job
    • Linux: 13s (33s in total)
    • macOS: 18s (35s in total)

6.6x faster on Linux.

@rhysd rhysd changed the title Add cargo example Add cargo example for Rust project Oct 31, 2019

## License
The scripts and documentation in this project are released under the [MIT License](LICENSE)
The scripts and documentation in this project are released under the [MIT License](LICENSE)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This diff occurred since original file did not have newline at the end of file.

@smorimoto
Copy link
Contributor

smorimoto commented Oct 31, 2019

I prefer to add the hash of the lock file to the key. What do you think?

key: ${{ runner.os }}-cargo-registry-${{ hashFiles(format('{0}{1}', github.workspace, '/Cargo.lock')) }}

or

key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

@rhysd
Copy link
Contributor Author

rhysd commented Oct 31, 2019

@imbsky

Cargo handles outdated libraries in build directory. For example, when we update some dependency and Cargo.lock is changed, cargo test checks local dependencies and rebuilds packages which were updated. So if I'm correct, we don't need to care and can use cached directory always.

Ah, I misunderstood cache behavior. We need to add hash to key. Thank you for the point. I'll fix it. I think **/Cargo.lock is enough since it changes when dependencies change.

@smorimoto
Copy link
Contributor

Oh, I'm glad if my suggestion helped 😁

@smorimoto
Copy link
Contributor

The example has been moved to examples.md. See #13.

@rhysd
Copy link
Contributor Author

rhysd commented Nov 1, 2019

Thanks. I moved the example to examples.md and rebased this branch onto the latest master.

@smorimoto
Copy link
Contributor

Looks good to me.

@chrispat
Copy link
Member

chrispat commented Nov 4, 2019

@rhysd can you resolve your merge conflicts and we will get this mrged today.

Thanks.

@rhysd
Copy link
Contributor Author

rhysd commented Nov 4, 2019

@chrispat I did.

@joshmgross joshmgross merged commit 57f889e into actions:master Nov 4, 2019
joshmgross added a commit that referenced this pull request Nov 4, 2019
* Create CODE_OF_CONDUCT.md

* Update workflow (#1)

* Run workflow on linux, mac, and windows

* Add status badge

* Use npm install instead

* Bump typescript version

* Use node 12.x

* Add Ruby Gem example (#4)

* Add Cocoapods example (#5)

* Add Carthage example (#10)

* Move examples to their own page (#13)

* Minor typo in README (#15)

from `steps.[ID].outupts.cache-hit` to `steps.[ID].outputs.cache-hit`

* Update README.md

* Prevent commands from executing during tests (#21)

* Prevent commands from executing during tests

* Add newline at end of file

* Drop all commands from output

* Link to NuGet lock files documentation (#20)

* Add trailing dash to Maven fallback key (#19)

* Fix README.md (#25)

`restore-keys` had incorrect indentation.

* Exclude documentation from CI tests (#28)

* Ignore all .md files

* Add note about time-based eviction to README (#30)

* Fix typo in error message (#29)

* Time based eviction interval is 1 week (#34)

* Remove cache checksum debug - close #24 (#26)

* Remove cache checksum debug - close #24

*  Remove cache checksum debug on save

* Fix formatting

* Add Go modules example (#18)

* Add Go modules example

* Fix TOC

* Fix repo name in contact email (#41)

* Add Elixir Mix example (#42)

* Add Elixir Mix example

* Fix typo

* Add cargo example for Rust project (#8)

* Add cargo example

* Add hash of Cargo.lock to keys of caches

* Move Rust example to examples.md

* Stop warning when cache is not found (#40)

The cache not being found is a common situation so very visible warning
is a little too much.

* Bump package version

* Release v0.0.2
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.

4 participants