-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add Aspect Workflows CircleCI configuration (#383)
- Loading branch information
1 parent
6743be4
commit ee22b4b
Showing
6 changed files
with
353 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports_files(["config.yaml"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""Bazel dependencies for Aspect Workflows""" | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive", _http_file = "http_file") | ||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") | ||
|
||
# TODO: move this to a rule set so repositories on Aspect Workflows can avoid this boilerplate | ||
rosetta_version = "5.11.0" | ||
rosetta_integrity = { | ||
"darwin_aarch64": "sha256-zmWdxspunpc9Sz5iZOow0FotE66EGe6WFeHk5+vwMJ8=", | ||
"darwin_x86_64": "sha256-5V6SxvL3QYWbBE/GuwP1ReJwpe0zkznb+j8n4V36O+E=", | ||
"linux_aarch64": "sha256-qwscEgk9kdMnNZ9df+Cw8aPo1ZokIHViS6+6nCSsfSU=", | ||
"linux_x86_64": "sha256-WgDaxOssma7zDHGh+iZ4p3MyBvIBk6m138ZWzR44g2Q=", | ||
} | ||
|
||
# https://github.com/suzuki-shunsuke/circleci-config-merge/releases | ||
# https://dev.to/suzukishunsuke/splitting-circleci-config-yml-10gk | ||
circleci_config_merge_version = "1.1.6" | ||
circleci_config_merge_integrity = { | ||
"darwin_aarch64": "sha256-7cQeLrSVRZR+mQu/njn+x//EIb2bhTV2+J8fafRHpr4=", | ||
"darwin_x86_64": "sha256-vHKDSdDaYK58MaudJ9yOPRKh+OT/LiTQV/9E07RL8qA=", | ||
"linux_aarch64": "sha256-MaXVQmRK9q9LgsfM5ZzxCIIT8rUcOBbzJ8aVDgK6zWs=", | ||
"linux_x86_64": "sha256-3eYJn7dShZD1oiS3cgXfqXwdDzclf/N97A2nh7ZfW+w=", | ||
} | ||
|
||
def http_archive(name, **kwargs): | ||
maybe(_http_archive, name = name, **kwargs) | ||
|
||
def http_file(name, **kwargs): | ||
maybe(_http_file, name = name, **kwargs) | ||
|
||
# buildifier: disable=function-docstring | ||
def fetch_workflows_deps(): | ||
for platform_arch in rosetta_integrity.keys(): | ||
http_file( | ||
name = "rosetta_{}".format(platform_arch), | ||
downloaded_file_path = "rosetta", | ||
executable = True, | ||
integrity = rosetta_integrity[platform_arch], | ||
urls = ["https://static.aspect.build/aspect/{0}/rosetta_real_{1}".format(rosetta_version, platform_arch.replace("aarch64", "arm64"))], | ||
) | ||
|
||
for platform_arch in circleci_config_merge_integrity.keys(): | ||
http_archive( | ||
name = "circleci_config_merge_{}".format(platform_arch), | ||
build_file_content = "exports_files([\"circleci-config-merge\"])", | ||
integrity = circleci_config_merge_integrity[platform_arch], | ||
urls = ["https://github.com/suzuki-shunsuke/circleci-config-merge/releases/download/v{0}/circleci-config-merge_{0}_{1}.tar.gz".format(circleci_config_merge_version, platform_arch.replace("aarch64", "arm64").replace("x86_64", "amd64"))], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file") | ||
|
||
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", | ||
}), | ||
) | ||
|
||
genrule( | ||
name = "aspect_workflows_config", | ||
srcs = ["//.aspect/workflows:config.yaml"], | ||
outs = [":aspect-workflows-config.yml"], | ||
cmd = "CI=1 CIRCLE_PROJECT_USERNAME={0} ASPECT_WORKFLOWS_DISABLE_TRACES_COLLECTION=1 $(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, | ||
], | ||
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", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
# GENERATED FILE - DO NOT EDIT! | ||
# Update with: bazel run //.circleci:write_merged_config | ||
version: 2.1 | ||
workflows: | ||
aspect-workflows: | ||
jobs: | ||
- aw-format: | ||
context: [] | ||
workspace: . | ||
- aw-lint: | ||
context: [] | ||
workspace: . | ||
- aw-test: | ||
context: [] | ||
workspace: . | ||
when: | ||
not: | ||
equal: | ||
- scheduled_pipeline | ||
- << pipeline.trigger_source >> | ||
aspect-workflows-warming: | ||
jobs: | ||
- aw-warming: {} | ||
when: | ||
and: | ||
- equal: | ||
- scheduled_pipeline | ||
- << pipeline.trigger_source >> | ||
- equal: | ||
- aspect-workflows-warming | ||
- << pipeline.schedule.name >> | ||
user-workflow: | ||
jobs: | ||
- user-job | ||
when: | ||
and: | ||
- not: | ||
equal: | ||
- << pipeline.trigger_source >> | ||
- scheduled_pipeline | ||
jobs: | ||
aw-format: | ||
environment: | ||
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> | ||
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type >> | ||
ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows | ||
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml | ||
ASPECT_WORKFLOWS_WORKSPACE: << parameters.workspace >> | ||
XDG_CACHE_HOME: /mnt/ephemeral/caches | ||
machine: true | ||
parameters: | ||
workspace: | ||
type: string | ||
resource_class: aspect-build/aspect-default | ||
steps: | ||
- run: | ||
command: /etc/aspect/workflows/bin/configure_workflows_env | ||
name: Workflows environment | ||
- checkout | ||
- run: | ||
command: rm -rf /workflows/artifacts /workflows/testlogs | ||
name: Prepare archive directories | ||
- run: | ||
command: /etc/aspect/workflows/bin/agent_health_check | ||
name: Agent health check | ||
no_output_timeout: 180m | ||
- run: | ||
command: rosetta run checkout | ||
name: Checkout health | ||
no_output_timeout: 180m | ||
- run: | ||
command: rosetta run format --workspace << parameters.workspace >> | ||
name: Format | ||
no_output_timeout: 180m | ||
- store_artifacts: | ||
path: /workflows/artifacts | ||
- run: | ||
command: rosetta run finalization | ||
name: Finalization | ||
no_output_timeout: 10m | ||
when: always | ||
working_directory: /mnt/ephemeral/workdir | ||
aw-lint: | ||
environment: | ||
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> | ||
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type >> | ||
ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows | ||
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml | ||
ASPECT_WORKFLOWS_WORKSPACE: << parameters.workspace >> | ||
XDG_CACHE_HOME: /mnt/ephemeral/caches | ||
machine: true | ||
parameters: | ||
workspace: | ||
type: string | ||
resource_class: aspect-build/aspect-default | ||
steps: | ||
- run: | ||
command: /etc/aspect/workflows/bin/configure_workflows_env | ||
name: Workflows environment | ||
- checkout | ||
- run: | ||
command: rm -rf /workflows/artifacts /workflows/testlogs | ||
name: Prepare archive directories | ||
- run: | ||
command: /etc/aspect/workflows/bin/agent_health_check | ||
name: Agent health check | ||
no_output_timeout: 180m | ||
- run: | ||
command: rosetta run checkout | ||
name: Checkout health | ||
no_output_timeout: 180m | ||
- run: | ||
command: rosetta run lint --workspace << parameters.workspace >> | ||
name: Lint | ||
no_output_timeout: 180m | ||
- store_artifacts: | ||
path: /workflows/artifacts | ||
- run: | ||
command: rosetta run finalization | ||
name: Finalization | ||
no_output_timeout: 10m | ||
when: always | ||
working_directory: /mnt/ephemeral/workdir | ||
aw-test: | ||
environment: | ||
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> | ||
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type >> | ||
ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows | ||
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml | ||
ASPECT_WORKFLOWS_WORKSPACE: << parameters.workspace >> | ||
XDG_CACHE_HOME: /mnt/ephemeral/caches | ||
machine: true | ||
parameters: | ||
workspace: | ||
type: string | ||
resource_class: aspect-build/aspect-default | ||
steps: | ||
- run: | ||
command: /etc/aspect/workflows/bin/configure_workflows_env | ||
name: Workflows environment | ||
- checkout | ||
- run: | ||
command: rm -rf /workflows/artifacts /workflows/testlogs | ||
name: Prepare archive directories | ||
- run: | ||
command: /etc/aspect/workflows/bin/agent_health_check | ||
name: Agent health check | ||
no_output_timeout: 180m | ||
- run: | ||
command: rosetta run checkout | ||
name: Checkout health | ||
no_output_timeout: 180m | ||
- run: | ||
command: rosetta run test --workspace << parameters.workspace >> | ||
name: Test | ||
no_output_timeout: 180m | ||
- store_test_results: | ||
path: /workflows/testlogs | ||
- store_artifacts: | ||
path: /workflows/testlogs | ||
- store_artifacts: | ||
path: /workflows/artifacts | ||
- run: | ||
command: rosetta run finalization | ||
name: Finalization | ||
no_output_timeout: 10m | ||
when: always | ||
working_directory: /mnt/ephemeral/workdir | ||
aw-warming: | ||
environment: | ||
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> | ||
ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type >> | ||
ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows | ||
ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml | ||
XDG_CACHE_HOME: /mnt/ephemeral/caches | ||
machine: true | ||
resource_class: aspect-build/aspect-warming | ||
steps: | ||
- run: | ||
command: /etc/aspect/workflows/bin/configure_workflows_env | ||
name: Workflows environment | ||
- checkout | ||
- run: | ||
command: /etc/aspect/workflows/bin/agent_health_check | ||
name: Agent health check | ||
no_output_timeout: 180m | ||
- run: | ||
command: rosetta run warming --workspace . | ||
name: Create warming archive for root | ||
no_output_timeout: 180m | ||
- run: | ||
command: /etc/aspect/workflows/bin/warming_archive | ||
name: Archive warming tars | ||
working_directory: /mnt/ephemeral/workdir | ||
user-job: | ||
docker: | ||
- image: cimg/base:2023.03 | ||
steps: | ||
- checkout | ||
- run: echo "Example user CircleCI job that is not generated by Aspect Workflows." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# This is an example of a user CircleCI configuration that is not generated by | ||
# Aspect Workflows. The naming of this file is arbitrary. This configuration is | ||
# merged with the generated Aspect Workflows CircleCI configuration into the | ||
# load bearing load `.circleci/config.yaml` configuration file that is used by | ||
# CircleCI. | ||
# | ||
# To update `.circleci/config.yaml` after editing this file run: | ||
# | ||
# bazel run //.circleci:write_merged_config | ||
# | ||
# | ||
# Aspect Workflows workflow names are all prefixed with "aspect-workflows-". | ||
# These currently include: | ||
# | ||
# - aspect-workflows | ||
# - aspect-workflows-warming | ||
# - aspect-workflows-manual-deliver | ||
# | ||
# Aspect Workflows job names are all prefixed with "aw-". These currently | ||
# include. | ||
# | ||
# - aw-auto-deliver | ||
# - aw-buildifier | ||
# - aw-configure | ||
# - aw-format | ||
# - aw-gazelle | ||
# - aw-manual-deliver | ||
# - aw-test | ||
# - aw-warming | ||
# | ||
# In your user CircleCI configuration, avoid workflow names prefixed with | ||
# `aspect-workflows-` and job names prefixed with `aw-`. Conflicting workflow or | ||
# job names will result in a bad configuration merge. | ||
version: 2.1 | ||
jobs: | ||
user-job: | ||
docker: | ||
- image: cimg/base:2023.03 | ||
steps: | ||
- checkout | ||
- run: echo "Example user CircleCI job that is not generated by Aspect Workflows." | ||
workflows: | ||
user-workflow: | ||
jobs: | ||
- user-job | ||
when: | ||
and: | ||
- not: | ||
equal: | ||
- << pipeline.trigger_source >> | ||
- scheduled_pipeline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# Workaround https://github.com/bazelbuild/bazel-watcher/pull/647 | ||
load("//.aspect/workflows:deps.bzl", "fetch_workflows_deps") | ||
|
||
fetch_workflows_deps() |