Skip to content

Commit

Permalink
chore: cleanup WORKSPACE and MODULE.bazel files (#1673)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed May 20, 2024
1 parent 9b1d03c commit 99275cd
Show file tree
Hide file tree
Showing 44 changed files with 336 additions and 294 deletions.
2 changes: 1 addition & 1 deletion .bazeliskrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BAZELISK_BASE_URL=https://github.com/aspect-build/aspect-cli/releases/download
USE_BAZEL_VERSION=aspect/5.9.24
USE_BAZEL_VERSION=aspect/5.9.25
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
2 changes: 1 addition & 1 deletion .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bazel_dep(name = "aspect_rules_js", version = "${TAG:1}")
# By default you get the node version from DEFAULT_NODE_VERSION in @rules_nodejs//nodejs:repositories.bzl
# Optionally you can pin a different node version:
bazel_dep(name = "rules_nodejs", version = "6.1.0")
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
node.toolchain(node_version = "16.14.2")
#################################
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ default_stages: [commit]
repos:
# Check formatting and lint for starlark code
- repo: https://github.com/keith/pre-commit-buildifier
rev: 6.1.0.1
rev: 6.4.0
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
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: 'v2.4.0'
rev: v3.1.0
hooks:
- id: prettier
- repo: https://github.com/koalaman/shellcheck-precommit
Expand Down
4 changes: 3 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
load("@npm//:defs.bzl", "npm_link_all_packages", "npm_link_targets")
load("@pnpm__links//:defs.bzl", npm_link_pnpm = "npm_link_imported_package")
load("//npm:defs.bzl", "npm_link_package")
load("//js:defs.bzl", "js_library")
load("//npm:defs.bzl", "npm_link_package")

# Link all packages from the /WORKSPACE npm_translate_lock(name = "npm") and also packages from
# manual /WORKSPACE npm_import rules to bazel-bin/node_modules as well as the package store
Expand Down Expand Up @@ -99,6 +99,7 @@ buildifier(
lint_mode = "fix",
lint_warnings = ["-out-of-order-load"], # TODO: enable out-of-order-load
mode = "fix",
tags = ["manual"], # tag as manual so windows ci does not build it by default
)

buildifier(
Expand All @@ -107,6 +108,7 @@ buildifier(
lint_mode = "warn",
lint_warnings = ["-out-of-order-load"], # TODO: enable out-of-order-load
mode = "diff",
tags = ["manual"], # tag as manual so windows ci does not build it by default
)

alias(
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module(
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1")
bazel_dep(name = "bazel_features", version = "1.9.0")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "rules_nodejs", version = "6.1.0")
bazel_dep(name = "platforms", version = "0.0.5")
bazel_dep(name = "rules_nodejs", version = "6.1.0")

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
use_repo(node, "nodejs_darwin_amd64")
Expand Down
5 changes: 1 addition & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
workspace(
# see https://docs.bazel.build/versions/main/skylark/deploying.html#workspace
name = "aspect_rules_js",
)
workspace(name = "aspect_rules_js")

# buildifier: disable=bzl-visibility
load("//js/private:dev_deps.bzl", "rules_js_dev_dependencies")
Expand Down
14 changes: 4 additions & 10 deletions e2e/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
module(
name = "e2e_bzlmod",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "aspect_rules_js", version = "0.0.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1")
bazel_dep(name = "bazel_skylib", version = "1.5.0")

bazel_dep(name = "aspect_rules_js", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_js",
path = "../..",
)

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

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
Expand Down
7 changes: 1 addition & 6 deletions e2e/git_dep_metadata/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
module(
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "aspect_rules_js", version = "0.0.0")
bazel_dep(name = "aspect_rules_js", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_js",
path = "../..",
Expand Down
14 changes: 9 additions & 5 deletions e2e/gyp_no_install_script/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
bazel_dep(name = "platforms", version = "0.0.8")

bazel_dep(name = "aspect_rules_js", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_js",
path = "../..",
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1", dev_dependency = True)
bazel_dep(name = "platforms", version = "0.0.9", dev_dependency = True)

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)
npm.npm_translate_lock(
name = "npm",
data = ["//:package.json"],
Expand Down
File renamed without changes.
21 changes: 14 additions & 7 deletions e2e/js_image_docker/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ load("@npm//:repositories.bzl", "npm_repositories")

npm_repositories()

# TODO: remove when rules_? upgrades to modern version supporting
http_archive(
name = "bazel_gazelle",
integrity = "sha256-dd8ojEsxyB61D1Hi4U9HY8t1SNquEmgXJHBkY3/Z6mI=",
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz"],
)

###
# Setup rules_docker
# rules_docker does not work with M1 macs due to ancient rules_go version.
Expand All @@ -54,6 +47,20 @@ http_archive(
urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip"],
)

# Bring in a newer version of bazel_gazelle to work-around an incompatability with an older
# version that is brought in transitively below that is incompatible with newer versions of rules_go.
# Error when this is not done is:
# ERROR: Traceback (most recent call last):
# File "/private/var/tmp/_bazel_greg/970c650b0c043c16acaced625553237d/external/bazel_gazelle/internal/go_repository_tools.bzl", line 15, column 52, in <toplevel>
# load("@io_bazel_rules_go//go/private:common.bzl", "env_execute", "executable_extension")
# Error: file '@io_bazel_rules_go//go/private:common.bzl' does not contain symbol 'env_execute'
# ERROR: Error computing the main repository mapping: at /private/var/tmp/_bazel_greg/970c650b0c043c16acaced625553237d/external/io_bazel_rules_docker/repositories/deps.bzl:22:6: at /private/var/tmp/_bazel_greg/970c650b0c043c16acaced625553237d/external/io_bazel_rules_docker/repositories/go_repositories.bzl:22:6: at /private/var/tmp/_bazel_greg/970c650b0c043c16acaced625553237d/external/bazel_gazelle/deps.bzl:24:5: initialization of module 'internal/go_repository_tools.bzl' failed
http_archive(
name = "bazel_gazelle",
integrity = "sha256-dd8ojEsxyB61D1Hi4U9HY8t1SNquEmgXJHBkY3/Z6mI=",
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz"],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()
Expand Down
34 changes: 20 additions & 14 deletions e2e/js_run_devserver/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
module(
name = "e2e_js_run_devserver",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "aspect_bazel_lib", version = "2.7.1")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "rules_go", version = "0.46.0")

bazel_dep(name = "aspect_rules_js", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_js",
path = "../..",
)

pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "rules_go", version = "0.46.0", dev_dependency = True)

pnpm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"pnpm",
dev_dependency = True,
)
use_repo(pnpm, "pnpm")

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)
npm.npm_translate_lock(
name = "npm",
bins = {
Expand All @@ -32,7 +34,11 @@ npm.npm_translate_lock(
)
use_repo(npm, "npm")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk = use_extension(
"@rules_go//go:extensions.bzl",
"go_sdk",
dev_dependency = True,
)
go_sdk.download(
name = "go_sdk",
version = "1.20.3",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_link_package-esm/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ local_repository(

load("@rules_foo//foo:repositories.bzl", "foo_repositories")

foo_repositories(name = "foo")
foo_repositories()

load("@foo//:npm_repositories.bzl", foo_npm_repositories = "npm_repositories")

Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_link_package/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ local_repository(

load("@rules_foo//foo:repositories.bzl", "foo_repositories")

foo_repositories(name = "foo")
foo_repositories()

load("@foo//:npm_repositories.bzl", foo_npm_repositories = "npm_repositories")

Expand Down
22 changes: 10 additions & 12 deletions e2e/npm_translate_lock/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
module(
name = "e2e_npm_translate_lock",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
bazel_dep(name = "platforms", version = "0.0.8")

bazel_dep(name = "aspect_rules_js", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_js",
path = "../..",
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "platforms", version = "0.0.9", dev_dependency = True)

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)
npm.npm_translate_lock(
name = "npm",
data = ["//:package.json"],
Expand Down
17 changes: 8 additions & 9 deletions e2e/npm_translate_lock_auth/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
module(
name = "e2e_npm_translate_lock_auth",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
bazel_dep(name = "aspect_rules_js", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_js",
path = "../..",
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)
npm.npm_translate_lock(
name = "npm",
data = ["//:package.json"],
Expand Down
22 changes: 10 additions & 12 deletions e2e/npm_translate_lock_empty/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
module(
name = "e2e_npm_translate_lock",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
bazel_dep(name = "platforms", version = "0.0.8")

bazel_dep(name = "aspect_rules_js", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_js",
path = "../..",
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "platforms", version = "0.0.9", dev_dependency = True)

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)
npm.npm_translate_lock(
name = "npm",
data = ["//:package.json"],
Expand Down
17 changes: 8 additions & 9 deletions e2e/npm_translate_lock_git+ssh/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
module(
name = "e2e_npm_translate_lock_git_ssh",
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
bazel_dep(name = "aspect_rules_js", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_js",
path = "../..",
)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)
npm.npm_translate_lock(
name = "npm",
data = ["//:package.json"],
Expand Down
Loading

0 comments on commit 99275cd

Please sign in to comment.