bazel-lib/.circleci/BUILD.bazel

62 lines
2.4 KiB
Python
Raw Normal View History

load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
CIRCLECI_ORG = "aspect-build"
CIRCLECI_USER_CONFIG_FILE = "//.circleci:user-config.yml"
2024-02-27 00:58:03 +00:00
not_windows = select({
# There isn't a published rosetta binary for windows as of Feb 2024
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
})
alias(
name = "rosetta",
actual = select({
"@bazel_tools//src/conditions:darwin_arm64": "@rosetta_darwin_aarch64//file:rosetta",
"@bazel_tools//src/conditions:darwin_x86_64": "@rosetta_darwin_x86_64//file:rosetta",
"@bazel_tools//src/conditions:linux_aarch64": "@rosetta_linux_aarch64//file:rosetta",
"@bazel_tools//src/conditions:linux_x86_64": "@rosetta_linux_x86_64//file:rosetta",
}),
2024-02-27 00:58:03 +00:00
target_compatible_with = not_windows,
)
alias(
name = "circleci-config-merge",
actual = select({
"@bazel_tools//src/conditions:darwin_arm64": "@circleci_config_merge_darwin_aarch64//:circleci-config-merge",
"@bazel_tools//src/conditions:darwin_x86_64": "@circleci_config_merge_darwin_x86_64//:circleci-config-merge",
"@bazel_tools//src/conditions:linux_aarch64": "@circleci_config_merge_linux_aarch64//:circleci-config-merge",
"@bazel_tools//src/conditions:linux_x86_64": "@circleci_config_merge_linux_x86_64//:circleci-config-merge",
}),
2024-02-27 00:58:03 +00:00
target_compatible_with = not_windows,
)
genrule(
name = "aspect_workflows_config",
srcs = ["//.aspect/workflows:config.yaml"],
outs = [":aspect-workflows-config.yml"],
cmd = "CI=1 CIRCLE_PROJECT_USERNAME={0} $(execpath :rosetta) steps --configuration .aspect/workflows/config.yaml --host circleci > $@".format(CIRCLECI_ORG),
2024-02-27 00:58:03 +00:00
target_compatible_with = not_windows,
tools = [":rosetta"],
)
genrule(
name = "merge_config",
srcs = [
":aspect-workflows-config.yml",
CIRCLECI_USER_CONFIG_FILE,
],
outs = [":_config.yml"],
cmd = "echo -e '# GENERATED FILE - DO NOT EDIT!\\n# Update with: bazel run //.circleci:write_merged_config' > $@ && $(execpath :circleci-config-merge) merge $(execpath :aspect-workflows-config.yml) $(execpath {0}) >> $@".format(CIRCLECI_USER_CONFIG_FILE),
2024-02-27 00:58:03 +00:00
target_compatible_with = not_windows,
tools = [":circleci-config-merge"],
)
write_source_file(
name = "write_merged_config",
in_file = ":_config.yml",
out_file = "config.yml",
2024-02-27 00:58:03 +00:00
target_compatible_with = not_windows,
)