diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7a55e0ba..ed5bc714 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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"}]' diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh index cb4e3bb3..0e6c2f75 100755 --- a/.github/workflows/release_prep.sh +++ b/.github/workflows/release_prep.sh @@ -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 "\`\`\`" \ No newline at end of file diff --git a/README.md b/README.md index d61737e1..97e7230e 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/example/.bazelrc b/example/.bazelrc index 3ce91d27..e69de29b 100644 --- a/example/.bazelrc +++ b/example/.bazelrc @@ -1 +0,0 @@ -common --enable_bzlmod diff --git a/example/.bazelversion b/example/.bazelversion index 96cf9496..b3326049 120000 --- a/example/.bazelversion +++ b/example/.bazelversion @@ -1 +1 @@ -../../.bazelversion \ No newline at end of file +../.bazelversion \ No newline at end of file diff --git a/example/WORKSPACE.bazel b/example/WORKSPACE.bazel index 37e39e55..ee20a2ec 100644 --- a/example/WORKSPACE.bazel +++ b/example/WORKSPACE.bazel @@ -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", diff --git a/example/WORKSPACE.bzlmod b/example/WORKSPACE.bzlmod new file mode 100644 index 00000000..471e1172 --- /dev/null +++ b/example/WORKSPACE.bzlmod @@ -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() diff --git a/example/package.json b/example/package.json index eb6980a5..afab9fe0 100644 --- a/example/package.json +++ b/example/package.json @@ -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" diff --git a/example/pnpm-lock.yaml b/example/pnpm-lock.yaml index 6d41462a..f31f1922 100644 --- a/example/pnpm-lock.yaml +++ b/example/pnpm-lock.yaml @@ -9,16 +9,16 @@ specifiers: prettier: ^2.8.7 prettier-plugin-sh: ^0.12.8 prettier-plugin-sql: ^0.14.0 - typescript: "5.0" + typescript: 4.9.5 devDependencies: - "@typescript-eslint/eslint-plugin": 5.59.1_2utyh6gct5glvuz6qwradubqqa - "@typescript-eslint/parser": 5.59.1_iacogk7kkaymxepzhgcbytyi7q + "@typescript-eslint/eslint-plugin": 5.59.1_jsr5owskg7irefkzbmq6cipclm + "@typescript-eslint/parser": 5.59.1_tbtvr3a5zwdiktqy4vlmx63mqq eslint: 8.39.0 prettier: 2.8.8_whkmnyg4gs3djzcukwmxxipg5m prettier-plugin-sh: 0.12.8_prettier@2.8.8 prettier-plugin-sql: 0.14.0_prettier@2.8.8 - typescript: 5.0.4 + typescript: 4.9.5 packages: /@eslint-community/eslint-utils/4.4.0_eslint@8.39.0: @@ -182,7 +182,7 @@ packages: } dev: true - /@typescript-eslint/eslint-plugin/5.59.1_2utyh6gct5glvuz6qwradubqqa: + /@typescript-eslint/eslint-plugin/5.59.1_jsr5owskg7irefkzbmq6cipclm: resolution: { integrity: sha512-AVi0uazY5quFB9hlp2Xv+ogpfpk77xzsgsIEWyVS7uK/c7MZ5tw7ZPbapa0SbfkqE0fsAMkz5UwtgMLVk2BQAg==, @@ -199,23 +199,23 @@ packages: optional: true dependencies: "@eslint-community/regexpp": 4.5.0 - "@typescript-eslint/parser": 5.59.1_iacogk7kkaymxepzhgcbytyi7q + "@typescript-eslint/parser": 5.59.1_tbtvr3a5zwdiktqy4vlmx63mqq "@typescript-eslint/scope-manager": 5.59.1 - "@typescript-eslint/type-utils": 5.59.1_iacogk7kkaymxepzhgcbytyi7q - "@typescript-eslint/utils": 5.59.1_iacogk7kkaymxepzhgcbytyi7q + "@typescript-eslint/type-utils": 5.59.1_tbtvr3a5zwdiktqy4vlmx63mqq + "@typescript-eslint/utils": 5.59.1_tbtvr3a5zwdiktqy4vlmx63mqq debug: 4.3.4 eslint: 8.39.0 grapheme-splitter: 1.0.4 ignore: 5.2.4 natural-compare-lite: 1.4.0 semver: 7.5.0 - tsutils: 3.21.0_typescript@5.0.4 - typescript: 5.0.4 + tsutils: 3.21.0_typescript@4.9.5 + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser/5.59.1_iacogk7kkaymxepzhgcbytyi7q: + /@typescript-eslint/parser/5.59.1_tbtvr3a5zwdiktqy4vlmx63mqq: resolution: { integrity: sha512-nzjFAN8WEu6yPRDizIFyzAfgK7nybPodMNFGNH0M9tei2gYnYszRDqVA0xlnRjkl7Hkx2vYrEdb6fP2a21cG1g==, @@ -232,10 +232,10 @@ packages: dependencies: "@typescript-eslint/scope-manager": 5.59.1 "@typescript-eslint/types": 5.59.1 - "@typescript-eslint/typescript-estree": 5.59.1_typescript@5.0.4 + "@typescript-eslint/typescript-estree": 5.59.1_typescript@4.9.5 debug: 4.3.4 eslint: 8.39.0 - typescript: 5.0.4 + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true @@ -253,7 +253,7 @@ packages: "@typescript-eslint/visitor-keys": 5.59.1 dev: true - /@typescript-eslint/type-utils/5.59.1_iacogk7kkaymxepzhgcbytyi7q: + /@typescript-eslint/type-utils/5.59.1_tbtvr3a5zwdiktqy4vlmx63mqq: resolution: { integrity: sha512-ZMWQ+Oh82jWqWzvM3xU+9y5U7MEMVv6GLioM3R5NJk6uvP47kZ7YvlgSHJ7ERD6bOY7Q4uxWm25c76HKEwIjZw==, @@ -268,12 +268,12 @@ packages: typescript: optional: true dependencies: - "@typescript-eslint/typescript-estree": 5.59.1_typescript@5.0.4 - "@typescript-eslint/utils": 5.59.1_iacogk7kkaymxepzhgcbytyi7q + "@typescript-eslint/typescript-estree": 5.59.1_typescript@4.9.5 + "@typescript-eslint/utils": 5.59.1_tbtvr3a5zwdiktqy4vlmx63mqq debug: 4.3.4 eslint: 8.39.0 - tsutils: 3.21.0_typescript@5.0.4 - typescript: 5.0.4 + tsutils: 3.21.0_typescript@4.9.5 + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true @@ -288,7 +288,7 @@ packages: engines: { node: ^12.22.0 || ^14.17.0 || >=16.0.0 } dev: true - /@typescript-eslint/typescript-estree/5.59.1_typescript@5.0.4: + /@typescript-eslint/typescript-estree/5.59.1_typescript@4.9.5: resolution: { integrity: sha512-lYLBBOCsFltFy7XVqzX0Ju+Lh3WPIAWxYpmH/Q7ZoqzbscLiCW00LeYCdsUnnfnj29/s1WovXKh2gwCoinHNGA==, @@ -308,13 +308,13 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.0 - tsutils: 3.21.0_typescript@5.0.4 - typescript: 5.0.4 + tsutils: 3.21.0_typescript@4.9.5 + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils/5.59.1_iacogk7kkaymxepzhgcbytyi7q: + /@typescript-eslint/utils/5.59.1_tbtvr3a5zwdiktqy4vlmx63mqq: resolution: { integrity: sha512-MkTe7FE+K1/GxZkP5gRj3rCztg45bEhsd8HYjczBuYm+qFHP5vtZmjx3B0yUCDotceQ4sHgTyz60Ycl225njmA==, @@ -330,7 +330,7 @@ packages: "@types/semver": 7.3.13 "@typescript-eslint/scope-manager": 5.59.1 "@typescript-eslint/types": 5.59.1 - "@typescript-eslint/typescript-estree": 5.59.1_typescript@5.0.4 + "@typescript-eslint/typescript-estree": 5.59.1_typescript@4.9.5 eslint: 8.39.0 eslint-scope: 5.1.1 semver: 7.5.0 @@ -1996,7 +1996,7 @@ packages: } dev: true - /tsutils/3.21.0_typescript@5.0.4: + /tsutils/3.21.0_typescript@4.9.5: resolution: { integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==, @@ -2008,7 +2008,7 @@ packages: typescript: ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" dependencies: tslib: 1.14.1 - typescript: 5.0.4 + typescript: 4.9.5 dev: true /type-check/0.4.0: @@ -2033,14 +2033,12 @@ packages: engines: { node: ">=10" } dev: true - /typescript/5.0.4: + /typescript/4.9.5: resolution: { - integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==, - registry: https://registry.npmjs.com/, - tarball: https://registry.npmjs.com/typescript/-/typescript-5.0.4.tgz, + integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==, } - engines: { node: ">=12.20" } + engines: { node: ">=4.2.0" } hasBin: true dev: true