Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use rules_workflows for CircleCI config generation #622

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions .aspect/workflows/deps.bzl

This file was deleted.

54 changes: 9 additions & 45 deletions .circleci/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,50 +1,14 @@
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
load("@aspect_rules_workflows//workflows:defs.bzl", "circleci_aspect_workflows_config", "circleci_merged_config")

CIRCLECI_ORG = "aspect-build"

CIRCLECI_USER_CONFIG_FILE = "//.circleci:user-config.yml"

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",
}),
)

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",
}),
circleci_aspect_workflows_config(
name = "aspect-workflows-config",
circleci_org = "aspect-build",
)

genrule(
name = "aspect_workflows_config",
srcs = ["//.aspect/workflows:config.yaml"],
outs = [":aspect-workflows-config.yml"],
cmd = "CIRCLE_PROJECT_USERNAME={0} $(execpath :rosetta) steps --configuration .aspect/workflows/config.yaml --host circleci > $@".format(CIRCLECI_ORG),
tools = [":rosetta"],
)

genrule(
name = "merge_config",
srcs = [
":aspect-workflows-config.yml",
CIRCLECI_USER_CONFIG_FILE,
circleci_merged_config(
name = "config",
circleci_config_files = [
":user-config.yml",
":aspect-workflows-config",
],
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),
tools = [":circleci-config-merge"],
)

write_source_file(
name = "write_merged_config",
in_file = ":_config.yml",
out_file = "config.yml",
)
22 changes: 11 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# GENERATED FILE - DO NOT EDIT!
# Update with: bazel run //.circleci:write_merged_config
# Update with: bazel run //.circleci:config
version: 2.1
workflows:
aspect-workflows:
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
name: Configure Workflows
- checkout
- run:
command: rm -rf /some/path/artifacts /some/path/testlogs
command: rm -rf /workflows/artifacts /workflows/testlogs
environment:
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml
XDG_CACHE_HOME: /mnt/ephemeral/caches
Expand All @@ -161,7 +161,7 @@ jobs:
name: Buildifier
no_output_timeout: 180m
- store_artifacts:
path: /some/path/artifacts
path: /workflows/artifacts
- run:
command: rosetta run finalization
environment:
Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:
name: Configure Workflows
- checkout
- run:
command: rm -rf /some/path/artifacts /some/path/testlogs
command: rm -rf /workflows/artifacts /workflows/testlogs
environment:
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml
XDG_CACHE_HOME: /mnt/ephemeral/caches
Expand All @@ -220,7 +220,7 @@ jobs:
name: Configure
no_output_timeout: 180m
- store_artifacts:
path: /some/path/artifacts
path: /workflows/artifacts
- run:
command: rosetta run finalization
environment:
Expand Down Expand Up @@ -252,7 +252,7 @@ jobs:
name: Configure Workflows
- checkout
- run:
command: rm -rf /some/path/artifacts /some/path/testlogs
command: rm -rf /workflows/artifacts /workflows/testlogs
environment:
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml
XDG_CACHE_HOME: /mnt/ephemeral/caches
Expand All @@ -279,7 +279,7 @@ jobs:
name: Format
no_output_timeout: 180m
- store_artifacts:
path: /some/path/artifacts
path: /workflows/artifacts
- run:
command: rosetta run finalization
environment:
Expand Down Expand Up @@ -362,7 +362,7 @@ jobs:
name: Configure Workflows
- checkout
- run:
command: rm -rf /some/path/artifacts /some/path/testlogs
command: rm -rf /workflows/artifacts /workflows/testlogs
environment:
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml
XDG_CACHE_HOME: /mnt/ephemeral/caches
Expand All @@ -389,7 +389,7 @@ jobs:
name: Test
no_output_timeout: 180m
- store_test_results:
path: /some/path/testlogs
path: /workflows/testlogs
- when:
condition:
and:
Expand All @@ -411,9 +411,9 @@ jobs:
name: Delivery Manifest
no_output_timeout: 180m
- store_artifacts:
path: /some/path/testlogs
path: /workflows/testlogs
- store_artifacts:
path: /some/path/artifacts
path: /workflows/artifacts
- run:
command: rosetta run finalization
environment:
Expand Down
15 changes: 13 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ http_archive(
url = "https://github.com/aspect-build/rules_lint/releases/download/v0.7.0/rules_lint-v0.7.0.tar.gz",
)

http_archive(
name = "aspect_rules_workflows",
sha256 = "0168f77fef0917b00f223d1e19db4f4bd5f205d5a97eb0626d6fe1e0ba109c3b",
strip_prefix = "rules_workflows-0.1.0",
url = "https://github.com/aspect-build/rules_workflows/releases/download/v0.1.0/rules_workflows-v0.1.0.tar.gz",
)

http_archive(
name = "bazel_skylib",
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
Expand Down Expand Up @@ -253,6 +260,10 @@ fetch_shfmt()

fetch_terraform()

load("//.aspect/workflows:deps.bzl", "fetch_workflows_deps")
load("@aspect_rules_workflows//workflows:dependencies.bzl", "rules_workflows_dependencies")

rules_workflows_dependencies()

load("@aspect_rules_workflows//workflows:repositories.bzl", "fetch_workflows_tools")

fetch_workflows_deps()
fetch_workflows_tools(workflows_version = "5.9.2")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should rules_workflows be versioned with workflows, so you don't have to choose two separate versions when installing this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly... this is on the agenda for tech leads so lets discuss there

Loading