Skip to content

Commit a587e13

Browse files
committed
Enable Bzlmod
All but finishes bazelbuild#1482, barring the release and publication to the Bazel Central Registry. Closes bazelbuild#1625. New `MODULE.bazel` files mirroring existing `WORKSPACE` configurations and copies of the `protobuf` toolchainization patch comprise the bulk of the commit. The empty `WORKSPACE.bzlmod` files ensure that Bzlmod won't evaluate the existing `WORKSPACE` files. Reenables the `last_green` Bazel build in CI. Other than that, these new files comprise the most significant part of the change: - `.bazelignore` - `.bcr/*` - `scala/extensions/config.bzl` - `scala/extensions/deps.bzl` - `scala/private/extensions/dev_deps.bzl` - `scala/private/macros/bzlmod.bzl` `config.bzl`, `deps.bzl`, and `dev_deps.bzl` are thoroughly tested by existing tests. These new test files thoroughly test the helpers from `scala/private/macros/bzlmod.bzl` specifically: - scala/private/macros/test/... - test/shell/test_bzlmod_macros.sh The pattern employed throughout the new module extensions is explained in the `scala/private/macros/bzlmod.bzl` docstring. Adding `test/shell/test_bzlmod_macros.sh` also precipitated adding a new `assert_matches` helper to `test/shell/test_helper.sh`. `test/shell/test_bzlmod_macros.sh` also introduces a mechanism for automatically finding and skipping tests, documented in the comment at the bottom of the file. Added `bazel mod tidy` checks to `test_lint.sh` and `test_version.sh` to ensure `MODULE.bazel` files remain consistent. Adds `bazel clean --expunge_async` to tests that create temporary repos and the `test_cleanup.sh` script to reclaim disk space. "Publish to BCR" configuration in the `.bcr` directory comes from: - https://github.com./bazel-contrib/publish-to-bcr/tree/main/templates The bazel-contrib/publish-to-bcr README contains further guidance on configuring the app. --- This change enables Bazel 7 and 8 users to migrate their `rules_scala` dependency from `WORKSPACE` to `MODULE.bazel` whenever they're ready. Once the Publish to BCR GitHub app is ready, we can use it to publish a new version to https://registry.bazel.build/. At that point, we can close bazelbuild#1482.
1 parent 54fe888 commit a587e13

File tree

82 files changed

+3601
-39
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3601
-39
lines changed

.bazelci/presubmit.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,15 @@ tasks:
2929
# Install xmllint
3030
- sudo apt update && sudo apt install --reinstall libxml2-utils -y
3131
- "./test_rules_scala.sh"
32-
# Switch `last_rc` to `last_green` once Bzlmod lands.
33-
# https://github.com./bazelbuild/rules_scala/issues/1482
34-
test_rules_scala_linux_last_rc:
35-
name: "./test_rules_scala (last_rc Bazel)"
32+
test_rules_scala_linux_last_green:
33+
name: "./test_rules_scala (last_green Bazel)"
3634
platform: ubuntu2004
37-
bazel: last_rc
35+
bazel: last_green
3836
shell_commands:
3937
# Install xmllint
4038
- sudo apt update && sudo apt install --reinstall libxml2-utils -y
4139
- echo "build --enable_workspace" >> .bazelrc
42-
- "./test_rules_scala.sh || buildkite-agent annotate --style 'warning' \"Optional build with last_rc Bazel version failed, [see here](${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}) (It is not mandatory but worth checking)\""
40+
- "./test_rules_scala.sh || buildkite-agent annotate --style 'warning' \"Optional build with last_green Bazel version failed, [see here](${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}) (It is not mandatory but worth checking)\""
4341
test_rules_scala_macos:
4442
name: "./test_rules_scala"
4543
platform: macos

