Skip to content

Commit

Permalink
merge: #2975
Browse files Browse the repository at this point in the history
2975: build(deps): update Nix & Buck2 dependencies (2023-W47) r=fnichol a=fnichol



Co-authored-by: Fletcher Nichol <[email protected]>
  • Loading branch information
si-bors-ng[bot] and fnichol authored Nov 24, 2023
2 parents 293876c + bb5488c commit 19d6403
Show file tree
Hide file tree
Showing 529 changed files with 26,272 additions and 6,797 deletions.
33 changes: 19 additions & 14 deletions bxl/dependent_targets.bxl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ dependent_targets = bxl_main(
)

# Computes affected targets given various CLI file options.
def _compute_targets(ctx: "bxl_ctx") -> "target_set":
def _compute_targets(ctx: bxl.Context) -> bxl.TargetSet:
targets = utarget_set()

# Add affected targets if global project files are provided.
Expand Down Expand Up @@ -132,8 +132,8 @@ def _compute_targets(ctx: "bxl_ctx") -> "target_set":

return targets

# Filters a `"target_set"` given CLI boolean filter options.
def _filter_targets(ctx: "bxl_ctx", targets: "target_set") -> "target_set":
# Filters a `TargetSet` given CLI boolean filter options.
def _filter_targets(ctx: bxl.Context, targets: bxl.TargetSet) -> bxl.TargetSet:
filtered = utarget_set()
has_filtered = False

