Skip to content

Commit 4b91b00

Browse files
hvadehrarules_java Copybara
authored andcommitted
Add a test for the @rules_java release notes generator
PiperOrigin-RevId: 740752942 Change-Id: I01455d2ef20f027f4c253324eda650694c9254f6
1 parent 8c7993f commit 4b91b00

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

.bazelci/presubmit.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ build_targets_integration: &build_targets_integration
2222
test_targets: &test_targets
2323
- "//test/..."
2424
- "//java/test/..."
25-
# linux-only tests
26-
- "-//test:check_remote_jdk_configs_test"
2725
# TODO: re-enable docs after moving them out of https://bazel.build/reference/be/java
2826
- "-//test:docs_up_to_date_test"
2927

@@ -108,5 +106,10 @@ tasks:
108106
name: "Extra tests w/ Bazel {bazel}"
109107
bazel: ${{ bazel }}
110108
platform: "ubuntu2004"
109+
shell_commands:
110+
- "git config user.name 'fake-user-for-testing'"
111+
- "git tag -a 'fake-tag-for-testing' -m 'ignore'"
112+
- "git commit --allow-empty -m 'Fake commit message for testing'"
111113
test_targets:
112114
- "//test:check_remote_jdk_configs_test"
115+
- "//test:check_release_notes_test"

distro/relnotes.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ EOF
4848
""".format(ARCHIVE = archive, VERSION = version),
4949
srcs = [archive],
5050
tags = ["local", "manual"],
51+
visibility = ["//test:__pkg__"],
5152
)

test/BUILD.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ sh_test(
3131
for configs in REMOTE_JDK_CONFIGS.values()
3232
for config in configs
3333
],
34+
tags = ["manual"], # explicitly tested only on Linux
3435
)
3536

3637
sh_test(
@@ -47,6 +48,17 @@ sh_test(
4748
],
4849
)
4950

51+
sh_test(
52+
name = "check_release_notes_test",
53+
srcs = ["check_release_notes_test.sh"],
54+
args = [
55+
"$(location //distro:relnotes.txt)",
56+
module_version(),
57+
],
58+
data = ["//distro:relnotes.txt"],
59+
tags = ["manual"], # explicitly tested only on Linux
60+
)
61+
5062
diff_test(
5163
name = "docs_up_to_date_test",
5264
failure_message = """

test/check_release_notes_test.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2025 The Bazel Authors. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
RELNOTES_FILE=$1
17+
VERSION=$2
18+
19+
function fail() {
20+
echo "ERROR: ${1}"
21+
echo "Release notes content:"
22+
echo "--------------------------------------"
23+
cat ${RELNOTES_FILE}
24+
echo "--------------------------------------"
25+
exit 1
26+
}
27+
28+
echo "Checking generated release notes: ${RELNOTES_FILE}"
29+
30+
grep -q '**Changes since fake-tag-for-tests**' ${RELNOTES_FILE} || fail "No changelog header"
31+
grep -q 'Fake commit message for testing' ${RELNOTES_FILE} || fail "No changelog commit"
32+
grep -q '**MODULE.bazel setup**' ${RELNOTES_FILE} || fail "No bzlmod setup header"
33+
grep -q "bazel_dep(name = \"rules_java\", version = \"${VERSION}\")" ${RELNOTES_FILE} || fail "No bzlmod dep stanza"
34+
grep -q '**WORKSPACE setup**' ${RELNOTES_FILE} || fail "No WORKSPACE setup header"
35+
grep -q '**Using the rules**' ${RELNOTES_FILE} || fail "No using the rules header"

0 commit comments

Comments
 (0)