Skip to content

Commit

Permalink
chore: misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Jun 7, 2024
1 parent cb4693d commit ad910ec
Show file tree
Hide file tree
Showing 20 changed files with 124 additions and 78 deletions.
27 changes: 3 additions & 24 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,38 +1,17 @@
# Import shared settings first so we can override below
import %workspace%/common.bazelrc

###############################
# Remote Build Execution support
# Turn on these settings with
# --config=remote
###############################

# Load default settings for Remote Build Execution.
import %workspace%/third_party/github.com/bazelbuild/bazel-toolchains/bazelrc/bazel-4.1.0.bazelrc

# Remote instance, borrow the one used by Angular devs
build:remote --remote_instance_name=projects/internal-200822/instances/default_instance
build:remote --project_id=internal-200822

# To reproduce Windows issues where there is no runfiles symlink there
build:no-runfiles --noenable_runfiles
# workaround https://github.com/bazelbuild/bazel/issues/7994
build:no-runfiles --spawn_strategy=standalone
# This config is probably only used while debugging
build:no-runfiles --define=VERBOSE_LOG=1

# Docker Sandbox Mode
# Useful for troubleshooting Remote Build Execution problems
# See https://docs.bazel.build/versions/master/remote-execution-sandbox.html#prerequisites
build:docker-sandbox --spawn_strategy=docker --strategy=Javac=docker --genrule_strategy=docker
build:docker-sandbox --define=EXECUTOR=remote
build:docker-sandbox --experimental_docker_verbose
build:docker-sandbox --experimental_enable_docker_sandbox
# This is the same image used on BazelCI rbe_ubuntu1604 job
build:docker-sandbox --experimental_docker_image=gcr.io/cloud-marketplace/google/rbe-ubuntu16-04

# Incompatible flags to run with
build --incompatible_no_implicit_file_export
# TODO: flip this once @buildifier_prebuilt is compatible with it
# build --incompatible_no_implicit_file_export

# Fail if a glob doesn't match anything (https://github.com/bazelbuild/bazel/issues/8195)
build --incompatible_disallow_empty_glob
# TODO(mattem): flip this when dependencies allow
Expand Down
2 changes: 1 addition & 1 deletion .github/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_codeowners//tools:codeowners.bzl", "generate_codeowners")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@rules_codeowners//tools:codeowners.bzl", "generate_codeowners")

