Skip to content

Commit

Permalink
Make git_fetch rule support writing the result to cache
Browse files Browse the repository at this point in the history
Summary:
Writing these to cache has some benefits

1. reading from CAS is way faster (10x for the projects i tested)
2. allows cache hits, which means we may not need to materialize it at all

Reviewed By: rajneesh

Differential Revision: D69550163

fbshipit-source-id: dda00d4f7848d3dc0b889d63f27a637a89b2f6c7
  • Loading branch information
cjhopman authored and facebook-github-bot committed Feb 14, 2025
1 parent a8cda66 commit e2fed69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions prelude/decls/git_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ git_fetch = prelude_rule(
attrs = (
# @unsorted-dict-items
{
"allow_cache_upload": attrs.bool(doc = """
Whether the results of the fetch can be written to the action cache and CAS.
""", default = True),
"repo": attrs.string(doc = """
Url suitable as a git remote.
"""),
Expand Down
1 change: 1 addition & 0 deletions prelude/git/git_fetch.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def git_fetch_impl(ctx: AnalysisContext) -> list[Provider]:
cmd,
category = "git_fetch",
local_only = True,
allow_cache_upload = ctx.attrs.allow_cache_upload,
)

return [DefaultInfo(default_output = work_tree)]

0 comments on commit e2fed69

Please sign in to comment.