Skip to content

Commit de92e55

Browse files
chore(ci): Move subrepo e2e tests to workflows (#675)
Meaningfully faster; more product usage. Includes pre-commit automation for the lazy (me). Need to finish the bzlmod migration to re-enable bzl8. ### Changes are visible to end-users: no ### Test plan This is the test plan --------- Co-authored-by: aspect-marvin[bot] <[email protected]>
1 parent df3d98c commit de92e55

File tree

10 files changed

+121
-32
lines changed

10 files changed

+121
-32
lines changed

.aspect/workflows/config.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,63 @@
11
# See https://docs.aspect.build/workflows/configuration
2+
3+
# This list is maintained by tools/e2e/sync.py
4+
workspaces:
5+
# SYNC: e2e
6+
# {{{
7+
- .
8+
- e2e/cross-repo-610
9+
- e2e/interpreter-version-541
10+
- e2e/repository-rule-deps
11+
- e2e/smoke
12+
- e2e/system-interpreter
13+
- examples/uv_pip_compile
14+
# }}}
15+
216
tasks:
17+
# TODO(arrdem): Rosetta doesn't like HEAD version strings seemingly
18+
# - test:
19+
# name: test-os:linux-bzl:head
20+
# queue: aspect-default
21+
# hooks:
22+
# - type: before_task
23+
# command: |
24+
# rm .bazelversion
25+
# echo "USE_BAZEL_VERSION=last_green" > .bazeliskrc
26+
27+
# TODO(arrdem): Bazel 8+ dropped the original PyInfo etc. which the ancient
28+
# rules_python we have on the WORKSPACE side isn't ready for yet. Once we kill
29+
# off WORKSPACE we can flip these back on but practically this is blocked on
30+
# getting that change in.
31+
#
32+
# - test:
33+
# name: test-os:linux-bzl:latest
34+
# queue: aspect-large
35+
# hooks:
36+
# - type: before_task
37+
# command: |
38+
# rm .bazelversion
39+
# echo "USE_BAZEL_VERSION=latest" > .bazeliskrc
40+
41+
# - test:
42+
# name: test-os:linux-bzl:8
43+
# queue: aspect-large
44+
# hooks:
45+
# - type: before_task
46+
# command: |
47+
# rm .bazelversion
48+
# echo "USE_BAZEL_VERSION=8.2.1" > .bazeliskrc
49+
350
- test:
51+
name: test-os:linux-bzl:7
452
queue: aspect-large
53+
hooks:
54+
- type: before_task
55+
command: |
56+
rm .bazelversion
57+
echo "USE_BAZEL_VERSION=7.6.1" > .bazeliskrc
58+
559
- finalization:
660
queue: aspect-small
61+
762
notifications:
863
github: {}

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ test --test_output=errors
66

77
# TODO(alex): enable
88
common --noenable_bzlmod
9+
# For very recent bazel we have to set this explicitly
10+
common --enable_workspace
911

1012
# Define value used by tests
1113
build --define=SOME_VAR=SOME_VALUE

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
7.4.0
1+
7.6.1
22
# The first line of this file is used by Bazelisk and Bazel to be sure
33
# the right version of Bazel is used to build and test this repo.
44
# This also defines which version is used on CI.

.github/workflows/ci.yaml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,6 @@ concurrency:
2222
cancel-in-progress: ${{ github.ref_name != 'main' }}
2323

2424
jobs:
25-
test:
26-
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@646899086d7aaee8e532540480f3e91e00596234 # 11 Dec 2024
27-
with:
28-
# NB: the root folder is tested with Aspect Workflows on BuildKite, see /.aspect/workflows/config.yaml
29-
folders: |
30-
[
31-
"e2e/cross-repo-610",
32-
"e2e/interpreter-version-541",
33-
"e2e/repository-rule-deps",
34-
"e2e/smoke",
35-
"e2e/system-interpreter",
36-
"examples/uv_pip_compile"
37-
]
38-
# TODO: Build Windows tools and add to toolchain
39-
# TODO(alex): switch the root folder to bzlmod
40-
# TODO: fix remaining folders on Bazel 8
41-
exclude: |
42-
[
43-
{"os": "windows-latest"},
44-
{"folder": "e2e/cross-repo-610", "bzlmodEnabled": false},
45-
{"folder": "e2e/interpreter-version-541", "bzlmodEnabled": false},
46-
{"folder": "e2e/repository-rule-deps", "bzlmodEnabled": false},
47-
{"folder": "e2e/system-interpreter", "bzlmodEnabled": false},
48-
{"folder": "examples/uv_pip_compile", "bzlmodEnabled": false},
49-
{"folder": "e2e/smoke", "bazelversion": "8.0.0"}
50-
]
51-
5225
pre-commit:
5326
runs-on: ubuntu-latest
5427
if: always() && !cancelled()
@@ -114,7 +87,6 @@ jobs:
11487
# on "all matrix jobs were successful".
11588
conclusion:
11689
needs:
117-
- test
11890
- verify-bcr-patches
11991
- test-release
12092
- pre-commit

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,10 @@ repos:
6161
entry: /bin/sh -c '/usr/bin/env bazel run //py/tests/py_venv_image_layer:my_app_arm64_layers'
6262
language: script
6363
require_serial: true
64+
65+
- id: sync-workflows-subrepos
66+
name: Update workflows file for subrepos
67+
# Note that we use a nested shell to discard $@, which is the file list
68+
entry: /usr/bin/env python3 tools/e2e/sync.py
69+
language: script
70+
require_serial: true

py/tests/py_image_layer/my_app_layers_listing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2491,6 +2491,6 @@ files:
24912491
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_image_layer/my_app_bin.runfiles/bazel_tools/tools/
24922492
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/
24932493
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/runfiles/
2494-
- -rwxr-xr-x 0 0 0 21622 Jan 1 2023 ./py/tests/py_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash
2494+
- -rwxr-xr-x 0 0 0 21636 Jan 1 2023 ./py/tests/py_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash
24952495
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_image_layer/my_app_bin.runfiles/pypi_colorama/
24962496
- -rwxr-xr-x 0 0 0 183 Jan 1 2023 ./py/tests/py_image_layer/my_app_bin.venv.pth

py/tests/py_venv_image_layer/my_app_amd64_layers_listing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2523,5 +2523,5 @@ files:
25232523
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/
25242524
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/
25252525
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/runfiles/
2526-
- -rwxr-xr-x 0 0 0 21622 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash
2526+
- -rwxr-xr-x 0 0 0 21636 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash
25272527
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/pypi_colorama/

py/tests/py_venv_image_layer/my_app_arm64_layers_listing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2504,5 +2504,5 @@ files:
25042504
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/
25052505
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/
25062506
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/runfiles/
2507-
- -rwxr-xr-x 0 0 0 21622 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash
2507+
- -rwxr-xr-x 0 0 0 21636 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash
25082508
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/pypi_colorama/

tools/e2e/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ py_binary(
1111
srcs = ["devintegrity.py"],
1212
main = "devintegrity.py",
1313
)
14+
15+
py_binary(
16+
name = "sync",
17+
srcs = ["sync.py"],
18+
main = "sync.py",
19+
)

tools/e2e/sync.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
3+
import re
4+
from os import getenv
5+
from pathlib import Path
6+
7+
WORKSPACES_BLOCK_RE = re.compile(r"""\
8+
# SYNC: e2e
9+
# {{{
10+
(.*?
11+
)# }}}
12+
""", re.MULTILINE | re.DOTALL)
13+
14+
if __name__ == "__main__" or 1:
15+
root = Path(__file__).parent.parent.parent.absolute()
16+
workflows_file = root / ".aspect/workflows/config.yaml"
17+
modules = root.rglob("**/MODULE.bazel")
18+
module_roots = [it.parent.relative_to(root) for it in modules]
19+
20+
# Module roots that we know we can't run in workflows
21+
ignored_roots = [
22+
Path("e2e/use_release"),
23+
Path("e2e/cross-repo-610/subrepo_a"),
24+
Path("e2e/cross-repo-610/subrepo_b"),
25+
]
26+
27+
module_roots = [
28+
r for r in module_roots if r not in ignored_roots
29+
]
30+
module_roots = sorted(module_roots)
31+
32+
33+
with open(workflows_file, "r") as fp:
34+
config = fp.read()
35+
36+
def _handler(m):
37+
return m.group(0).replace(m.group(1), "".join([" - {}\n".format(it) for it in module_roots]))
38+
39+
new_config = re.sub(WORKSPACES_BLOCK_RE, _handler, config)
40+
41+
if config != new_config:
42+
print(new_config)
43+
44+
with open(workflows_file, "w") as fp:
45+
fp.write(new_config)
46+
47+
exit(1)

0 commit comments

Comments
 (0)