generate_codeowners(
name = "gen_codeowners",
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/buildifier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Buildifier

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: buildifier
run: bazel run --enable_bzlmod //:buildifier.check
4 changes: 2 additions & 2 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# It is referenced with a --bazelrc option in the call to bazel in ci.yaml

# Debug where options came from
build --announce_rc
common --announce_rc
# This directory is configured in GitHub actions to be persisted between runs.
build --disk_cache=~/.cache/bazel
build --repository_cache=~/.cache/bazel-repo
# Don't rely on test logs being easily accessible from the test runner,
# though it makes the log noisier.
test --test_output=errors
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
test --test_env=XDG_CACHE_HOME
common --test_env=XDG_CACHE_HOME
15 changes: 8 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ node_modules
yarn-error.log
.DS_Store

# Disable lockfile for now. It is unstable.
# https://github.com/bazelbuild/bazel/issues/19026
# https://github.com/bazelbuild/bazel/issues/19621
# https://github.com/bazelbuild/bazel/issues/19971
# https://github.com/bazelbuild/bazel/issues/20272
# https://github.com/bazelbuild/bazel/issues/20369
MODULE.bazel.lock
# Bazel's MODULE lockfile isn't ready to check in yet as of Bazel 7.1.
# Do allow for it to be created, however, since it gives a performance boost for local development.
# [Store resolved repository attributes in the Bzlmod lockfile](https://github.com/bazelbuild/bazel/issues/19026)
# [MODULE.bazel.lock file contains user specific paths](https://github.com/bazelbuild/bazel/issues/19621)
# [Consider skipping bazel_tools@_ from lockfile](https://github.com/bazelbuild/bazel/issues/19971)
# [MODULE.bazel.lock file "reads through" already-locked package manager](https://github.com/bazelbuild/bazel/issues/20272)
# [moduleFileHash in MODULE.bazel.lock causes frequent Git merge conflicts](https://github.com/bazelbuild/bazel/issues/20369)
MODULE.bazel.lock
27 changes: 22 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
# See CONTRIBUTING.md for instructions.
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

# Commitizen runs in commit-msg stage
# but we don't want to run the other hooks on commit messages
default_stages: [commit]

repos:
# Check formatting and lint for starlark code
- repo: https://github.com/keith/pre-commit-buildifier
rev: 4.0.1.1
rev: 6.4.0
hooks:
- id: buildifier
args: &args
# Keep this argument in sync with .bazelci/presubmit.yml
- --warnings=-bzl-visibility,-function-docstring-args,-function-docstring-return,-print,-unnamed-macro,-provider-params,-function-docstring-header,-no-effect,-uninitialized,-rule-impl-return
- id: buildifier-lint
args: *args
# Enforce that commit messages allow for later changelog generation
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.24.0
hooks:
# Requires that commitizen is already installed
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.8.0
hooks:
- id: shellcheck
19 changes: 17 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@buildifier_prebuilt//:rules.bzl", "buildifier")
load("//:tools/defaults.bzl", "codeowners")

package(default_visibility = ["//visibility:public"])
Expand All @@ -24,12 +25,26 @@ exports_files([
"LICENSE",
])

# BEGIN-INTERNAL
buildifier(
name = "buildifier",
exclude_patterns = ["./.git/*"],
lint_mode = "fix",
mode = "fix",
tags = ["manual"], # tag as manual so windows ci does not build it by default
)

buildifier(
name = "buildifier.check",
exclude_patterns = ["./.git/*"],
lint_mode = "warn",
mode = "diff",
tags = ["manual"], # tag as manual so windows ci does not build it by default
)

codeowners(
pattern = "*",
teams = [
"@mattem",
"@gregmagolan",
],
)
# END-INTERNAL
13 changes: 13 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,29 @@ use_repo(node, "nodejs_toolchains")
# https://github.com/bazelbuild/rules_nodejs/blob/4c373209b058d46f2a5f9ab9f8abf11b161ae459/nodejs/repositories.bzl#L461/.
# See https://github.com/bazelbuild/bazel/issues/19645 and https://github.com/bazelbuild/rules_nodejs/pull/3750 for more context.
register_toolchains("@nodejs_toolchains//:linux_amd64_toolchain_target")

register_toolchains("@nodejs_toolchains//:linux_amd64_toolchain")

register_toolchains("@nodejs_toolchains//:linux_arm64_toolchain_target")

register_toolchains("@nodejs_toolchains//:linux_arm64_toolchain")

register_toolchains("@nodejs_toolchains//:linux_s390x_toolchain_target")

register_toolchains("@nodejs_toolchains//:linux_s390x_toolchain")

register_toolchains("@nodejs_toolchains//:linux_ppc64le_toolchain_target")

register_toolchains("@nodejs_toolchains//:linux_ppc64le_toolchain")

register_toolchains("@nodejs_toolchains//:darwin_amd64_toolchain_target")

register_toolchains("@nodejs_toolchains//:darwin_amd64_toolchain")

register_toolchains("@nodejs_toolchains//:darwin_arm64_toolchain_target")

register_toolchains("@nodejs_toolchains//:darwin_arm64_toolchain")

register_toolchains("@nodejs_toolchains//:windows_amd64_toolchain_target")

register_toolchains("@nodejs_toolchains//:windows_amd64_toolchain")
9 changes: 9 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,12 @@ stardoc_external_deps()
load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install")

stardoc_pinned_maven_install()

# Buildifier
load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")

buildifier_prebuilt_deps()

load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")

buildifier_prebuilt_register_toolchains()
3 changes: 0 additions & 3 deletions common.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#
# The full list of Bazel options: https://docs.bazel.build/versions/master/command-line-reference.html

# Cache action outputs on disk so they persist across output_base and bazel shutdown (eg. changing branches)
build --disk_cache=~/.cache/bazel-disk-cache

# Bazel picks up host-OS-specific config lines from bazelrc files
build --enable_platform_specific_config

Expand Down
8 changes: 4 additions & 4 deletions e2e/nodejs_host/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ local_path_override(
path = "../..",
)

bazel_dep(name = "bazel_skylib", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1", dev_dependency = True)
bazel_dep(name = "aspect_bazel_lib", version = "2.7.7", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)

Expand All @@ -26,10 +26,10 @@ use_repo(
node,
"node16_darwin_amd64",
"node16_linux_amd64",
"node16_toolchains",
"node16_windows_amd64",
"node16_nvmrc_darwin_amd64",
"node16_nvmrc_linux_amd64",
"node16_nvmrc_toolchains",
"node16_nvmrc_windows_amd64",
"node16_toolchains",
"node16_windows_amd64",
)
7 changes: 2 additions & 5 deletions e2e/nodejs_host/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_skylib",
sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
],
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"],
)

