Skip to content

Commit

Permalink
chore: switch rbe to buildbuddy (#430)
Browse files Browse the repository at this point in the history
* chore: switch rbe to buildbuddy

Matches aspect-build/rules_js#1241

* fix: workaround aspect-cli issue with 'common'

* chore: buildifier

* chore: align buildifier version

So that pre-commit and buildifier.check agree

* fix: ts_proto_library must return runfiles too

* chore: exclude rbe+e2e/bzlmod

* Update .bazelrc.common

* restore deleted file

* chore: add missing TODO
  • Loading branch information
alexeagle authored Aug 30, 2023
1 parent 4e1ba86 commit 7db73d1
Show file tree
Hide file tree
Showing 43 changed files with 119 additions and 109 deletions.
9 changes: 7 additions & 2 deletions .bazelrc.common
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ build:macos --nolegacy_external_runfiles
build:freebsd --nolegacy_external_runfiles
build:openbsd --nolegacy_external_runfiles

common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
common --@aspect_rules_ts//ts:default_to_tsc_transpiler
# TODO: switch to 'common' once https://github.com/bazelbuild/bazel/pull/19363 is landed and available in Bazel
build --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
fetch --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
query --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
build --@aspect_rules_ts//ts:default_to_tsc_transpiler
fetch --@aspect_rules_ts//ts:default_to_tsc_transpiler
query --@aspect_rules_ts//ts:default_to_tsc_transpiler

# Turn on --incompatible_strict_action_env which was on by default
# in Bazel 0.21.0 but turned off again in 0.22.0. Follow
Expand Down
18 changes: 5 additions & 13 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,8 @@ build:rbe --genrule_strategy=remote
build:rbe --host_platform=@aspect_rules_js//platforms:x86_64_linux_remote
build:rbe --jobs=32

# EngFlow remote cache
build:rbe --bes_backend=grpcs://tourmaline.cluster.engflow.com
build:rbe --bes_results_url=https://tourmaline.cluster.engflow.com/invocation/
build:rbe --remote_cache=grpcs://tourmaline.cluster.engflow.com

# EngFlow remote build execution
build:rbe --remote_executor=grpcs://tourmaline.cluster.engflow.com

# TODO: remove workaround for failure
build:rbe --modify_execution_info=GoCompilePkg=+no-remote-exec

# These files are written during CI setup, using secrets registered with the CI platforms
build:rbe --tls_client_certificate=engflow.crt --tls_client_key=engflow.key
# BuildBuddy remote exec
build:rbe --bes_results_url=https://app.buildbuddy.io/invocation/
build:rbe --bes_backend=grpcs://remote.buildbuddy.io
build:rbe --remote_timeout=3600
build:rbe --remote_executor=grpcs://remote.buildbuddy.io
21 changes: 11 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:
# Prepares the 'config' axis of the test matrix
runs-on: ubuntu-latest
env:
ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }}
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
steps:
- id: local
run: echo "config=local" >> $GITHUB_OUTPUT
- id: rbe
run: echo "config=rbe" >> $GITHUB_OUTPUT
# Don't run RBE if there are no EngFlow creds which is the case on forks
if: ${{ env.ENGFLOW_PRIVATE_KEY != '' }}
# Don't run RBE if there is no API token which is the case on forks
if: ${{ env.BUILDBUDDY_API_KEY != '' }}
outputs:
# Will look like ["local", "rbe"]
configs: ${{ toJSON(steps.*.outputs.config) }}
Expand Down Expand Up @@ -92,6 +92,9 @@ jobs:
# Don't test RBE with on MacOS (not configured)
- os: macos-latest
config: rbe
# TODO(https://github.com/aspect-build/rules_ts/issues/432): re-enable
- folder: e2e/bzlmod
config: rbe

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down Expand Up @@ -125,17 +128,15 @@ jobs:
# then use .bazelversion to determine which Bazel version to use
run: echo "${{ matrix.bazelversion }}" > .bazelversion

