Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support WORKSPACE #20

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v5
with:
folders: '[".", "example"]'
# Only test with Bazel 6 and bzlmod enabled. And we don't try for Windows support yet.
exclude: '[{"bazelversion": "5.4.0"}, {"bzlmodEnabled": false}, {"os": "windows-latest"}]'
# Only test with Bazel 6. And we don't try for Windows support yet.
exclude: '[{"bazelversion": "5.4.0"}, {"os": "windows-latest"}]'
15 changes: 15 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,20 @@ bazel_dep(name = "aspect_rules_lint", version = "${TAG:1}")
# - linting: https://github.com/aspect-build/rules_lint/blob/${TAG}/docs/linting.md
# - formatting: https://github.com/aspect-build/rules_lint/blob/${TAG}/docs/formatting.md
\`\`\`

## Using WORKSPACE

Paste this snippet into your `WORKSPACE.bazel` file:

\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "aspect_rules_lint",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/aspect-build/rules_lint/releases/download/${TAG}/${ARCHIVE}",
)
EOF

awk 'f;/--SNIP--/{f=1}' example/WORKSPACE.bazel
echo "\`\`\`"
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ Thanks!!

## Installation

rules_lint currently only works with bzlmod under Bazel 6+.
This is because we accumulate dependencies which are difficult to express
in a WORKSPACE file.
We might add support for WORKSPACE in the future.

Follow instructions from the release you wish to use:
<https://github.com/aspect-build/rules_lint/releases>

Expand Down
1 change: 0 additions & 1 deletion example/.bazelrc
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
common --enable_bzlmod
2 changes: 1 addition & 1 deletion example/.bazelversion
134 changes: 131 additions & 3 deletions example/WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,135 @@
# Marker that this is the root of a Bazel workspace
# Override http_archive for local testing
local_repository(
name = "aspect_rules_lint",
path = "..",
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_python",
sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b",
strip_prefix = "rules_python-0.26.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

py_repositories()

python_register_toolchains(
name = "python39",
python_version = "3.9",
)

load("@python39//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")

pip_parse(
name = "pip",
incompatible_generate_aliases = True,
python_interpreter_target = interpreter,
requirements_lock = "//:requirements.txt",
)

load("@pip//:requirements.bzl", "install_deps")

install_deps()

http_archive(
name = "aspect_rules_js",
sha256 = "7ab9776bcca823af361577a1a2ebb9a30d2eb5b94ecc964b8be360f443f714b2",
strip_prefix = "rules_js-1.32.6",
url = "https://github.com/aspect-build/rules_js/releases/download/v1.32.6/rules_js-v1.32.6.tar.gz",
)

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

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")

nodejs_register_toolchains(
name = "nodejs",
node_version = DEFAULT_NODE_VERSION,
)

load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)

load("@npm//:repositories.bzl", "npm_repositories")

npm_repositories()

http_archive(
name = "aspect_rules_ts",
sha256 = "8eb25d1fdafc0836f5778d33fb8eaac37c64176481d67872b54b0a05de5be5c0",
strip_prefix = "rules_ts-1.3.3",
url = "https://github.com/aspect-build/rules_ts/releases/download/v1.3.3/rules_ts-v1.3.3.tar.gz",
)

load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")

rules_ts_dependencies(
ts_version_from = "//:package.json",
)

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

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

buildifier_prebuilt_deps()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

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

buildifier_prebuilt_register_toolchains()

http_archive(
name = "io_bazel_rules_go",
sha256 = "51dc53293afe317d2696d4d6433a4c33feedb7748a9e352072e2ec3c0dafd2c6",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.40.1/rules_go-v0.40.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.40.1/rules_go-v0.40.1.zip",
],
)

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

go_rules_dependencies()

go_register_toolchains(version = "1.20.3")

http_archive(
name = "com_google_protobuf",
sha256 = "d7d204a59fd0d2d2387bd362c2155289d5060f32122c4d1d922041b61191d522",
strip_prefix = "protobuf-3.21.5",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.21.5.tar.gz"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

#---SNIP--- Below here is re-used in the workspace snippet published on releases

# Support repos that aren't on bazel central registry
# Needed until Bazel 7 allows MODULE.bazel to directly call repository rules
# Use whichever formatter binaries you need:
load(
"@aspect_rules_lint//format:repositories.bzl",
"fetch_java_format",
Expand Down
26 changes: 26 additions & 0 deletions example/WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Marker that this is the root of a Bazel workspace
# This file shadows WORKSPACE.bazel under --enable_bzlmod.

# Support repos that aren't on bazel central registry
# Needed until Bazel 7 allows MODULE.bazel to directly call repository rules
load(
"@aspect_rules_lint//format:repositories.bzl",
"fetch_java_format",
"fetch_jsonnet",
"fetch_ktfmt",
"fetch_pmd",
"fetch_swiftformat",
"fetch_terraform",
)

fetch_pmd()

fetch_jsonnet()

fetch_terraform()

fetch_java_format()

fetch_ktfmt()

fetch_swiftformat()
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"eslint": "*",
"@typescript-eslint/parser": "*",
"@typescript-eslint/eslint-plugin": "*",
"typescript": "5.0",
"typescript": "4.9.5",
"prettier": "^2.8.7",
"prettier-plugin-sh": "^0.12.8",
"prettier-plugin-sql": "^0.14.0"
Expand Down
58 changes: 28 additions & 30 deletions example/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.