Skip to content

Commit 0ef36fa

Browse files
tomgrEdSchouten
authored andcommitted
Bump bb-storage
This also switches to pre-built protoc toolchains to improve compilation time.
1 parent 5b4f5a6 commit 0ef36fa

File tree

9 files changed

+306
-55
lines changed

9 files changed

+306
-55
lines changed

.bazelrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
build --host_cxxopt=-std=c++17
21
run --workspace_status_command="bash tools/workspace-status.sh"
2+
common --enable_platform_specific_config
3+
common --incompatible_enable_proto_toolchain_resolution
4+
common --protocopt=--fatal_warnings
5+
6+
# Required to make protobuf compile on Windows
7+
common:windows --host_cxxopt=/std:c++17 --define=protobuf_allow_msvc=true

.github/workflows/master.yaml

Lines changed: 184 additions & 19 deletions
Large diffs are not rendered by default.

.github/workflows/pull-requests.yaml

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,136 @@
11
{
22
"jobs": {
33
"build_and_test": {
4-
"runs-on": "ubuntu-latest",
4+
"name": "build_and_test ${{ matrix.host.os }}",
5+
"runs-on": "${{ matrix.host.os }}",
56
"steps": [
67
{
78
"name": "Check out source code",
89
"uses": "actions/checkout@v1"
910
},
1011
{
1112
"name": "Installing Bazel",
12-
"run": "v=$(cat .bazelversion) && curl -L https://github.com/bazelbuild/bazel/releases/download/${v}/bazel-${v}-linux-x86_64 > ~/bazel && chmod +x ~/bazel && echo ~ >> ${GITHUB_PATH}"
13+
"run": "v=$(cat .bazelversion) && curl -L https://github.com/bazelbuild/bazel/releases/download/${v}/bazel-${v}-${{matrix.host.bazel_os}}-x86_64 > ~/bazel && chmod +x ~/bazel && echo ~ >> ${GITHUB_PATH}",
14+
"shell": "bash"
1315
},
1416
{
17+
"if": "matrix.host.platform_name == 'windows_amd64'",
18+
"name": "Override .bazelrc",
19+
"run": "echo \"startup --output_base=D:/bazel_output\" >> .bazelrc"
20+
},
21+
{
22+
"if": "matrix.host.lint",
1523
"name": "Bazel mod tidy",
1624
"run": "bazel mod tidy"
1725
},
1826
{
27+
"if": "matrix.host.lint",
1928
"name": "Gazelle",
2029
"run": "rm -f $(find . -name '*.pb.go' | sed -e 's/[^/]*$/BUILD.bazel/') && bazel run //:gazelle"
2130
},
2231
{
32+
"if": "matrix.host.lint",
2333
"name": "Buildifier",
2434
"run": "bazel run @com_github_bazelbuild_buildtools//:buildifier"
2535
},
2636
{
37+
"if": "matrix.host.lint",
2738
"name": "Gofmt",
2839
"run": "bazel run @cc_mvdan_gofumpt//:gofumpt -- -w -extra $(pwd)"
2940
},
3041
{
42+
"if": "matrix.host.lint",
3143
"name": "Clang format",
3244
"run": "find . -name '*.proto' -exec bazel run @llvm_toolchain_llvm//:bin/clang-format -- -i {} +"
3345
},
3446
{
47+
"if": "matrix.host.lint",
3548
"name": "GitHub workflows",
3649
"run": "bazel build //tools/github_workflows && cp bazel-bin/tools/github_workflows/*.yaml .github/workflows"
3750
},
3851
{
52+
"if": "matrix.host.lint",
3953
"name": "Protobuf generation",
4054
"run": "if [ -d pkg/proto ]; then\n find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true\n bazel build $(bazel query --output=label 'kind(\"go_proto_library\", //...)')\n find bazel-bin/pkg/proto -name '*.pb.go' | while read f; do\n cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|')\n done\nfi\n"
4155
},
4256
{
57+
"if": "matrix.host.lint",
4358
"name": "Embedded asset generation",
4459
"run": "bazel build $(git grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |//\\1:|; s|\"||g; s| .*||' | sort -u)\ngit grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |\\1/|' | while read o; do\n if [ -e \"bazel-bin/$o\" ]; then\n rm -rf \"$o\"\n cp -r \"bazel-bin/$o\" \"$o\"\n find \"$o\" -type f -exec chmod -x {} +\n fi\ndone\n"
4560
},
4661
{
62+
"if": "matrix.host.lint",
4763
"name": "Test style conformance",
4864
"run": "git add . && git diff --exit-code HEAD --"
4965
},
5066
{
67+
"if": "matrix.host.lint",
5168
"name": "Golint",
5269
"run": "bazel run @org_golang_x_lint//golint -- -set_exit_status $(pwd)/..."
5370
},
5471
{
55-
"name": "linux_amd64: build and test",
56-
"run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_amd64 //..."
72+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_amd64'",
73+
"name": "linux_amd64: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}",
74+
"run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_amd64 //..."
5775
},
5876
{
59-
"name": "linux_386: build and test",
60-
"run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_386 //..."
77+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_386'",
78+
"name": "linux_386: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}",
79+
"run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_386 //..."
6180
},
6281
{
63-
"name": "linux_arm: build and test",
64-
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm //..."
82+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm'",
83+
"name": "linux_arm: build${{ matrix.host.platform_name == 'linux_arm' && ' and test' || '' }}",
84+
"run": "bazel ${{ matrix.host.platform_name == 'linux_arm' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm //..."
6585
},
6686
{
67-
"name": "linux_arm64: build and test",
68-
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm64 //..."
87+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm64'",
88+
"name": "linux_arm64: build${{ matrix.host.platform_name == 'linux_arm64' && ' and test' || '' }}",
89+
"run": "bazel ${{ matrix.host.platform_name == 'linux_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm64 //..."
6990
},
7091
{
71-
"name": "darwin_amd64: build and test",
72-
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_amd64 //..."
92+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_amd64'",
93+
"name": "darwin_amd64: build${{ matrix.host.platform_name == 'darwin_amd64' && ' and test' || '' }}",
94+
"run": "bazel ${{ matrix.host.platform_name == 'darwin_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_amd64 //..."
7395
},
7496
{
75-
"name": "darwin_arm64: build and test",
76-
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_arm64 //..."
97+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_arm64'",
98+
"name": "darwin_arm64: build${{ matrix.host.platform_name == 'darwin_arm64' && ' and test' || '' }}",
99+
"run": "bazel ${{ matrix.host.platform_name == 'darwin_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_arm64 //..."
77100
},
78101
{
79-
"name": "freebsd_amd64: build and test",
80-
"run": "bazel build --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_noop_worker //cmd/bb_runner //cmd/bb_scheduler //cmd/bb_virtual_tmp //cmd/bb_worker //cmd/fake_python //cmd/fake_xcrun"
102+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'freebsd_amd64'",
103+
"name": "freebsd_amd64: build${{ matrix.host.platform_name == 'freebsd_amd64' && ' and test' || '' }}",
104+
"run": "bazel ${{ matrix.host.platform_name == 'freebsd_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:freebsd_amd64 //..."
81105
},
82106
{
83-
"name": "windows_amd64: build and test",
84-
"run": "bazel build --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bb_noop_worker //cmd/bb_runner //cmd/bb_scheduler //cmd/bb_virtual_tmp //cmd/bb_worker //cmd/fake_python //cmd/fake_xcrun"
107+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'windows_amd64'",
108+
"name": "windows_amd64: build${{ matrix.host.platform_name == 'windows_amd64' && ' and test' || '' }}",
109+
"run": "bazel ${{ matrix.host.platform_name == 'windows_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:windows_amd64 //..."
85110
}
86-
]
111+
],
112+
"strategy": {
113+
"matrix": {
114+
"host": [
115+
{
116+
"bazel_os": "linux",
117+
"cross_compile": true,
118+
"lint": true,
119+
"os": "ubuntu-latest",
120+
"platform_name": "linux_amd64",
121+
"upload": true
122+
},
123+
{
124+
"bazel_os": "windows",
125+
"cross_compile": false,
126+
"lint": false,
127+
"os": "windows-latest",
128+
"platform_name": "windows_amd64",
129+
"upload": false
130+
}
131+
]
132+
}
133+
}
87134
}
88135
},
89136
"name": "pull-requests",