local_repository(
Expand Down
4 changes: 0 additions & 4 deletions e2e/smoke/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
import %workspace%/../../common.bazelrc

# Remote instance, borrow the one used by Angular devs
build:remote --remote_instance_name=projects/internal-200822/instances/default_instance
build:remote --project_id=internal-200822
4 changes: 2 additions & 2 deletions e2e/smoke/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load(":defs.bzl", "my_nodejs")

# Trivial test fixture: a nodejs program that writes to a file
Expand Down
5 changes: 2 additions & 3 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ local_path_override(
path = "../..",
)

bazel_dep(name = "bazel_skylib", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "aspect_bazel_lib", version = "2.7.7", dev_dependency = True)
bazel_dep(name = "platforms", version = "0.0.5", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "platforms", version = "0.0.10", dev_dependency = True)

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)

node.toolchain(node_version = "16.5.0")
node.toolchain(
name = "node17",
Expand Down
2 changes: 1 addition & 1 deletion nodejs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//nodejs/private:current_node_cc_headers.bzl", "current_node_cc_headers")
load("//nodejs/private:nodejs_toolchains_repo.bzl", "PLATFORMS")
load("//nodejs/private:user_build_settings.bzl", "user_args")
load("//nodejs/private:current_node_cc_headers.bzl", "current_node_cc_headers")

exports_files([
"index.for_docs.bzl",
Expand Down
8 changes: 4 additions & 4 deletions nodejs/providers.bzl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"Public providers, aspects and helpers that are shipped in the built-in rules_nodejs repository."

load(
"//nodejs/private/providers:user_build_settings.bzl",
_UserBuildSettingInfo = "UserBuildSettingInfo",
)
load(
"//nodejs/private/providers:stamp_setting_info.bzl",
_STAMP_ATTR = "STAMP_ATTR",
_StampSettingInfo = "StampSettingInfo",
)
load(
"//nodejs/private/providers:user_build_settings.bzl",
_UserBuildSettingInfo = "UserBuildSettingInfo",
)

UserBuildSettingInfo = _UserBuildSettingInfo
StampSettingInfo = _StampSettingInfo
Expand Down
3 changes: 1 addition & 2 deletions nodejs/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"Rules to be called from the users WORKSPACE"

load("//nodejs/private:os_name.bzl", "assert_node_exists_for_host", "node_exists_for_os")
load("//nodejs/private:node_versions.bzl", "NODE_VERSIONS")
load("//nodejs/private:nodejs_repo_host_os_alias.bzl", "nodejs_repo_host_os_alias")
load("//nodejs/private:nodejs_toolchains_repo.bzl", "PLATFORMS", "nodejs_toolchains_repo")
load("//nodejs/private:os_name.bzl", "assert_node_exists_for_host", "node_exists_for_os")

# Default base name for node toolchain repositories
# created by the module extension
Expand Down Expand Up @@ -154,7 +154,6 @@ def _prepare_node(repository_ctx):

node_bin_relative = _strip_bin(node_bin)
npm_script_relative = _strip_bin(npm_script)
node_entry_relative = _strip_bin(node_entry)
npx_script_relative = _strip_bin(npx_script)

# The entry points for node for osx/linux and windows
Expand Down
2 changes: 1 addition & 1 deletion packages/runfiles/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("//internal:tsc.bzl", "tsc")

tsc(
Expand Down
20 changes: 12 additions & 8 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ def rules_nodejs_dev_dependencies():

http_archive(
name = "bazel_skylib",
sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
],
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"],
)

http_archive(
Expand All @@ -60,7 +57,14 @@ def rules_nodejs_dev_dependencies():

http_archive(
name = "aspect_bazel_lib",
sha256 = "b554eb7942a5ab44c90077df6a0c76fc67c5874c9446a007e9ba68be82bd4796",
strip_prefix = "bazel-lib-2.7.1",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.1/bazel-lib-v2.7.1.tar.gz",
sha256 = "6d758a8f646ecee7a3e294fbe4386daafbe0e5966723009c290d493f227c390b",
strip_prefix = "bazel-lib-2.7.7",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.7/bazel-lib-v2.7.7.tar.gz",
)

http_archive(
name = "buildifier_prebuilt",
sha256 = "8ada9d88e51ebf5a1fdff37d75ed41d51f5e677cdbeafb0a22dda54747d6e07e",
strip_prefix = "buildifier-prebuilt-6.4.0",
urls = ["http://github.com/keith/buildifier-prebuilt/archive/6.4.0.tar.gz"],
)

0 comments on commit ad910ec

Please sign in to comment.