From 288cc01268d2df349ff782cf7359aff06c051d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20Andr=C3=A9?= <92062874+matheusandre1@users.noreply.github.com> Date: Sat, 26 Sep 2026 03:19:58 -0300 Subject: [PATCH] ci: verify the source-derived shard class list against compiled test classes (#4245) all-classes.txt is derived from src/test/java file names so shard.txt exists before Compile. A test class whose name differed from its file would drop out of both all-classes.txt and the shard union, and the completeness check in CI summary would not notice. After Compile, derive the list from target/test-classes as before and fail the shard if the two disagree. --- .github/workflows/ci.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a0702ffe5..35de0c30a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,7 +74,8 @@ jobs: # Derived from test sources, not target/test-classes, so shard.txt exists # before Compile and the image prefetch below overlaps the compile instead # of starting moments before the tests that need the images. Every test is - # a top-level class in src/test/java, so the file name is the class name. + # a top-level class in src/test/java, so the file name is the class name; + # the step after Compile fails the shard if that ever stops being true. - name: Compute shard include list run: | cd src/test/java @@ -95,6 +96,22 @@ jobs: - name: Compile run: ./mvnw test-compile -B + # all-classes.txt is derived from file names, so a test class whose name + # differs from its file would drop out of both it and the shard union + # without the completeness check noticing. The compiled classes are the + # ground truth; fail here if the two lists ever disagree. + - name: Verify shard list matches compiled test classes + run: | + cd target/test-classes + find . \( -name '*Test.class' -o -name 'Test*.class' \ + -o -name '*Tests.class' -o -name '*TestCase.class' \) \ + ! -name '*$*' \ + | sed 's|^\./||; s|\.class$||' | LC_ALL=C sort \ + > "$RUNNER_TEMP/compiled-classes.txt" + cd "$GITHUB_WORKSPACE" + cmp -s all-classes.txt "$RUNNER_TEMP/compiled-classes.txt" \ + || { echo "::error::test class list from src/test/java differs from target/test-classes:"; diff all-classes.txt "$RUNNER_TEMP/compiled-classes.txt" | head -50; exit 1; } + - name: Run tests run: > ./mvnw surefire:test -B