MODULE.bazel

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ bazel_dep(name = "com_github_buildbarn_bb_storage")
77
bazel_dep(name = "com_github_buildbarn_go_xdr")
88
bazel_dep(name = "gazelle", version = "0.45.0")
99
bazel_dep(name = "googleapis", version = "0.0.0-20250703-f9d6fe4a")
10+
bazel_dep(name = "platforms", version = "1.0.0")
11+
bazel_dep(name = "toolchains_protoc", version = "0.4.3") # must come BEFORE protobuf so the toolchain registration wins
1012
bazel_dep(name = "protobuf", version = "31.1")
1113
bazel_dep(name = "rules_go", version = "0.56.1")
1214
bazel_dep(name = "rules_jsonnet", version = "0.7.2")
@@ -23,7 +25,7 @@ git_override(
2325

2426
git_override(
2527
module_name = "com_github_buildbarn_bb_storage",
26-
commit = "48ed13203b8710ffdde5cc4441d7e58033a76957",
28+
commit = "139cf51268e0870b937633dd8b7fb255225ad9c8",
2729
remote = "https://github.com/buildbarn/bb-storage.git",
2830
)
2931

@@ -48,6 +50,10 @@ single_version_override(
4850
patches = ["//:patches/gazelle/dont-flatten-srcs.diff"],
4951
)
5052

53+
# Match protobuf above, until it ships a pre-built binary toolchain itself
54+
protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
55+
protoc.toolchain(version = "v31.1")
56+
5157
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
5258
go_deps.from_file(go_mod = "//:go.mod")
5359
use_repo(

cmd/bb_runner/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ oci_image(
9090
platform_transition_filegroup(
9191
name = "bb_runner_installer_image_" + arch,
9292
srcs = ["bb_runner_installer_image"],
93+
tags = ["manual"],
9394
target_platform = "@rules_go//go/toolchain:linux_" + arch,
9495
)
9596
for arch in [
@@ -107,6 +108,7 @@ oci_image_index(
107108
"arm64",
108109
]
109110
],
111+
tags = ["manual"],
110112
visibility = ["//visibility:public"],
111113
)
112114

cmd/bb_scheduler/BUILD.bazel

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
2+
load("@aspect_rules_js//js:defs.bzl", "js_run_binary")
13
load("@com_github_buildbarn_bb_remote_execution_npm//:purgecss/package_json.bzl", purgecss_bin = "bin")
24
load("@com_github_buildbarn_bb_storage//tools:container.bzl", "container_push_official", "multiarch_go_image")
35
load("@rules_go//go:def.bzl", "go_binary", "go_library")
@@ -8,8 +10,9 @@ go_library(
810
"build_queue_state_service.go",
911
"main.go",
1012
],
13+
# keep
1114
embedsrcs = [
12-
"stylesheet.css",
15+
":stylesheet",
1316
"templates/error.html",
1417
"templates/footer.html",
1518
"templates/get_build_queue_state.html",
@@ -59,9 +62,11 @@ go_library(
5962
],
6063
)
6164

65+
templates = glob(["templates/*.html"])
66+
6267
filegroup(
6368
name = "templates",
64-
srcs = glob(["templates/*.html"]),
69+
srcs = templates,
6570
)
6671

6772
purgecss_bin.purgecss_binary(
@@ -70,16 +75,37 @@ purgecss_bin.purgecss_binary(
7075
)
7176

7277
# Create a copy of Bootstrap that only contains the style attributes
73-
# used by the HTML templates.
74-
genrule(
75-
name = "stylesheet",
78+
# used by the HTML template.
79+
js_run_binary(
80+
name = "stylesheet_platform",
7681
srcs = [
7782
"@com_github_twbs_bootstrap//:css/bootstrap.min.css",
78-
":templates",
79-
],
83+
] + templates,
8084
outs = ["stylesheet.css"],
81-
cmd = "BAZEL_BINDIR=$(BINDIR) $(location :purgecss) --css $${PWD}/$(location @com_github_twbs_bootstrap//:css/bootstrap.min.css) --content $$(for i in $(locations templates); do echo $${PWD}/$${i}; done) --output $${PWD}/$@",
82-
tools = [":purgecss"],
85+
args = [
86+
# js_run_binary runs in the output dir;
87+
# see https://github.com/aspect-build/rules_js/blob/main/docs/migrate.md#account-for-change-to-working-directory
88+
"--css",
89+
"../../../$(location @com_github_twbs_bootstrap//:css/bootstrap.min.css)",
90+
"--output",
91+
"../../../$(location stylesheet.css)",
92+
"--content",
93+
] + [
94+
"../../../$(location %s)" % f
95+
for f in templates
96+
],
97+
copy_srcs_to_bin = False,
98+
tags = ["manual"],
99+
tool = ":purgecss",
100+
)
101+
102+
# Work around https://github.com/aspect-build/rules_js/issues/2121 by always
103+
# building the stylesheet for the host platform, even if we are cross
104+
# compiling.
105+
platform_transition_filegroup(
106+
name = "stylesheet",
107+
srcs = [":stylesheet_platform"],
108+
target_platform = "@platforms//host",
83109
)
84110

85111
go_binary(

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
cloud.google.com/go/longrunning v0.6.7
1313
github.com/bazelbuild/buildtools v0.0.0-20250715102656-62b9413b08bb
1414
github.com/bazelbuild/remote-apis v0.0.0-20250728120203-e94a7ece2a1e
15-
github.com/buildbarn/bb-storage v0.0.0-20250811173226-48ed13203b87
15+
github.com/buildbarn/bb-storage v0.0.0-20250814113139-139cf51268e0
1616
github.com/buildbarn/go-xdr v0.0.0-20240702182809-236788cf9e89
1717
github.com/golang/protobuf v1.5.4
1818
github.com/google/uuid v1.6.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ github.com/bazelbuild/remote-apis v0.0.0-20250728120203-e94a7ece2a1e/go.mod h1:/
7575
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
7676
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
7777
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
78-
github.com/buildbarn/bb-storage v0.0.0-20250811173226-48ed13203b87 h1:A/kPfCDwlhNpPEJ6qnhPdPmMdeTzlschpM97c76dEik=
79-
github.com/buildbarn/bb-storage v0.0.0-20250811173226-48ed13203b87/go.mod h1:ro83180H9FprjjO6nTjBfhvke3edvWtsLuZkfSSMgpo=
78+
github.com/buildbarn/bb-storage v0.0.0-20250814113139-139cf51268e0 h1:S6iMu1p4Wv7B8nqnowOLeiY8CTW0v9D1zxpH4L2bJmk=
79+
github.com/buildbarn/bb-storage v0.0.0-20250814113139-139cf51268e0/go.mod h1:ro83180H9FprjjO6nTjBfhvke3edvWtsLuZkfSSMgpo=
8080
github.com/buildbarn/go-sha256tree v0.0.0-20250310211320-0f70f20e855b h1:IKUxixGBm9UxobU7c248z0BF0ojG19uoSLz8MFZM/KA=
8181
github.com/buildbarn/go-sha256tree v0.0.0-20250310211320-0f70f20e855b/go.mod h1:e7g3/yWApcg+PpDqd4eQEEV8pexQmfCgK3frP+1Wuvk=
8282
github.com/buildbarn/go-xdr v0.0.0-20240702182809-236788cf9e89 h1:Wtpgk4CIkoEJ7Qx3BwjaMp3TOVv834heqyCC9jMKStM=

pkg/runner/local_runner_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestLocalRunnerCheckReadiness(t *testing.T) {
4949
_, err := runner.CheckReadiness(ctx, &runner_pb.CheckReadinessRequest{
5050
Path: "does_not_exist",
5151
})
52-
testutil.RequirePrefixedStatus(t, status.Error(codes.Internal, "Failed to check existence of path \"does_not_exist\" in build directory: no such file or directory"), err)
52+
testutil.RequirePrefixedStatus(t, status.Error(codes.Internal, "Failed to check existence of path \"does_not_exist\" in build directory: "), err)
5353
})
5454

5555
t.Run("NonExistentDirectory", func(t *testing.T) {
@@ -59,7 +59,7 @@ func TestLocalRunnerCheckReadiness(t *testing.T) {
5959
_, err := runner.CheckReadiness(ctx, &runner_pb.CheckReadinessRequest{
6060
Path: "does/not/exist",
6161
})
62-
testutil.RequirePrefixedStatus(t, status.Error(codes.Internal, "Failed to resolve path \"does/not/exist\" in build directory: no such file or directory"), err)
62+
testutil.RequirePrefixedStatus(t, status.Error(codes.Internal, "Failed to resolve path \"does/not/exist\" in build directory: "), err)
6363
})
6464

6565
t.Run("Success", func(t *testing.T) {
@@ -90,7 +90,7 @@ func TestLocalRunnerRun(t *testing.T) {
9090
defer buildDirectory.Close()
9191

9292
buildDirectoryPathBuilder, scopeWalker := path.EmptyBuilder.Join(path.VoidScopeWalker)
93-
require.NoError(t, path.Resolve(path.UNIXFormat.NewParser(buildDirectoryPath), scopeWalker))
93+
require.NoError(t, path.Resolve(path.LocalFormat.NewParser(buildDirectoryPath), scopeWalker))
9494

9595
var cmdPath string
9696
var getEnvCommand []string

0 commit comments

Comments
 (0)