Skip to content

Commit 024f9f8

Browse files
gregmagolanclaude
andcommitted
chore: migrate to Aspect CLI AXL tasks on ephemeral GHA runners
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent cef068f commit 024f9f8

13 files changed

Lines changed: 176 additions & 84 deletions

File tree

.aspect/config.axl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Aspect CLI configuration."""
2+
3+
load("@aspect//feature/artifacts.axl", "ArtifactUpload")
4+
load("@aspect//format.axl", "format")
5+
load("@aspect//traits.axl", "BazelTrait")
6+
7+
# `aspect buildifier` — alias of `aspect format` preset to the Starlark-only
8+
# formatter target. CI and local users can run `aspect buildifier` instead
9+
# of `aspect format --formatter-target=//tools/format:buildifier`.
10+
buildifier = format.alias(
11+
defaults = {
12+
"formatter_target": "//tools/format:buildifier",
13+
},
14+
summary = "Format Starlark files using buildifier.",
15+
)
16+
17+
def config(ctx: ConfigContext):
18+
is_ci = bool(ctx.std.env.var("CI"))
19+
20+
if is_ci:
21+
ctx.traits[BazelTrait].extra_flags.extend([
22+
"--config=ci",
23+
])
24+
25+
# Register the buildifier alias as a real CLI command.
26+
ctx.tasks.add(buildifier)
27+
28+
# Enable artifact uploads for testlogs, profile, and BEP.
29+
# upload_test_logs="failed" — only the logs from failing tests are useful.
30+
ctx.features[ArtifactUpload].args.upload_test_logs = "failed"
31+
ctx.features[ArtifactUpload].args.upload_profile = True
32+
ctx.features[ArtifactUpload].args.upload_bep = True

.aspect/version.axl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version("2026.21.44")

.aspect/workflows/config.yaml

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

.bazelrc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ common:release --compilation_mode=opt
3737
common:release --@rules_rust//rust/settings:lto=fat
3838
common:release --@rules_rust//:extra_rustc_flags=-Cpanic=abort
3939

40-
# Load any settings specific to the current user.
41-
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
42-
# This needs to be last statement in this
43-
# config, as the user configuration should be able to overwrite flags from this file.
44-
# See https://docs.bazel.build/versions/master/best-practices.html#bazelrc
45-
# (Note that we use .bazelrc.user so the file appears next to .bazelrc in directory listing,
46-
# rather than user.bazelrc as suggested in the Bazel docs)
47-
try-import %workspace%/.bazelrc.user
48-
4940
# Uncomment to enable verbose diagnostics for uv repository rules (sdist builds, git archives)
5041
# common --repo_env=RULES_PY_UV_VERBOSE=1
42+
43+
# Build without the bytes
44+
common:ci --remote_download_outputs=minimal
45+
common:ci --nobuild_runfile_links
46+
47+
# Override the preset's `--lockfile_mode=error` on CI since we don't
48+
# yet commit MODULE.bazel.lock — see .gitignore.
49+
common:ci --lockfile_mode=off
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI - Aspect Workflows
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
permissions:
11+
id-token: write
12+
13+
env:
14+
ASPECT_API_TOKEN: ${{ secrets.ASPECT_API_TOKEN }}
15+
INSTALL_ASPECT_LAUNCHER_VERSION: 2026.21.44
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
buildifier:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v6
26+
- uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0
27+
with:
28+
bazelisk-cache: true
29+
disk-cache: ${{ github.workflow }}-buildifier
30+
repository-cache: true
31+
external-cache: true
32+
- name: Buildifier
33+
run: |
34+
curl -fsSL https://install.aspect.build | bash -s -- "$INSTALL_ASPECT_LAUNCHER_VERSION"
35+
aspect buildifier --task-key=buildifier
36+
gazelle:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v6
40+
- uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0
41+
with:
42+
bazelisk-cache: true
43+
disk-cache: ${{ github.workflow }}-gazelle
44+
repository-cache: true
45+
external-cache: true
46+
- name: Gazelle
47+
run: |
48+
curl -fsSL https://install.aspect.build | bash -s -- "$INSTALL_ASPECT_LAUNCHER_VERSION"
49+
aspect gazelle --task-key=gazelle
50+
test:
51+
name: test (${{ matrix.workspace.path }}, ${{ matrix.bazel.id }})
52+
runs-on: ubuntu-latest
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
workspace:
57+
- { path: ".", slug: "root" }
58+
- { path: "e2e", slug: "e2e" }
59+
- { path: "examples/uv_pip_compile", slug: "examples-uv_pip_compile" }
60+
bazel:
61+
- { id: "bazel-8", version: "8.x", flags: "--bazel-flag=--test_tag_filters=-skip-on-bazel8" }
62+
- { id: "bazel-9", version: "9.*", flags: "--bazel-flag=--test_tag_filters=-skip-on-bazel9" }
63+
exclude:
64+
- { workspace: { slug: "examples-uv_pip_compile" }, bazel: { id: "bazel-9" } }
65+
env:
66+
USE_BAZEL_VERSION: ${{ matrix.bazel.version }}
67+
steps:
68+
- uses: actions/checkout@v6
69+
- uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0
70+
with:
71+
bazelisk-cache: true
72+
disk-cache: ${{ github.workflow }}-test-${{ matrix.workspace.slug }}-${{ matrix.bazel.id }}
73+
repository-cache: true
74+
external-cache: true
75+
- name: Test
76+
working-directory: ${{ matrix.workspace.path }}
77+
run: |
78+
curl -fsSL https://install.aspect.build | bash -s -- "$INSTALL_ASPECT_LAUNCHER_VERSION"
79+
aspect test --task-key=test-${{ matrix.workspace.slug }}-${{ matrix.bazel.id }} ${{ matrix.bazel.flags }} -- //...

.gitignore

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@
77
.DS_Store
88
.agent*
99
.gemini*
10-
.bazelrc.user
1110
.idea
1211
.ijwb
1312
.venv/
14-
MODULE.bazel.lock
1513
node_modules/
14+
15+
# Bazel's MODULE lockfile isn't ready to check in yet as of Bazel 7.1.
16+
# Do allow for it to be created, however, since it gives a performance boost for local development.
17+
# [Store resolved repository attributes in the Bzlmod lockfile](https://github.com/bazelbuild/bazel/issues/19026)
18+
# [MODULE.bazel.lock file contains user specific paths](https://github.com/bazelbuild/bazel/issues/19621)
19+
# [Consider skipping bazel_tools@_ from lockfile](https://github.com/bazelbuild/bazel/issues/19971)
20+
# [MODULE.bazel.lock file "reads through" already-locked package manager](https://github.com/bazelbuild/bazel/issues/20272)
21+
# [moduleFileHash in MODULE.bazel.lock causes frequent Git merge conflicts](https://github.com/bazelbuild/bazel/issues/20369)
22+
MODULE.bazel.lock

BUILD.bazel

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
load("@aspect_gazelle_prebuilt//:def.bzl", "aspect_gazelle")
21
load("@bazel_skylib//rules:build_test.bzl", "build_test")
3-
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
42
load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements")
53
load("//uv:defs.bzl", "gazelle_python_manifest")
64

@@ -33,32 +31,14 @@ gazelle_python_manifest(
3331
],
3432
)
3533

36-
aspect_gazelle(
34+
alias(
3735
name = "gazelle",
38-
languages = ["starlark"],
39-
with_check = True,
36+
actual = "//tools/gazelle",
4037
)
4138

42-
# Snapshot directories hold copies of generated repo-rule output and aren't
43-
# real Starlark sources — see .gitattributes / //uv/private/uv_hub:snapshots.
44-
_BUILDIFIER_EXCLUDES = [
45-
"./uv/private/uv_hub/snapshots/*",
46-
"./e2e/snapshots/*",
47-
]
48-
49-
buildifier(
39+
alias(
5040
name = "buildifier",
51-
exclude_patterns = _BUILDIFIER_EXCLUDES,
52-
lint_mode = "fix",
53-
mode = "fix",
54-
)
55-
56-
buildifier(
57-
name = "buildifier.check",
58-
exclude_patterns = _BUILDIFIER_EXCLUDES,
59-
# TODO: enable lint_mode = "warn" once existing warnings are fixed
60-
lint_mode = "",
61-
mode = "diff",
41+
actual = "//tools/format:buildifier",
6242
)
6343

6444
compile_pip_requirements(

MODULE.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ register_toolchains(
140140

141141
bazel_dep(name = "aspect_gazelle_prebuilt", version = "0.0.8", dev_dependency = True)
142142
bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.2", dev_dependency = True)
143+
bazel_dep(name = "aspect_rules_lint", version = "1.13.0", dev_dependency = True)
143144

144145
bazel_dep(name = "bazelrc-preset.bzl", version = "1.9.2", dev_dependency = IS_RELEASE)
145146
bazel_dep(name = "bazel_env.bzl", version = "0.5.0", dev_dependency = IS_RELEASE)
@@ -288,3 +289,9 @@ http_file(
288289
sha256 = "0523026398aea9c8b5f7a4a6d5c0829c285b4fbd960c17b5967a369342e21e01",
289290
urls = ["https://files.pythonhosted.org/packages/10/96/36c136013c4a6ecb8c6aa3eed66e6dcea838f85fd80e1446499f1dabfac7/sqlparse-0.4.0-py3-none-any.whl"],
290291
)
292+
293+
# Transitive rules_go and rules_nodejs versions reference legacy global
294+
# symbols (CcInfo, incompatible_use_toolchain_transition) that Bazel 9
295+
# removed. Pin to versions that load via explicit `load(...)` statements.
296+
bazel_dep(name = "rules_go", version = "0.60.0", dev_dependency = True)
297+
bazel_dep(name = "rules_nodejs", version = "6.7.4", dev_dependency = True)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# aspect_rules_py
22

3+
> [!NOTE]
4+
> This repository uses the [Aspect CLI](https://github.com/aspect-build/aspect-cli) for CI and local development.
5+
> See the [docs](https://docs.aspect.build/cli/overview) and [install instructions](https://docs.aspect.build/cli/install) to get started.
6+
37
> [!WARNING]
48
> **This is the 2.x ALPHA branch.** APIs and behavior may change without notice. For stable documentation, see the [1.x branch](https://github.com/aspect-build/rules_py/tree/1.x).
59

e2e/.bazelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ common --java_runtime_version=remotejdk_11
2525
# supports-path-mapping. Actions that declare the execution requirement get
2626
# configuration-stripped cache keys; those that don't still work normally.
2727
build --experimental_output_paths=strip
28+
29+
# Build without the bytes
30+
common:ci --remote_download_outputs=minimal
31+
common:ci --nobuild_runfile_links
32+
33+
# Override the preset's `--lockfile_mode=error` on CI since we don't
34+
# yet commit MODULE.bazel.lock — see .gitignore.
35+
common:ci --lockfile_mode=off

0 commit comments

Comments
 (0)