- name: Write engflow credentials
- name: Write RBE credentials
if: ${{ matrix.config == 'rbe' }}
working-directory: ${{ matrix.folder }}
run: |
touch engflow.crt engflow.key
chmod 0600 engflow.crt engflow.key
echo "$ENGFLOW_CLIENT_CRT" > engflow.crt
echo "$ENGFLOW_PRIVATE_KEY" > engflow.key
touch $HOME/.bazelrc
chmod 0600 $HOME/.bazelrc
echo "build --remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY" > $HOME/.bazelrc
env:
ENGFLOW_CLIENT_CRT: ${{ secrets.ENGFLOW_CLIENT_CRT }}
ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }}
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}

- name: bazel test //...
env:
Expand Down
34 changes: 17 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
default_stages: [commit]

repos:
# Check formatting and lint for starlark code
- repo: https://github.com/keith/pre-commit-buildifier
rev: 4.0.1.1
hooks:
- id: buildifier
- id: buildifier-lint
# Enforce that commit messages allow for later changelog generation
- repo: https://github.com/commitizen-tools/commitizen
rev: v2.18.0
hooks:
# Requires that commitizen is already installed
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.4.0"
hooks:
- id: prettier
# Check formatting and lint for starlark code
- repo: https://github.com/keith/pre-commit-buildifier
rev: 6.3.3
hooks:
- id: buildifier
- id: buildifier-lint
# Enforce that commit messages allow for later changelog generation
- repo: https://github.com/commitizen-tools/commitizen
rev: v2.18.0
hooks:
# Requires that commitizen is already installed
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v2.4.0'
hooks:
- id: prettier
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@buildifier_prebuilt//:rules.bzl", "buildifier")

