-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Bazel example (Take #2️⃣) #1132
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4b381be
Add example for Bazel
davidB ef11f54
Fix example for Bazel
vorburger 4b8460c
Create separate Linux/macOS examples for Bazel
vorburger 6f1f1e1
Clarify that macos-latest image has bazelisk
vorburger 8f2671f
Merge branch 'main' into bazel-example
vorburger bd9b49b
Merge branch 'main' into bazel-example
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
- [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods) | ||
- [Swift - Swift Package Manager](#swift---swift-package-manager) | ||
- [Swift - Mint](#swift---mint) | ||
- [* - Bazel](#---bazel) | ||
|
||
## C# - NuGet | ||
|
||
|
@@ -657,3 +658,35 @@ steps: | |
restore-keys: | | ||
${{ runner.os }}-mint- | ||
``` | ||
|
||
## * - Bazel | ||
|
||
[`bazelisk`](https://github.com/bazelbuild/bazelisk) does not have be to separately downloaded and installed because it's already included in GitHub's `ubuntu-latest` and `macos-latest` base images. | ||
|
||
### Linux | ||
|
||
```yaml | ||
- name: Cache Bazel | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/bazel | ||
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }} | ||
restore-keys: | | ||
${{ runner.os }}-bazel- | ||
- run: bazelisk test //... | ||
``` | ||
|
||
### macOS | ||
|
||
```yaml | ||
- name: Cache Bazel | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
/private/var/tmp/_bazel_runner/ | ||
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }} | ||
vorburger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
restore-keys: | | ||
${{ runner.os }}-bazel- | ||
Comment on lines
+689
to
+690
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
- run: bazelisk test //... | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd argue that we shouldn't do partial restore with Bazel (at least not that wide), since most of the restored files won't be used anyway, and they are going to be saved in the new cache, wasting cache space and increasing restore times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vsvipul I'm reluctant to make changes to a PR after a LGTM.. before I do, could you comment if you want this to be removed or not? Personally I'm not sure I see the harm in this being there, and in my project it does seem to help quite a bit to speed up things on small dependency changes. It also does not seem consistent, to me, for Bazel to be the only example where there is not
restore-keys
? Isn't what @PiotrSikora alludes to something that could be said for all examples and that is not specific to Bazel per se?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skimming through examples,
deno
doesn't haverestore-keys
either.But if you want to retain it here, I'd probably add more layers of
restore-keys
, e.g.:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its upto you @vorburger . But in most cases we don't include the hashFiles in restore-keys the key with the hashFiles is already accounted for in an exact match. Also, in some cases we don't keep restore-keys where the restored cache might not be very useful. I don't have much clue about bazel so can't comment on that. would leave the decision to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, the
restore-keys
above is wrong, since thosehashFiles
would all evaluate to different hashes, even if the other files didin't change, and there would be no partial match. It should be this instead:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Piotr, I believe I now finally better understand what you are after. You mean that there is a sort of "hierarchy" involved here, yes? Like this, a .bazelversion change causes the entire cache to be thrown away (which would make sense to me as well, yes), but a .bazrlrc version causes some cache reuse, etc.? That's a nice idea - but I'm personally not familiar enough with the cache action to be sure that this will really work like this. Vipul, thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is that i need to know when each of these files change
'.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel'
to allow some kind of reuse for cache and I have never used bazel myself so i'm hesitant to merge something which I'm not sure about. I feel the current state of the PR is good enough for normal users.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM, I don't mind if this gets merged as-is. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vsvipul can I do anything else to now see this get merged as-is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no. this lgtm.