bitter-ability-32190
05/10/2022, 4:30 PMgenrule
which generates a file which dumps some git info to be included in packaged things.
Trying to use experimental_shell_command
to do the same thing, I unfortunately noticed the command runs in the sandbox and not in repo root.
Alternatively I could use experimental_run_shell_command
but then I can't capture outputs 😞witty-crayon-22786
05/10/2022, 4:47 PMbitter-ability-32190
05/10/2022, 4:49 PMdef build_file_aliases():
def repo_root_path(parse_context):
return lambda: PurePath(parse_context.build_root)
return BuildFileAliases(context_aware_object_factories={"repo_root_path": repo_root_path})
hundreds-father-404
05/10/2022, 5:11 PMbitter-ability-32190
05/10/2022, 5:16 PMbuild_file_dir().parent
which is '.'
witty-crayon-22786
05/10/2022, 5:34 PMgenrule
invalidated in bazel? i’m guessing it wasn’t, and you needed to restart the server?bitter-ability-32190
05/10/2022, 5:36 PMlocal = True,
stamp = 1,
tags = ["no-cache"],
witty-crayon-22786
05/10/2022, 6:51 PMno-cache
would be to skip writing it to the persistent cache, rather than to necessarily not memoize it in memory. would be the same here probably… interaction with git
needs the pants equivalent of cache_scope=PER_SESSION
experimental_shell_command
could be useful… but i’m not sure what the API would look like, since when you set it, you’d still also need to escape the sandbox like you did with the absolute path.bitter-ability-32190
05/10/2022, 6:54 PMwitty-crayon-22786
05/10/2022, 6:56 PMMaybeGitWorktree
gives you PER_SESSION behavior.bitter-ability-32190
05/10/2022, 6:58 PMGitWorkTree
as an EngineAwareReturnType
Exception: Error lifting Process: Absolute paths are not allowed: "/home/joshuacannon/work/techlabs"
result = await Get(
ProcessResult,
Process(
["git", "rev-parse", "HEAD"],
working_directory=build_root.path,
description="Getting Git SHA.",
cache_scope=ProcessCacheScope.PER_SESSION,
),
)
Was trying to whip up a way to have the rule fire per-state change and this was my current pathcurved-television-6568
05/10/2022, 9:01 PMbitter-ability-32190
05/10/2022, 9:19 PMexperimental_shell_command
which generates the file but depends on the address of the target which depends on git state
◦ This means the file correctly gets re-generated every time SHA changes
• Use the latter dependency when building docker imagesMake another plugin which exposes a dummy file codegen which only gets cached per git SHAI feel so evil, yet so good