gazelle_binary(
Expand Down
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ bazel_dep(name = "aspect_bazel_lib", version = "1.29.2")
# Similar to rules_python/MODULE.bazel, see https://github.com/bazelbuild/rules_python/pull/832
# These are loaded only when using ts_proto_library
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

# Only needed because rules_proto doesn't provide the protoc toolchain yet.
# TODO(alex/sahin): remove in the future
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
Expand Down
6 changes: 1 addition & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")

aspect_bazel_lib_dependencies(override_local_config_platform = True)
Expand All @@ -52,8 +48,8 @@ bazel_skylib_workspace()

############################################
# Gazelle, for generating bzl_library targets
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

Expand Down
9 changes: 7 additions & 2 deletions e2e/bzlmod/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# NB: we don't import common bazelrc shared with e2e workspaces
# NB: we don't import common bazelrc shared with e2e workspaces so that we can test flag settings

build --enable_runfiles
common --enable_bzlmod
common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig

# TODO: switch to 'common' once https://github.com/bazelbuild/bazel/pull/19363 is landed and available in Bazel
build --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
query --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
fetch --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
4 changes: 2 additions & 2 deletions e2e/bzlmod/BUILD
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@aspect_rules_ts//ts:proto.bzl", "ts_proto_library")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@rules_proto//proto:defs.bzl", "proto_library")

package(default_visibility = ["//visibility:public"])

Expand Down
8 changes: 6 additions & 2 deletions e2e/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ module(
bazel_dep(name = "aspect_rules_js", version = "1.29.2", dev_dependency = True)
bazel_dep(name = "aspect_rules_ts", version = "0.0.0", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "rules_proto", version = "5.3.0-21.7", dev_dependency = True)
bazel_dep(name = "rules_proto", version = "5.3.0-21.7", dev_dependency = True)

local_path_override(
module_name = "aspect_rules_ts",
path = "../..",
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)
npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
Expand Down
2 changes: 1 addition & 1 deletion e2e/worker/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@npm//:defs.bzl", "npm_link_all_packages")

package(default_visibility = ["//:__subpackages__"])
Expand Down
2 changes: 1 addition & 1 deletion e2e/worker/composite/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")

package(default_visibility = ["//composite:__subpackages__"])

Expand Down
2 changes: 1 addition & 1 deletion examples/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("@npm//:defs.bzl", "npm_link_all_packages")

# Building this target results in bazel-bin/examples/node_modules/@myorg/js_lib, so that
# TypeScript and other node programs beneath bazel-bin/examples are able to resolve its location.
Expand Down
2 changes: 1 addition & 1 deletion examples/connect_node/proto/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@aspect_rules_ts//ts:proto.bzl", "ts_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

package(default_visibility = ["//visibility:public"])

Expand Down
2 changes: 1 addition & 1 deletion examples/declaration_dir/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Shows how https://www.typescriptlang.org/tsconfig/#declarationDir can be used to write
.d.ts typings files to a different folder than the JavaScript outputs."""

load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_bazel_lib//lib:testing.bzl", "assert_outputs")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

ts_project(
name = "transpile",
Expand Down
2 changes: 1 addition & 1 deletion examples/deps_lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")

ts_config(
name = "tsconfig",
Expand Down
2 changes: 1 addition & 1 deletion examples/deps_lib_transpiler/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("//examples/transpiler:babel.bzl", "babel")

ts_config(
Expand Down
2 changes: 1 addition & 1 deletion examples/dts_lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@bazel_skylib//rules:build_test.bzl", "build_test")

ts_project(
Expand Down
2 changes: 1 addition & 1 deletion examples/js_lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_js//npm:defs.bzl", "npm_package")

npm_package(
name = "js_lib",
Expand Down
2 changes: 1 addition & 1 deletion examples/js_test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

ts_project(
name = "compile",
Expand Down
4 changes: 2 additions & 2 deletions examples/jsx/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_bazel_lib//lib:params_file.bzl", "params_file")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

ts_project(
name = "jsx",
Expand Down
2 changes: 1 addition & 1 deletion examples/linked_tsconfig/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages()

Expand Down
2 changes: 1 addition & 1 deletion examples/linked_tsconfig_consumer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages()

Expand Down
4 changes: 2 additions & 2 deletions examples/module_ext/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
See https://nodejs.org/docs/latest/api/esm.html#esm_differences_between_es_modules_and_commonjs
"""

load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_bazel_lib//lib:params_file.bzl", "params_file")
load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

# Demonstrate that ts_project accepts the dedicated file extensions.
ts_project(
Expand Down
2 changes: 1 addition & 1 deletion examples/output_group/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

ts_project(
name = "output_group",
Expand Down
4 changes: 1 addition & 3 deletions examples/proto_grpc/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_rules_ts//ts:proto.bzl", "ts_proto_library")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@rules_proto//proto:defs.bzl", "proto_library")

npm_link_all_packages(name = "node_modules")

Expand Down Expand Up @@ -36,8 +36,6 @@ js_test(
data = [
"package.json", # for type=module
"proto_grpc",
# TODO: but I didn't import this!
":node_modules/@bufbuild/protobuf",
],
entry_point = "main.js",
)
2 changes: 1 addition & 1 deletion examples/proto_grpc/stripping/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@aspect_rules_ts//ts:proto.bzl", "ts_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

proto_library(
name = "s_proto",
Expand Down
2 changes: 1 addition & 1 deletion examples/resolve_json_module/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Shows how https://www.typescriptlang.org/tsconfig/#resolveJsonModule can be used."""

load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

ts_project(
name = "ts",
Expand Down
2 changes: 1 addition & 1 deletion examples/source_map_support/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

exports_files([
"defs.bzl",
Expand Down
2 changes: 1 addition & 1 deletion examples/source_map_support/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("//ts:defs.bzl", "ts_project")
load("//examples/source_map_support:defs.bzl", "js_test")
load("//ts:defs.bzl", "ts_project")

ts_project(
name = "ts",
Expand Down
3 changes: 2 additions & 1 deletion examples/transpiler/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

# Note, Bazel 6 starlark has lambda so maybe we can stop using partial
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load(":babel.bzl", "babel")

###
Expand Down
6 changes: 3 additions & 3 deletions internal_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def rules_ts_internal_deps():

http_archive(
name = "buildifier_prebuilt",
sha256 = "e46c16180bc49487bfd0f1ffa7345364718c57334fa0b5b67cb5f27eba10f309",
strip_prefix = "buildifier-prebuilt-6.1.0",
urls = ["https://github.com/keith/buildifier-prebuilt/archive/6.1.0.tar.gz"],
sha256 = "72b5bb0853aac597cce6482ee6c62513318e7f2c0050bc7c319d75d03d8a3875",
strip_prefix = "buildifier-prebuilt-6.3.3",
urls = ["https://github.com/keith/buildifier-prebuilt/archive/6.3.3.tar.gz"],
)

http_archive(
Expand Down
Loading

0 comments on commit 7db73d1

Please sign in to comment.