.bazelignore

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Remove once the following is fixed:
2+
# - bazelbuild/bazel: Loading top-level targets in local_path_override modules
3+
# in child directory breaks the build #22208
4+
# https://github.com./bazelbuild/bazel/issues/22208
5+
dt_patches/compiler_sources
6+
dt_patches/test_dt_patches
7+
dt_patches/test_dt_patches_user_srcjar
8+
examples/crossbuild
9+
examples/overridden_artifacts
10+
examples/scala3
11+
examples/semanticdb
12+
examples/testing/multi_frameworks_toolchain
13+
examples/testing/scalatest_repositories
14+
examples/testing/specs2_junit_repositories
15+
test/proto_cross_repo_boundary/repo
16+
test_cross_build
17+
third_party/test/example_external_workspace
18+
third_party/test/new_local_repo
19+
third_party/test/proto

.bazelrc

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# Switch to --noenable_workspace when Bzlmod lands.
2-
# https://github.com./bazelbuild/rules_scala/issues/1482
3-
common --enable_workspace --noenable_bzlmod
1+
# Remove once Bazel 8 becomes the default supported version.
2+
common --noenable_workspace --incompatible_use_plus_in_repo_names
43

54
# Remove once proto toolchainization becomes the default
65
# - https://bazel.build/reference/command-line-reference#flag--incompatible_enable_proto_toolchain_resolution

.bcr/config.yml

Whitespace-only changes.

.bcr/metadata.template.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"homepage": "https://github.com./bazelbuild/rules_scala",
3+
"maintainers": [
4+
{
5+
"name": "Simonas Pinevičius",
6+
"email": "[email protected]",
7+
"github": "simuons"
8+
},
9+
{
10+
"name": "Vaidas Pilkauskas",
11+
"email": "[email protected]",
12+
"github": "liucijus"
13+
}
14+
],
15+
"repository": [
16+
"github:bazelbuild/rules_scala"
17+
],
18+
"versions": [],
19+
"yanked_versions": {}
20+
}

.bcr/presubmit.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# We recommend included a bcr test workspace that exercises your ruleset with bzlmod.
2+
# For an example, see https://github.com./aspect-build/bazel-lib/tree/main/e2e/bzlmod.
3+
bcr_test_module:
4+
module_path: "examples/crossbuild"
5+
matrix:
6+
platform: ["debian10", "macos", "ubuntu2004", "windows"]
7+
bazel: [6.x, 7.x]
8+
tasks:
9+
run_tests:
10+
name: "Run test module"
11+
platform: ${{ platform }}
12+
bazel: ${{ bazel }}
13+
test_targets:
14+
- "//..."

.bcr/source.template.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"integrity": "",
3+
"strip_prefix": "{REPO}-{VERSION}",
4+
"url": "https://github.com./{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
5+
}

.github/workflows/workspace_snippet.sh

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,23 @@ set -o errexit -o nounset -o pipefail
44

55
# Set by GH actions, see
66
# https://docs.github.com./en/actions/learn-github-actions/environment-variables#default-environment-variables
7-
TAG=${GITHUB_REF_NAME}
8-
PREFIX="rules_scala-${TAG:1}"
7+
TAG="${GITHUB_REF_NAME}"
8+
VERSION="${TAG:1}"
9+
PREFIX="rules_scala-${VERSION}"
910
ARCHIVE="rules_scala-$TAG.tar.gz"
1011
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
1112
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
1213

1314
cat << EOF
15+
## Using Bzlmod
16+
17+
Paste this snippet into your \`MODULE.bazel\` file:
18+
19+
\`\`\`starlark
20+
# Set \`repo_name = "io_bazel_rules_scala"\` if you still need it.
21+
bazel_dep(name = "rules_scala", version = "${VERSION}")
22+
\`\`\`
23+
1424
## Using WORKSPACE
1525
1626
Paste this snippet into your \`WORKSPACE\` file:

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ test/semanticdb/tempsrc
1616

1717
# From scripts/create_repository.py
1818
repository-artifacts.json
19+
20+
# Until it settles down
21+
**/MODULE.bazel.lock
22+
23+
# Used by some tests, but can also be used for local experimentation.
24+
tmp/

0 commit comments

Comments
 (0)