Skip to content

Commit 0277659

Browse files
committed
chore: use rules_workflows for CircleCI config generation
1 parent e71ed0b commit 0277659

File tree

4 files changed

+33
-106
lines changed

4 files changed

+33
-106
lines changed

.aspect/workflows/deps.bzl

Lines changed: 0 additions & 48 deletions
This file was deleted.

.circleci/BUILD.bazel

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,14 @@
1-
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
1+
load("@aspect_rules_workflows//workflows:defs.bzl", "circleci_aspect_workflows_config", "circleci_merged_config")
22

3-
CIRCLECI_ORG = "aspect-build"
4-
5-
CIRCLECI_USER_CONFIG_FILE = "//.circleci:user-config.yml"
6-
7-
alias(
8-
name = "rosetta",
9-
actual = select({
10-
"@bazel_tools//src/conditions:darwin_arm64": "@rosetta_darwin_aarch64//file:rosetta",
11-
"@bazel_tools//src/conditions:darwin_x86_64": "@rosetta_darwin_x86_64//file:rosetta",
12-
"@bazel_tools//src/conditions:linux_aarch64": "@rosetta_linux_aarch64//file:rosetta",
13-
"@bazel_tools//src/conditions:linux_x86_64": "@rosetta_linux_x86_64//file:rosetta",
14-
}),
15-
)
16-
17-
alias(
18-
name = "circleci-config-merge",
19-
actual = select({
20-
"@bazel_tools//src/conditions:darwin_arm64": "@circleci_config_merge_darwin_aarch64//:circleci-config-merge",
21-
"@bazel_tools//src/conditions:darwin_x86_64": "@circleci_config_merge_darwin_x86_64//:circleci-config-merge",
22-
"@bazel_tools//src/conditions:linux_aarch64": "@circleci_config_merge_linux_aarch64//:circleci-config-merge",
23-
"@bazel_tools//src/conditions:linux_x86_64": "@circleci_config_merge_linux_x86_64//:circleci-config-merge",
24-
}),
3+
circleci_aspect_workflows_config(
4+
name = "aspect-workflows-config",
5+
circleci_org = "aspect-build",
256
)
267

27-
genrule(
28-
name = "aspect_workflows_config",
29-
srcs = ["//.aspect/workflows:config.yaml"],
30-
outs = [":aspect-workflows-config.yml"],
31-
cmd = "CIRCLE_PROJECT_USERNAME={0} $(execpath :rosetta) steps --configuration .aspect/workflows/config.yaml --host circleci > $@".format(CIRCLECI_ORG),
32-
tools = [":rosetta"],
33-
)
34-
35-
genrule(
36-
name = "merge_config",
37-
srcs = [
38-
":aspect-workflows-config.yml",
39-
CIRCLECI_USER_CONFIG_FILE,
8+
circleci_merged_config(
9+
name = "config",
10+
circleci_config_files = [
11+
":user-config.yml",
12+
":aspect-workflows-config",
4013
],
41-
outs = [":_config.yml"],
42-
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),
43-
tools = [":circleci-config-merge"],
44-
)
45-
46-
write_source_file(
47-
name = "write_merged_config",
48-
in_file = ":_config.yml",
49-
out_file = "config.yml",
5014
)

.circleci/config.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# GENERATED FILE - DO NOT EDIT!
2-
# Update with: bazel run //.circleci:write_merged_config
2+
# Update with: bazel run //.circleci:config
33
version: 2.1
44
workflows:
55
aspect-workflows:
@@ -134,7 +134,7 @@ jobs:
134134
name: Configure Workflows
135135
- checkout
136136
- run:
137-
command: rm -rf /some/path/artifacts /some/path/testlogs
137+
command: rm -rf /workflows/artifacts /workflows/testlogs
138138
environment:
139139
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml
140140
XDG_CACHE_HOME: /mnt/ephemeral/caches
@@ -161,7 +161,7 @@ jobs:
161161
name: Buildifier
162162
no_output_timeout: 180m
163163
- store_artifacts:
164-
path: /some/path/artifacts
164+
path: /workflows/artifacts
165165
- run:
166166
command: rosetta run finalization
167167
environment:
@@ -193,7 +193,7 @@ jobs:
193193
name: Configure Workflows
194194
- checkout
195195
- run:
196-
command: rm -rf /some/path/artifacts /some/path/testlogs
196+
command: rm -rf /workflows/artifacts /workflows/testlogs
197197
environment:
198198
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml
199199
XDG_CACHE_HOME: /mnt/ephemeral/caches
@@ -220,7 +220,7 @@ jobs:
220220
name: Configure
221221
no_output_timeout: 180m
222222
- store_artifacts:
223-
path: /some/path/artifacts
223+
path: /workflows/artifacts
224224
- run:
225225
command: rosetta run finalization
226226
environment:
@@ -252,7 +252,7 @@ jobs:
252252
name: Configure Workflows
253253
- checkout
254254
- run:
255-
command: rm -rf /some/path/artifacts /some/path/testlogs
255+
command: rm -rf /workflows/artifacts /workflows/testlogs
256256
environment:
257257
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml
258258
XDG_CACHE_HOME: /mnt/ephemeral/caches
@@ -279,7 +279,7 @@ jobs:
279279
name: Format
280280
no_output_timeout: 180m
281281
- store_artifacts:
282-
path: /some/path/artifacts
282+
path: /workflows/artifacts
283283
- run:
284284
command: rosetta run finalization
285285
environment:
@@ -362,7 +362,7 @@ jobs:
362362
name: Configure Workflows
363363
- checkout
364364
- run:
365-
command: rm -rf /some/path/artifacts /some/path/testlogs
365+
command: rm -rf /workflows/artifacts /workflows/testlogs
366366
environment:
367367
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml
368368
XDG_CACHE_HOME: /mnt/ephemeral/caches
@@ -389,7 +389,7 @@ jobs:
389389
name: Test
390390
no_output_timeout: 180m
391391
- store_test_results:
392-
path: /some/path/testlogs
392+
path: /workflows/testlogs
393393
- when:
394394
condition:
395395
and:
@@ -411,9 +411,9 @@ jobs:
411411
name: Delivery Manifest
412412
no_output_timeout: 180m
413413
- store_artifacts:
414-
path: /some/path/testlogs
414+
path: /workflows/testlogs
415415
- store_artifacts:
416-
path: /some/path/artifacts
416+
path: /workflows/artifacts
417417
- run:
418418
command: rosetta run finalization
419419
environment:

WORKSPACE

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ http_archive(
2323
url = "https://github.com/aspect-build/rules_lint/releases/download/v0.7.0/rules_lint-v0.7.0.tar.gz",
2424
)
2525

26+
http_archive(
27+
name = "aspect_rules_workflows",
28+
sha256 = "0168f77fef0917b00f223d1e19db4f4bd5f205d5a97eb0626d6fe1e0ba109c3b",
29+
strip_prefix = "rules_workflows-0.1.0",
30+
url = "https://github.com/aspect-build/rules_workflows/releases/download/v0.1.0/rules_workflows-v0.1.0.tar.gz",
31+
)
32+
2633
http_archive(
2734
name = "bazel_skylib",
2835
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
@@ -253,6 +260,10 @@ fetch_shfmt()
253260

254261
fetch_terraform()
255262

256-
load("//.aspect/workflows:deps.bzl", "fetch_workflows_deps")
263+
load("@aspect_rules_workflows//workflows:dependencies.bzl", "rules_workflows_dependencies")
264+
265+
rules_workflows_dependencies()
266+
267+
load("@aspect_rules_workflows//workflows:repositories.bzl", "fetch_workflows_tools")
257268

258-
fetch_workflows_deps()
269+
fetch_workflows_tools(workflows_version = "5.9.2")

0 commit comments

Comments
 (0)