Add a test for the `@rules_java` release notes generator PiperOrigin-RevId: 740752942 Change-Id: I01455d2ef20f027f4c253324eda650694c9254f6
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index de1be01..a1dddbb 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml
@@ -22,8 +22,6 @@ test_targets: &test_targets - "//test/..." - "//java/test/..." - # linux-only tests - - "-//test:check_remote_jdk_configs_test" # TODO: re-enable docs after moving them out of https://bazel.build/reference/be/java - "-//test:docs_up_to_date_test" @@ -108,5 +106,10 @@ name: "Extra tests w/ Bazel {bazel}" bazel: ${{ bazel }} platform: "ubuntu2004" + shell_commands: + - "git config user.name 'fake-user-for-testing'" + - "git tag -a 'fake-tag-for-testing' -m 'ignore'" + - "git commit --allow-empty -m 'Fake commit message for testing'" test_targets: - "//test:check_remote_jdk_configs_test" + - "//test:check_release_notes_test"
diff --git a/distro/relnotes.bzl b/distro/relnotes.bzl index 71f3d83..5641bf7 100644 --- a/distro/relnotes.bzl +++ b/distro/relnotes.bzl
@@ -48,4 +48,5 @@ """.format(ARCHIVE = archive, VERSION = version), srcs = [archive], tags = ["local", "manual"], + visibility = ["//test:__pkg__"], )
diff --git a/test/BUILD.bazel b/test/BUILD.bazel index c9dd65b..70e62b5 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel
@@ -31,6 +31,7 @@ for configs in REMOTE_JDK_CONFIGS.values() for config in configs ], + tags = ["manual"], # explicitly tested only on Linux ) sh_test( @@ -47,6 +48,17 @@ ], ) +sh_test( + name = "check_release_notes_test", + srcs = ["check_release_notes_test.sh"], + args = [ + "$(location //distro:relnotes.txt)", + module_version(), + ], + data = ["//distro:relnotes.txt"], + tags = ["manual"], # explicitly tested only on Linux +) + diff_test( name = "docs_up_to_date_test", failure_message = """
diff --git a/test/check_release_notes_test.sh b/test/check_release_notes_test.sh new file mode 100755 index 0000000..86f0288 --- /dev/null +++ b/test/check_release_notes_test.sh
@@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# Copyright 2025 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +RELNOTES_FILE=$1 +VERSION=$2 + +function fail() { + echo "ERROR: ${1}" + echo "Release notes content:" + echo "--------------------------------------" + cat ${RELNOTES_FILE} + echo "--------------------------------------" + exit 1 +} + +echo "Checking generated release notes: ${RELNOTES_FILE}" + +grep -q '**Changes since fake-tag-for-tests**' ${RELNOTES_FILE} || fail "No changelog header" +grep -q 'Fake commit message for testing' ${RELNOTES_FILE} || fail "No changelog commit" +grep -q '**MODULE.bazel setup**' ${RELNOTES_FILE} || fail "No bzlmod setup header" +grep -q "bazel_dep(name = \"rules_java\", version = \"${VERSION}\")" ${RELNOTES_FILE} || fail "No bzlmod dep stanza" +grep -q '**WORKSPACE setup**' ${RELNOTES_FILE} || fail "No WORKSPACE setup header" +grep -q '**Using the rules**' ${RELNOTES_FILE} || fail "No using the rules header"