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 PMbitter-ability-32190
05/10/2022, 5:08 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})bitter-ability-32190
05/10/2022, 5:08 PMhundreds-father-404
05/10/2022, 5:11 PMhundreds-father-404
05/10/2022, 5:11 PMbitter-ability-32190
05/10/2022, 5:16 PMbuild_file_dir().parent which is '.'bitter-ability-32190
05/10/2022, 5:24 PMbitter-ability-32190
05/10/2022, 5:33 PMwitty-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"],bitter-ability-32190
05/10/2022, 6:48 PMwitty-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_SESSIONwitty-crayon-22786
05/10/2022, 6:51 PMexperimental_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.witty-crayon-22786
05/10/2022, 6:53 PMbitter-ability-32190
05/10/2022, 6:54 PMwitty-crayon-22786
05/10/2022, 6:56 PMMaybeGitWorktree gives you PER_SESSION behavior.witty-crayon-22786
05/10/2022, 6:57 PMbitter-ability-32190
05/10/2022, 6:58 PMbitter-ability-32190
05/10/2022, 7:21 PMGitWorkTree as an EngineAwareReturnTypebitter-ability-32190
05/10/2022, 7:40 PMException: 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 pathbitter-ability-32190
05/10/2022, 8:53 PMcurved-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 imagesbitter-ability-32190
05/10/2022, 9:21 PMbitter-ability-32190
05/10/2022, 9:28 PMMake another plugin which exposes a dummy file codegen which only gets cached per git SHAI feel so evil, yet so good