diff --git a/.bazelrc b/.bazelrc index 506f05c..7dd238d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,2 +1,7 @@ -build --host_cxxopt=-std=c++17 run --workspace_status_command="bash tools/workspace-status.sh" +common --enable_platform_specific_config +common --incompatible_enable_proto_toolchain_resolution +common --protocopt=--fatal_warnings + +# Required to make protobuf compile on Windows +common:windows --host_cxxopt=/std:c++17 --define=protobuf_allow_msvc=true diff --git a/.github/workflows/master.yaml b/.github/workflows/master.yaml index e9ae24e..e9107a1 100644 --- a/.github/workflows/master.yaml +++ b/.github/workflows/master.yaml @@ -1,7 +1,8 @@ { "jobs": { "build_and_test": { - "runs-on": "ubuntu-latest", + "name": "build_and_test ${{ matrix.host.os }}", + "runs-on": "${{ matrix.host.os }}", "steps": [ { "name": "Check out source code", @@ -9,57 +10,76 @@ }, { "name": "Installing Bazel", - "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}" + "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}", + "shell": "bash" }, { + "if": "matrix.host.platform_name == 'windows_amd64'", + "name": "Override .bazelrc", + "run": "echo \"startup --output_base=D:/bazel_output\" >> .bazelrc" + }, + { + "if": "matrix.host.lint", "name": "Bazel mod tidy", "run": "bazel mod tidy" }, { + "if": "matrix.host.lint", "name": "Gazelle", "run": "rm -f $(find . -name '*.pb.go' | sed -e 's/[^/]*$/BUILD.bazel/') && bazel run //:gazelle" }, { + "if": "matrix.host.lint", "name": "Buildifier", "run": "bazel run @com_github_bazelbuild_buildtools//:buildifier" }, { + "if": "matrix.host.lint", "name": "Gofmt", "run": "bazel run @cc_mvdan_gofumpt//:gofumpt -- -w -extra $(pwd)" }, { + "if": "matrix.host.lint", "name": "Clang format", "run": "find . -name '*.proto' -exec bazel run @llvm_toolchain_llvm//:bin/clang-format -- -i {} +" }, { + "if": "matrix.host.lint", "name": "GitHub workflows", "run": "bazel build //tools/github_workflows && cp bazel-bin/tools/github_workflows/*.yaml .github/workflows" }, { + "if": "matrix.host.lint", "name": "Protobuf generation", "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" }, { + "if": "matrix.host.lint", "name": "Embedded asset generation", "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" }, { + "if": "matrix.host.lint", "name": "Test style conformance", "run": "git add . && git diff --exit-code HEAD --" }, { + "if": "matrix.host.lint", "name": "Golint", "run": "bazel run @org_golang_x_lint//golint -- -set_exit_status $(pwd)/..." }, { - "name": "linux_amd64: build and test", - "run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_amd64 //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_amd64'", + "name": "linux_amd64: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_amd64 //..." }, { + "if": "matrix.host.upload", "name": "linux_amd64: copy bb_browser", "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_amd64 //cmd/bb_browser $(pwd)/bb_browser" }, { + "if": "matrix.host.upload", "name": "linux_amd64: upload bb_browser", "uses": "actions/upload-artifact@v4", "with": { @@ -68,14 +88,17 @@ } }, { - "name": "linux_386: build and test", - "run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_386 //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_386'", + "name": "linux_386: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_386 //..." }, { + "if": "matrix.host.upload", "name": "linux_386: copy bb_browser", "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_386 //cmd/bb_browser $(pwd)/bb_browser" }, { + "if": "matrix.host.upload", "name": "linux_386: upload bb_browser", "uses": "actions/upload-artifact@v4", "with": { @@ -84,14 +107,17 @@ } }, { - "name": "linux_arm: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm'", + "name": "linux_arm: build${{ matrix.host.platform_name == 'linux_arm' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'linux_arm' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm //..." }, { + "if": "matrix.host.upload", "name": "linux_arm: copy bb_browser", "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_arm //cmd/bb_browser $(pwd)/bb_browser" }, { + "if": "matrix.host.upload", "name": "linux_arm: upload bb_browser", "uses": "actions/upload-artifact@v4", "with": { @@ -100,14 +126,17 @@ } }, { - "name": "linux_arm64: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm64 //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm64'", + "name": "linux_arm64: build${{ matrix.host.platform_name == 'linux_arm64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'linux_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm64 //..." }, { + "if": "matrix.host.upload", "name": "linux_arm64: copy bb_browser", "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_arm64 //cmd/bb_browser $(pwd)/bb_browser" }, { + "if": "matrix.host.upload", "name": "linux_arm64: upload bb_browser", "uses": "actions/upload-artifact@v4", "with": { @@ -116,14 +145,17 @@ } }, { - "name": "darwin_amd64: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:darwin_amd64 //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_amd64'", + "name": "darwin_amd64: build${{ matrix.host.platform_name == 'darwin_amd64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'darwin_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_amd64 //..." }, { + "if": "matrix.host.upload", "name": "darwin_amd64: copy bb_browser", "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:darwin_amd64 //cmd/bb_browser $(pwd)/bb_browser" }, { + "if": "matrix.host.upload", "name": "darwin_amd64: upload bb_browser", "uses": "actions/upload-artifact@v4", "with": { @@ -132,14 +164,17 @@ } }, { - "name": "darwin_arm64: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:darwin_arm64 //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_arm64'", + "name": "darwin_arm64: build${{ matrix.host.platform_name == 'darwin_arm64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'darwin_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_arm64 //..." }, { + "if": "matrix.host.upload", "name": "darwin_arm64: copy bb_browser", "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:darwin_arm64 //cmd/bb_browser $(pwd)/bb_browser" }, { + "if": "matrix.host.upload", "name": "darwin_arm64: upload bb_browser", "uses": "actions/upload-artifact@v4", "with": { @@ -148,14 +183,17 @@ } }, { - "name": "freebsd_amd64: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_browser" + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'freebsd_amd64'", + "name": "freebsd_amd64: build${{ matrix.host.platform_name == 'freebsd_amd64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'freebsd_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:freebsd_amd64 //..." }, { + "if": "matrix.host.upload", "name": "freebsd_amd64: copy bb_browser", "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_browser $(pwd)/bb_browser" }, { + "if": "matrix.host.upload", "name": "freebsd_amd64: upload bb_browser", "uses": "actions/upload-artifact@v4", "with": { @@ -164,14 +202,17 @@ } }, { - "name": "windows_amd64: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bb_browser" + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'windows_amd64'", + "name": "windows_amd64: build${{ matrix.host.platform_name == 'windows_amd64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'windows_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:windows_amd64 //..." }, { + "if": "matrix.host.upload", "name": "windows_amd64: copy bb_browser", "run": "rm -f bb_browser.exe && bazel run --run_under cp --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bb_browser $(pwd)/bb_browser.exe" }, { + "if": "matrix.host.upload", "name": "windows_amd64: upload bb_browser", "uses": "actions/upload-artifact@v4", "with": { @@ -183,14 +224,38 @@ "env": { "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}" }, + "if": "matrix.host.upload", "name": "Install Docker credentials", "run": "echo \"${GITHUB_TOKEN}\" | docker login ghcr.io -u $ --password-stdin" }, { + "if": "matrix.host.upload", "name": "Push container bb_browser:bb_browser", "run": "bazel run --stamp //cmd/bb_browser:bb_browser_container_push" } - ] + ], + "strategy": { + "matrix": { + "host": [ + { + "bazel_os": "linux", + "cross_compile": true, + "lint": true, + "os": "ubuntu-latest", + "platform_name": "linux_amd64", + "upload": true + }, + { + "bazel_os": "windows", + "cross_compile": false, + "lint": false, + "os": "windows-latest", + "platform_name": "windows_amd64", + "upload": false + } + ] + } + } } }, "name": "master", diff --git a/.github/workflows/pull-requests.yaml b/.github/workflows/pull-requests.yaml index 5a47fba..7c73cb9 100644 --- a/.github/workflows/pull-requests.yaml +++ b/.github/workflows/pull-requests.yaml @@ -1,7 +1,8 @@ { "jobs": { "build_and_test": { - "runs-on": "ubuntu-latest", + "name": "build_and_test ${{ matrix.host.os }}", + "runs-on": "${{ matrix.host.os }}", "steps": [ { "name": "Check out source code", @@ -9,81 +10,127 @@ }, { "name": "Installing Bazel", - "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}" + "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}", + "shell": "bash" }, { + "if": "matrix.host.platform_name == 'windows_amd64'", + "name": "Override .bazelrc", + "run": "echo \"startup --output_base=D:/bazel_output\" >> .bazelrc" + }, + { + "if": "matrix.host.lint", "name": "Bazel mod tidy", "run": "bazel mod tidy" }, { + "if": "matrix.host.lint", "name": "Gazelle", "run": "rm -f $(find . -name '*.pb.go' | sed -e 's/[^/]*$/BUILD.bazel/') && bazel run //:gazelle" }, { + "if": "matrix.host.lint", "name": "Buildifier", "run": "bazel run @com_github_bazelbuild_buildtools//:buildifier" }, { + "if": "matrix.host.lint", "name": "Gofmt", "run": "bazel run @cc_mvdan_gofumpt//:gofumpt -- -w -extra $(pwd)" }, { + "if": "matrix.host.lint", "name": "Clang format", "run": "find . -name '*.proto' -exec bazel run @llvm_toolchain_llvm//:bin/clang-format -- -i {} +" }, { + "if": "matrix.host.lint", "name": "GitHub workflows", "run": "bazel build //tools/github_workflows && cp bazel-bin/tools/github_workflows/*.yaml .github/workflows" }, { + "if": "matrix.host.lint", "name": "Protobuf generation", "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" }, { + "if": "matrix.host.lint", "name": "Embedded asset generation", "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" }, { + "if": "matrix.host.lint", "name": "Test style conformance", "run": "git add . && git diff --exit-code HEAD --" }, { + "if": "matrix.host.lint", "name": "Golint", "run": "bazel run @org_golang_x_lint//golint -- -set_exit_status $(pwd)/..." }, { - "name": "linux_amd64: build and test", - "run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_amd64 //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_amd64'", + "name": "linux_amd64: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_amd64 //..." }, { - "name": "linux_386: build and test", - "run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_386 //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_386'", + "name": "linux_386: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_386 //..." }, { - "name": "linux_arm: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm'", + "name": "linux_arm: build${{ matrix.host.platform_name == 'linux_arm' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'linux_arm' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm //..." }, { - "name": "linux_arm64: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm64 //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm64'", + "name": "linux_arm64: build${{ matrix.host.platform_name == 'linux_arm64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'linux_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm64 //..." }, { - "name": "darwin_amd64: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:darwin_amd64 //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_amd64'", + "name": "darwin_amd64: build${{ matrix.host.platform_name == 'darwin_amd64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'darwin_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_amd64 //..." }, { - "name": "darwin_arm64: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:darwin_arm64 //..." + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_arm64'", + "name": "darwin_arm64: build${{ matrix.host.platform_name == 'darwin_arm64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'darwin_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_arm64 //..." }, { - "name": "freebsd_amd64: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_browser" + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'freebsd_amd64'", + "name": "freebsd_amd64: build${{ matrix.host.platform_name == 'freebsd_amd64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'freebsd_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:freebsd_amd64 //..." }, { - "name": "windows_amd64: build and test", - "run": "bazel build --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bb_browser" + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'windows_amd64'", + "name": "windows_amd64: build${{ matrix.host.platform_name == 'windows_amd64' && ' and test' || '' }}", + "run": "bazel ${{ matrix.host.platform_name == 'windows_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:windows_amd64 //..." } - ] + ], + "strategy": { + "matrix": { + "host": [ + { + "bazel_os": "linux", + "cross_compile": true, + "lint": true, + "os": "ubuntu-latest", + "platform_name": "linux_amd64", + "upload": true + }, + { + "bazel_os": "windows", + "cross_compile": false, + "lint": false, + "os": "windows-latest", + "platform_name": "windows_amd64", + "upload": false + } + ] + } + } } }, "name": "pull-requests", diff --git a/MODULE.bazel b/MODULE.bazel index e07762e..de8147f 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,11 +1,14 @@ module(name = "com_github_buildbarn_bb_browser") +bazel_dep(name = "aspect_bazel_lib", version = "2.20.0") bazel_dep(name = "aspect_rules_js", version = "2.4.2") bazel_dep(name = "bazel_remote_apis", version = "0.0.0") bazel_dep(name = "com_github_buildbarn_bb_remote_execution") bazel_dep(name = "com_github_buildbarn_bb_storage") bazel_dep(name = "com_github_buildbarn_go_xdr") bazel_dep(name = "gazelle", version = "0.45.0") +bazel_dep(name = "platforms", version = "1.0.0") +bazel_dep(name = "toolchains_protoc", version = "0.4.3") # must come BEFORE protobuf so the toolchain registration wins bazel_dep(name = "protobuf", version = "31.1") bazel_dep(name = "rules_go", version = "0.56.1") bazel_dep(name = "rules_jsonnet", version = "0.7.2") @@ -20,13 +23,13 @@ git_override( git_override( module_name = "com_github_buildbarn_bb_remote_execution", - commit = "5b4f5a6879e1c5fac56a426f26b4416cb8f38e81", + commit = "efef252cdf4f97cc0154ea02976ed1322587e599", remote = "https://github.com/buildbarn/bb-remote-execution.git", ) git_override( module_name = "com_github_buildbarn_bb_storage", - commit = "7bb781bdf07d77d62083e916275567a6f9fa64e4", + commit = "5bae58446505a87d0f3249a5d97accb9b47f3c88", remote = "https://github.com/buildbarn/bb-storage.git", ) @@ -51,6 +54,10 @@ single_version_override( patches = ["//:patches/jsonnet/bazel-8.diff"], ) +# Match protobuf above, until it ships a pre-built binary toolchain itself +protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc") +protoc.toolchain(version = "v31.1") + go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") go_deps.from_file(go_mod = "//:go.mod") use_repo( @@ -60,7 +67,6 @@ use_repo( "com_github_buildkite_terminal_to_html", "com_github_dustin_go_humanize", "com_github_gorilla_mux", - "com_github_jmespath_go_jmespath", "com_github_kballard_go_shellquote", "org_golang_google_grpc", "org_golang_google_protobuf", diff --git a/cmd/bb_browser/BUILD.bazel b/cmd/bb_browser/BUILD.bazel index 0456b31..be4075d 100644 --- a/cmd/bb_browser/BUILD.bazel +++ b/cmd/bb_browser/BUILD.bazel @@ -1,3 +1,5 @@ +load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") +load("@aspect_rules_js//js:defs.bzl", "js_run_binary") load("@com_github_buildbarn_bb_browser_npm//:purgecss/package_json.bzl", purgecss_bin = "bin") load("@com_github_buildbarn_bb_storage//tools:container.bzl", "container_push_official", "multiarch_go_image") load("@rules_go//go:def.bzl", "go_binary", "go_library") @@ -8,9 +10,10 @@ go_library( "browser_service.go", "main.go", ], + # keep embedsrcs = [ + ":stylesheet", "favicon.png", - "stylesheet.css", "templates/error.html", "templates/footer.html", "templates/header.html", @@ -69,9 +72,11 @@ go_library( ], ) +templates = glob(["templates/*.html"]) + filegroup( name = "templates", - srcs = glob(["templates/*.html"]), + srcs = templates, ) purgecss_bin.purgecss_binary( @@ -82,19 +87,48 @@ purgecss_bin.purgecss_binary( # Create a copy of Bootstrap that only contains the style attributes # used by the HTML templates. Also include the classes needed by # terminal-to-html. +js_run_binary( + name = "bootstrap_stylesheet_platform", + srcs = [ + "@com_github_twbs_bootstrap//:css/bootstrap.min.css", + ] + templates, + outs = ["bootstrap_stylesheet.css"], + args = [ + # js_run_binary runs in the output dir; + # see https://github.com/aspect-build/rules_js/blob/main/docs/migrate.md#account-for-change-to-working-directory + "--css", + "../../../$(location @com_github_twbs_bootstrap//:css/bootstrap.min.css)", + "--safelist", + "bg-secondary", + "--output", + "../../../$(location bootstrap_stylesheet.css)", + "--content", + ] + [ + "../../../$(location %s)" % f + for f in templates + ], + copy_srcs_to_bin = False, + tags = ["manual"], + tool = ":purgecss", +) + +# Work around https://github.com/aspect-build/rules_js/issues/2121 by always +# building the stylesheet for the host platform, even if we are cross +# compiling. +platform_transition_filegroup( + name = "bootstrap_stylesheet", + srcs = [":bootstrap_stylesheet_platform"], + target_platform = "@platforms//host", +) + genrule( name = "stylesheet", srcs = [ + ":bootstrap_stylesheet", "@com_github_buildkite_terminal_to_html//assets:terminal.css", - "@com_github_twbs_bootstrap//:css/bootstrap.min.css", - ":templates", ], outs = ["stylesheet.css"], - cmd = " && ".join([ - "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}/$@ --safelist bg-secondary", - "cat $(location @com_github_buildkite_terminal_to_html//assets:terminal.css) >> $@", - ]), - tools = [":purgecss"], + cmd = "cat $(SRCS) > $@", ) go_binary( diff --git a/go.mod b/go.mod index 43cfa1f..dcd01ec 100644 --- a/go.mod +++ b/go.mod @@ -5,12 +5,11 @@ go 1.24.5 require ( github.com/bazelbuild/buildtools v0.0.0-20250715102656-62b9413b08bb github.com/bazelbuild/remote-apis v0.0.0-20250728120203-e94a7ece2a1e - github.com/buildbarn/bb-remote-execution v0.0.0-20250812083130-5b4f5a6879e1 - github.com/buildbarn/bb-storage v0.0.0-20250812162552-7bb781bdf07d + github.com/buildbarn/bb-remote-execution v0.0.0-20250820081613-efef252cdf4f + github.com/buildbarn/bb-storage v0.0.0-20250820101750-5bae58446505 github.com/buildkite/terminal-to-html v3.2.0+incompatible github.com/dustin/go-humanize v1.0.1 github.com/gorilla/mux v1.8.1 - github.com/jmespath/go-jmespath v0.4.0 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 golang.org/x/lint v0.0.0-20241112194109-818c5a804067 gonum.org/v1/plot v0.16.0 @@ -21,8 +20,8 @@ require ( require ( cel.dev/expr v0.24.0 // indirect - cloud.google.com/go v0.121.5 // indirect - cloud.google.com/go/auth v0.16.4 // indirect + cloud.google.com/go v0.121.6 // indirect + cloud.google.com/go/auth v0.16.5 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect cloud.google.com/go/compute/metadata v0.8.0 // indirect cloud.google.com/go/iam v1.5.2 // indirect @@ -81,6 +80,7 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/klauspost/compress v1.18.0 // indirect github.com/lazybeaver/xorshift v0.0.0-20170702203709-ce511d4823dd // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -118,10 +118,10 @@ require ( golang.org/x/time v0.12.0 // indirect golang.org/x/tools v0.36.0 // indirect google.golang.org/api v0.247.0 // indirect - google.golang.org/genproto v0.0.0-20250811230008-5f3141c8851a // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20250811230008-5f3141c8851a // indirect - google.golang.org/genproto/googleapis/bytestream v0.0.0-20250811230008-5f3141c8851a // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a // indirect + google.golang.org/genproto v0.0.0-20250818200422-3122310a409c // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c // indirect + google.golang.org/genproto/googleapis/bytestream v0.0.0-20250818200422-3122310a409c // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c // indirect google.golang.org/grpc/security/advancedtls v1.0.0 // indirect sigs.k8s.io/yaml v1.6.0 // indirect ) diff --git a/go.sum b/go.sum index 4bc960d..3d69f86 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,10 @@ cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY= cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.121.5 h1:KU9tFP5NeZiVDSWcsgjJ2P/HosAlD4fCGBimBlGiNXA= -cloud.google.com/go v0.121.5/go.mod h1:coChdst4Ea5vUpiALcYKXEpR1S9ZgXbhEzzMcMR66vI= -cloud.google.com/go/auth v0.16.4 h1:fXOAIQmkApVvcIn7Pc2+5J8QTMVbUGLscnSVNl11su8= -cloud.google.com/go/auth v0.16.4/go.mod h1:j10ncYwjX/g3cdX7GpEzsdM+d+ZNsXAbb6qXA7p1Y5M= +cloud.google.com/go v0.121.6 h1:waZiuajrI28iAf40cWgycWNgaXPO06dupuS+sgibK6c= +cloud.google.com/go v0.121.6/go.mod h1:coChdst4Ea5vUpiALcYKXEpR1S9ZgXbhEzzMcMR66vI= +cloud.google.com/go/auth v0.16.5 h1:mFWNQ2FEVWAliEQWpAdH80omXFokmrnbDhUS9cBywsI= +cloud.google.com/go/auth v0.16.5/go.mod h1:utzRfHMP+Vv0mpOkTRQoWD2q3BatTOoWbA7gCc2dUhQ= cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc= cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c= cloud.google.com/go/compute/metadata v0.8.0 h1:HxMRIbao8w17ZX6wBnjhcDkW6lTFpgcaobyVfZWqRLA= @@ -93,10 +93,10 @@ github.com/bazelbuild/remote-apis v0.0.0-20250728120203-e94a7ece2a1e/go.mod h1:/ github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/buildbarn/bb-remote-execution v0.0.0-20250812083130-5b4f5a6879e1 h1:3USqyx6lJUiCm6g3qcC8tin9Xh7Psqrn1d1/0hY3W6Y= -github.com/buildbarn/bb-remote-execution v0.0.0-20250812083130-5b4f5a6879e1/go.mod h1:WUDsQx1UHsKRN8QiisO7r6tFGj8jNRDhl6PZD0p1zRE= -github.com/buildbarn/bb-storage v0.0.0-20250812162552-7bb781bdf07d h1:wGFabX+n2Gb7v9EMCsoqTi2RYB1WQc7mCeOGFPNGTQk= -github.com/buildbarn/bb-storage v0.0.0-20250812162552-7bb781bdf07d/go.mod h1:ro83180H9FprjjO6nTjBfhvke3edvWtsLuZkfSSMgpo= +github.com/buildbarn/bb-remote-execution v0.0.0-20250820081613-efef252cdf4f h1:e0eYtwSJNSf6V7qpw4JX2sL5Rcxm4LMCWhXofEgH2dU= +github.com/buildbarn/bb-remote-execution v0.0.0-20250820081613-efef252cdf4f/go.mod h1:6sdx0M5BZhU22C5ddaGXvlLJZZMlyuhbsVSMoFlVdMI= +github.com/buildbarn/bb-storage v0.0.0-20250820101750-5bae58446505 h1:RdSZlutoggpuX25Niw2nZis/kiOWNAEohxiEFAUUdkU= +github.com/buildbarn/bb-storage v0.0.0-20250820101750-5bae58446505/go.mod h1:HetfamALiIPfoxhYb1f9v7Upxl3s01K8zwJ/3QZr5hw= github.com/buildbarn/go-sha256tree v0.0.0-20250310211320-0f70f20e855b h1:IKUxixGBm9UxobU7c248z0BF0ojG19uoSLz8MFZM/KA= github.com/buildbarn/go-sha256tree v0.0.0-20250310211320-0f70f20e855b/go.mod h1:e7g3/yWApcg+PpDqd4eQEEV8pexQmfCgK3frP+1Wuvk= github.com/buildkite/terminal-to-html v3.2.0+incompatible h1:WdXzl7ZmYzCAz4pElZosPaUlRTW+qwVx/SkQSCa1jXs= @@ -396,14 +396,14 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20250811230008-5f3141c8851a h1:V8Zj/61zlL7B+VH151iV5hJlUnYc3fUNTEhLtyr9Kzc= -google.golang.org/genproto v0.0.0-20250811230008-5f3141c8851a/go.mod h1:q9+ZJOXH/LcpbpkQSsvYReIH5lCcwvfc2xE8JBSER0Q= -google.golang.org/genproto/googleapis/api v0.0.0-20250811230008-5f3141c8851a h1:DMCgtIAIQGZqJXMVzJF4MV8BlWoJh2ZuFiRdAleyr58= -google.golang.org/genproto/googleapis/api v0.0.0-20250811230008-5f3141c8851a/go.mod h1:y2yVLIE/CSMCPXaHnSKXxu1spLPnglFLegmgdY23uuE= -google.golang.org/genproto/googleapis/bytestream v0.0.0-20250811230008-5f3141c8851a h1:0DUPF5Jzu1yQ4frd1+5y706ETkcr99RVmEwWhIx16JY= -google.golang.org/genproto/googleapis/bytestream v0.0.0-20250811230008-5f3141c8851a/go.mod h1:1kGGe25NDrNJYgta9Rp2QLLXWS1FLVMMXNvihbhK0iE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a h1:tPE/Kp+x9dMSwUm/uM0JKK0IfdiJkwAbSMSeZBXXJXc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a/go.mod h1:gw1tLEfykwDz2ET4a12jcXt4couGAm7IwsVaTy0Sflo= +google.golang.org/genproto v0.0.0-20250818200422-3122310a409c h1:ZERoum3uuqL0PRSc6SXielu26FN96T4BUGaaW0oL+c8= +google.golang.org/genproto v0.0.0-20250818200422-3122310a409c/go.mod h1:Q8kep885BJnK3Jt6QZXIFeLHSzoAQtlI1CCloQigiyU= +google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c h1:AtEkQdl5b6zsybXcbz00j1LwNodDuH6hVifIaNqk7NQ= +google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c/go.mod h1:ea2MjsO70ssTfCjiwHgI0ZFqcw45Ksuk2ckf9G468GA= +google.golang.org/genproto/googleapis/bytestream v0.0.0-20250818200422-3122310a409c h1:CMCT63H4Rl6uNNT10m3hkjCR3JgAv4E9ZuVTeO+Sz98= +google.golang.org/genproto/googleapis/bytestream v0.0.0-20250818200422-3122310a409c/go.mod h1:1kGGe25NDrNJYgta9Rp2QLLXWS1FLVMMXNvihbhK0iE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c h1:qXWI/sQtv5UKboZ/zUk7h+mrf/lXORyI+n9DKDAusdg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c/go.mod h1:gw1tLEfykwDz2ET4a12jcXt4couGAm7IwsVaTy0Sflo= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= diff --git a/tools/github_workflows/BUILD.bazel b/tools/github_workflows/BUILD.bazel index f7dee3f..5f8b640 100644 --- a/tools/github_workflows/BUILD.bazel +++ b/tools/github_workflows/BUILD.bazel @@ -1,4 +1,5 @@ -load("@rules_jsonnet//jsonnet:jsonnet.bzl", "jsonnet_library", "jsonnet_to_json") +load("@rules_go//go:def.bzl", "go_test") +load("@rules_jsonnet//jsonnet:jsonnet.bzl", "jsonnet_to_json") jsonnet_to_json( name = "github_workflows", @@ -10,7 +11,8 @@ jsonnet_to_json( deps = ["@com_github_buildbarn_bb_storage//tools/github_workflows:workflows_template"], ) -sh_test( +# This is a no-op test that's only part of the repository to keep +# 'bazel test' happy. This is necessary, as no other tests are provided. +go_test( name = "noop_test", - srcs = ["noop_test.sh"], ) diff --git a/tools/github_workflows/noop_test.sh b/tools/github_workflows/noop_test.sh deleted file mode 100755 index fc6ce16..0000000 --- a/tools/github_workflows/noop_test.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -# This is a no-op test that's only part of the repository to keep -# 'bazel test' happy. This is necessary, as no other tests are provided. -exit 0