Buildifier fixes (#48691)

This resolves the buildifier failures we hit when running buildifier on
Aspect Workflows for the demo.

Test plan: CI

## App preview:

- [Web](https://sg-web-aspect-buildifier-fixes.onrender.com/search)

Check out the [client app preview
documentation](https://docs.sourcegraph.com/dev/how-to/client_pr_previews)
to learn more.
This commit is contained in:
Greg Magolan 2023-03-07 01:15:26 -08:00 committed by GitHub
parent e4149d55dc
commit a325a09005
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 5 deletions

8
BUILD.bazel generated
View File

@ -2,6 +2,9 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "nogo")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler")
load("@io_bazel_rules_go//proto/wkt:well_known_types.bzl", "WELL_KNOWN_TYPES_APIV2")
load("@npm//:defs.bzl", "npm_link_all_packages")
# Gazelle config
@ -37,8 +40,6 @@ ts_config(
],
)
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
gazelle_binary(
name = "gazelle-buf",
languages = [
@ -84,9 +85,6 @@ gazelle(
command = "update-repos",
)
load("@io_bazel_rules_go//proto/wkt:well_known_types.bzl", "WELL_KNOWN_TYPES_APIV2")
load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler")
# Because the current implementation of rules_go uses the old protoc grpc compiler, we have to declare our own, and declare it manually in the build files.
# See https://github.com/bazelbuild/rules_go/issues/3022
go_proto_compiler(

View File

@ -1,3 +1,5 @@
"GraphQL generation rule"
load("@aspect_rules_js//js:defs.bzl", "js_run_binary")
def generate_graphql_operations(name, interface_name, srcs, out, **kwargs):

View File

@ -1,3 +1,5 @@
"Schema generation rule"
load("@aspect_rules_js//js:defs.bzl", "js_run_binary")
load("@bazel_skylib//lib:collections.bzl", "collections")

View File

@ -1,6 +1,14 @@
"Bazel go dependencies"
load("@bazel_gazelle//:deps.bzl", "go_repository")
def go_dependencies():
"""The go dependencies in this macro are auto-updated by gazelle
To update run,
bazel run //:gazelle-update-repos
"""
go_repository(
name = "cc_mvdan_gofumpt",
build_file_proto_mode = "disable_global",

View File

@ -1,7 +1,21 @@
"Babel rule"
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//:@babel/cli/package_json.bzl", "bin")
def babel(name, srcs, module = None, **kwargs):
"""A wrapper around Babel CLI
Args:
name: A unique name for this target
srcs: A list of sources
module: If specified, sets BABEL_MODULE environment variable to this value
**kwargs: Additional arguments to pass to the rule
"""
# rules_js runs in the execroot under the output tree in bazel-out/[arch]/bin
execroot = "../../.."

View File

@ -1,3 +1,5 @@
"Bazel rules"
load("@bazel_skylib//lib:partial.bzl", "partial")
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@aspect_rules_js//npm:defs.bzl", _npm_package = "npm_package")
@ -15,6 +17,15 @@ USE_RAW_BABEL = True
sass = _sass
def ts_project(name, deps = [], **kwargs):
"""A wrapper around ts_project
Args:
name: A unique name for this target
deps: A list of dependencies
**kwargs: Additional arguments to pass to ts_project
"""
deps = deps + [
"//:node_modules/tslib",
]
@ -83,6 +94,15 @@ def _ts_project_tsc_impl(name, visibility, **kwargs):
)
def npm_package(name, srcs = [], **kwargs):
"""A wrapper around npm_package
Args:
name: A unique name for this target
srcs: A list of sources
**kwargs: Additional arguments to pass to npm_package
"""
replace_prefixes = kwargs.pop("replace_prefixes", {})
package_type = kwargs.pop("type", "module")

View File

@ -1,3 +1,5 @@
"Sass compilation rules"
load("@npm//client/build-config:sass/package_json.bzl", sass_bin = "bin")
load("@npm//client/build-config:postcss-cli/package_json.bzl", postcss_bin = "bin")
@ -7,6 +9,19 @@ def _sass_out(n):
# SASS and PostCSS
def sass(name, srcs, deps = [], runtime_deps = [], **kwargs):
"""Runs SASS and PostCSS on sass inputs
Args:
name: A unique name for the terminal target
srcs: A list of .scss sources
deps: A list of dependencies
runtime_deps: A list of runtime_dependencies
**kwargs: Additional arguments
"""
visibility = kwargs.pop("visibility", None)
sass_bin.sass(