Expand Down Expand Up @@ -163,7 +163,7 @@ def _filter_targets(ctx: "bxl_ctx", targets: "target_set") -> "target_set":
filtered = filtered + ctx.uquery().kind("docker_image_release", targets)
if ctx.cli_args.releasable_binary:
has_filtered = True
filtered = filtered + ctx.uquery().attrfilter(
filtered = filtered + ctx.uquery().attrfilter(
"name",
"si",
ctx.uquery().kind("rust_binary", targets),
Expand All @@ -183,7 +183,7 @@ def _filter_targets(ctx: "bxl_ctx", targets: "target_set") -> "target_set":
# Every relevant `:release` target should become a `:promote` target as the promotions are triggered
# from merge to the main branch whereas the releases are triggered in the merge queue pipeline. In
# other words, every necessary release has a 1:1 promotion that needs to happen later.
def _filtered_promote_docker_targets(ctx: "bxl_ctx", targets: "target_set") -> "target_set":
def _filtered_promote_docker_targets(ctx: bxl.Context, targets: bxl.TargetSet) -> bxl.TargetSet:
release_targets = ctx.uquery().kind("docker_image_release", targets)

promote_target_strs = map(
Expand All @@ -195,25 +195,25 @@ def _filtered_promote_docker_targets(ctx: "bxl_ctx", targets: "target_set") -> "
return promote_targets

# Computes a list of targets for all targets in the project.
def _dependent_global_file_targets(ctx: "bxl_ctx") -> "target_set":
def _dependent_global_file_targets(ctx: bxl.Context) -> bxl.TargetSet:
query = "root//..."
results = ctx.uquery().eval(query)

return results

# Computes a list of targets for all targets affected by given `BUCK` files.
def _dependent_buck_file_targets(ctx: "bxl_ctx", buck_files: list[str]) -> "target_set":
def _dependent_buck_file_targets(ctx: bxl.Context, buck_files: list[str]) -> bxl.TargetSet:
buck_target_strs = _buck_files_to_targets(buck_files)
return _rdeps_for_targets(ctx, buck_target_strs)

def _dependent_prelude_file_targets(ctx: "bxl_ctx") -> "target_set":
def _dependent_prelude_file_targets(ctx: bxl.Context) -> bxl.TargetSet:
# TODO(nick,fletcher): we need to figure this out. Use "rbuildfile" maybe?
print("xxx TODO prelude files: {}".format(ctx.cli_args.prelude_file))

return utarget_set()

# Computes a list of target strings for all targets affected by given deleted files.
def _dependent_deleted_file_targets(ctx: "bxl_ctx") -> "target_set":
def _dependent_deleted_file_targets(ctx: bxl.Context) -> bxl.TargetSet:
buck_files = []
for deleted_file in ctx.cli_args.deleted_file:
if ctx.fs.is_file(deleted_file):
Expand All @@ -225,7 +225,7 @@ def _dependent_deleted_file_targets(ctx: "bxl_ctx") -> "target_set":
return _dependent_buck_file_targets(ctx, buck_files)

# Computes a list of targets for all targets affected by given modified files.
def _dependent_modified_file_targets(ctx: "bxl_ctx") -> "target_set":
def _dependent_modified_file_targets(ctx: bxl.Context) -> bxl.TargetSet:
modified_files = map(
_normalize_target_str,
filter(lambda e: ctx.fs.is_file(e), ctx.cli_args.modified_file),
Expand All @@ -241,29 +241,34 @@ def _dependent_modified_file_targets(ctx: "bxl_ctx") -> "target_set":
return _rdeps_for_targets(ctx, map(lambda e: "{}".format(e.label), targets))

# Computes a list of targets which are reverse dependencies of given targets within a universe.
def _rdeps_for_targets(ctx: "bxl_ctx", targets: list[str]) -> "target_set":
def _rdeps_for_targets(ctx: bxl.Context, targets: list[str]) -> bxl.TargetSet:
raw_universe = map(_normalize_target_str, ctx.cli_args.rdeps_universe)
universe = ctx.unconfigured_targets(raw_universe)
raw_targets = map(_normalize_target_str, targets)
targets = ctx.unconfigured_targets(raw_targets)


results = ctx.uquery().rdeps(
universe,
targets,
)
return results

# Returns a file path to the nearest `BUCK` file in parent directories of a given file path.
def _find_parent_buck_file(ctx: "bxl_ctx", deleted_file: str) -> str:
def _find_parent_buck_file(ctx: bxl.Context, deleted_file: str) -> str:
for i in range(1, len(deleted_file.split("/")), 1):
candidate = "{}/{}".format(deleted_file.rsplit("/", i)[0], "BUCK")
if ctx.fs.is_file(candidate):
return candidate
candidate_v2 = "{}/{}".format(deleted_file.rsplit("/", i)[0], "BUCK.v2")
if ctx.fs.is_file(candidate_v2):
return candidate_v2

candidate = "BUCK"
if ctx.fs.is_file(candidate):
return candidate
candidate_v2 = "BUCK.v2"
if ctx.fs.is_file(candidate_v2):
return candidate_v2

return ""

Expand Down Expand Up @@ -295,7 +300,7 @@ def _normalize_target_str(file_str: str) -> str:

# Returns a normlalized file target string for a path string containing a `BUCK` file.
def _normalize_buck_file_target_str(buck_file_str: str) -> str:
normalized = buck_file_str.rstrip("BUCK")
normalized = buck_file_str.rstrip("BUCK.v2").rstrip("BUCK")
if normalized.endswith("//"):
result = normalized + ":"
return result
Expand Down
31 changes: 22 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
# Pin awscli2 to version 2.13.25 until unstable channel has updated pkg
# resolving build error.
#
# References: https://github.com/NixOS/nixpkgs/issues/268737
# References: https://github.com/NixOS/nixpkgs/pull/268590
# See: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=awscli2
awscli2-pin-pkgs.url = "https://github.com/NixOS/nixpkgs/archive/9957cd48326fe8dbd52fdc50dd2502307f188b0d.tar.gz";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
Expand All @@ -17,6 +24,7 @@
self,
nixpkgs,
flake-utils,
awscli2-pin-pkgs,
rust-overlay,
...
}:
Expand All @@ -30,6 +38,7 @@
];

pkgs = import nixpkgs {inherit overlays system;};
awscli2-pin = import awscli2-pin-pkgs {inherit system;};

rustVersion = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain;
rust-toolchain = rustVersion.override {
Expand Down Expand Up @@ -88,7 +97,7 @@
.${system};

langJsExtraPkgs = with pkgs; [
awscli2
awscli2-pin.awscli2
butane
gh
skopeo
Expand Down
Loading

0 comments on commit 19d6403

Please sign in to comment.