Skip to content

build: stop using bazel_collect in coverage jobs#67634

Merged
ti-chi-bot[bot] merged 4 commits intopingcap:masterfrom
hawkingrei:fix-jenkins-bazel-collect-bootstrap
Apr 9, 2026
Merged

build: stop using bazel_collect in coverage jobs#67634
ti-chi-bot[bot] merged 4 commits intopingcap:masterfrom
hawkingrei:fix-jenkins-bazel-collect-bootstrap

Conversation

@hawkingrei
Copy link
Copy Markdown
Member

@hawkingrei hawkingrei commented Apr 9, 2026

What problem does this PR solve?

Issue Number: N/A

Problem Summary:
Coverage jobs assume Bazel artifacts are always present. When coverage execution fails early, _coverage_report.dat and bazel.xml may be missing, which causes a secondary failure during artifact collection and can hide the original test failure.

What changed and how does it work?

  • Stop relying on bazel_collect in the Jenkins coverage helper scripts.
  • Copy ./bazel-out/_coverage/_coverage_report.dat directly when it exists.
  • Create an empty coverage.dat with a warning when the Bazel coverage report is absent.
  • Move bazel.xml into test_coverage/ when it exists.
  • Create an empty test_coverage/bazel.xml with a warning when the junit report is absent.
  • Preserve the original exit status from make bazel_coverage_test* in the unit-test scripts.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.
    • The change is limited to Jenkins helper scripts.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Summary by CodeRabbit

  • Bug Fixes

    • Improved build reliability by handling missing test artifacts gracefully: creates an empty coverage file and emits warnings instead of failing when reports are absent; preserves original test exit status.
  • Chores

    • Standardized conditional collection and reporting of coverage and test results across CI scripts for clearer, consistent behavior and error messages.

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

📝 Walkthrough

Walkthrough

Three Jenkins build scripts were changed to install bazel_collect, define coverage_report and junit_report variables, and conditionally collect/copy/move Bazel coverage and JUnit artifacts, emitting warnings and creating empty coverage files when sources are absent while preserving original exit codes.

Changes

Cohort / File(s) Summary
Build Script Artifact Handling
build/jenkins_collect_coverage.sh, build/jenkins_unit_test.sh, build/jenkins_unit_test_ddlargsv1.sh
Replaced unconditional bazel_collect and direct artifact ops with explicit install and conditional logic. Added coverage_report (./bazel-out/_coverage/_coverage_report.dat) and junit_report (./bazel.xml) variables, ensured test_coverage/ exists (collect script), copy coverage to ./coverage.dat only if present (else create/truncate empty and warn), move bazel.xml to test_coverage/bazel.xml only if present (else warn). Exit-status preserved.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

size/L

Suggested reviewers

  • lance6716
  • tiancaiamao
  • YangKeao

Poem

🐰 I hopped through builds at break of day,
I install, then look where reports may stay,
If coverage hides, I leave a tidy space,
If junit's missing, I note its place,
Quiet fixes made in a careful way.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: removing bazel_collect dependency from coverage jobs.
Description check ✅ Passed The description includes all required sections: problem statement, what changed/how it works, checklist with appropriate selections, side effects, and release notes. It clearly explains the issue and solution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hawkingrei hawkingrei changed the title build: bootstrap bazel_collect in coverage jobs build: stop using bazel_collect in coverage jobs Apr 9, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@build/jenkins_collect_coverage.sh`:
- Around line 32-36: The fallback branch in build/jenkins_collect_coverage.sh
currently creates a zero-byte placeholder for "${junit_report}" (variable
junit_report) which yields malformed JUnit XML; replace the no-op redirection (:
> test_coverage/bazel.xml) with code that writes a minimal valid JUnit document
(e.g. an empty <testsuite> root with required attributes) into
test_coverage/bazel.xml and keep the warning to stderr; apply the same change to
any sibling scripts that use the same fallback so downstream JUnit parsers
receive a valid XML file instead of a zero-byte file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c9bc55df-aa8d-4163-bce7-2826bf7cfd62

📥 Commits

Reviewing files that changed from the base of the PR and between c245042 and e03f2e2.

📒 Files selected for processing (3)
  • build/jenkins_collect_coverage.sh
  • build/jenkins_unit_test.sh
  • build/jenkins_unit_test_ddlargsv1.sh

Comment thread build/jenkins_collect_coverage.sh Outdated
@hawkingrei hawkingrei added the skip-issue-check Indicates that a PR no need to check linked issue. label Apr 9, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.4185%. Comparing base (c245042) to head (b4353b4).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #67634        +/-   ##
================================================
- Coverage   77.5948%   77.4185%   -0.1763%     
================================================
  Files          1981       1965        -16     
  Lines        547950     547963        +13     
================================================
- Hits         425181     424225       -956     
- Misses       121959     123736      +1777     
+ Partials        810          2       -808     
Flag Coverage Δ
integration 40.9294% <ø> (+6.5897%) ⬆️
unit 76.6404% <ø> (+0.2971%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 61.5065% <ø> (ø)
parser ∅ <ø> (∅)
br 49.9124% <ø> (-10.5260%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
build/jenkins_unit_test_ddlargsv1.sh (1)

35-39: ⚠️ Potential issue | 🟠 Major

Use a valid empty JUnit fallback instead of skipping artifact creation.

This branch has the same stale/missing artifact risk as the coverage collector script. Please emit a minimal test_coverage/bazel.xml when source JUnit is absent.

🩹 Proposed fix
 if [ -f "${junit_report}" ]; then
     mv "${junit_report}" test_coverage/bazel.xml
 else
-    echo "warning: junit report ${junit_report} not found, skipping junit artifact collection" >&2
+    cat > test_coverage/bazel.xml <<'EOF'
+<?xml version="1.0" encoding="UTF-8"?>
+<testsuite name="bazel" tests="0" failures="0" errors="0" skipped="0"/>
+EOF
+    echo "warning: junit report ${junit_report} not found, created empty test_coverage/bazel.xml" >&2
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@build/jenkins_unit_test_ddlargsv1.sh` around lines 35 - 39, When
${junit_report} is missing, create the test_coverage directory if needed and
emit a minimal valid JUnit XML at test_coverage/bazel.xml instead of skipping;
update the else branch to mkdir -p test_coverage and write a small XML like a
<testsuites>/<testsuite> wrapper with tests="0" failures="0" and a timestamp or
placeholder to ensure CI consumers treat it as a valid artifact (reference
${junit_report} and test_coverage/bazel.xml in your change).
build/jenkins_collect_coverage.sh (1)

32-36: ⚠️ Potential issue | 🟠 Major

Always materialize test_coverage/bazel.xml when JUnit is missing.

At Line 35, skipping creation can leave stale test_coverage/bazel.xml from previous workspace runs and can still break report consumers expecting this artifact. Write a minimal valid empty JUnit XML instead of skipping.

🩹 Proposed fix
 if [ -f "${junit_report}" ]; then
     mv "${junit_report}" test_coverage/bazel.xml
 else
-    echo "warning: junit report ${junit_report} not found, skipping junit artifact collection" >&2
+    cat > test_coverage/bazel.xml <<'EOF'
+<?xml version="1.0" encoding="UTF-8"?>
+<testsuite name="bazel" tests="0" failures="0" errors="0" skipped="0"/>
+EOF
+    echo "warning: junit report ${junit_report} not found, created empty test_coverage/bazel.xml" >&2
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@build/jenkins_collect_coverage.sh` around lines 32 - 36, The script currently
skips creating test_coverage/bazel.xml when ${junit_report} is missing, which
leaves stale artifacts; update the else branch in jenkins_collect_coverage.sh to
always materialize a minimal valid JUnit XML at test_coverage/bazel.xml (ensure
the test_coverage directory exists using mkdir -p) and write a simple empty
test-suite XML (with root <testsuites> or <testsuite> and zero tests) to that
path so consumers always find a well-formed file even when ${junit_report} is
absent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@build/jenkins_collect_coverage.sh`:
- Around line 32-36: The script currently skips creating test_coverage/bazel.xml
when ${junit_report} is missing, which leaves stale artifacts; update the else
branch in jenkins_collect_coverage.sh to always materialize a minimal valid
JUnit XML at test_coverage/bazel.xml (ensure the test_coverage directory exists
using mkdir -p) and write a simple empty test-suite XML (with root <testsuites>
or <testsuite> and zero tests) to that path so consumers always find a
well-formed file even when ${junit_report} is absent.

In `@build/jenkins_unit_test_ddlargsv1.sh`:
- Around line 35-39: When ${junit_report} is missing, create the test_coverage
directory if needed and emit a minimal valid JUnit XML at
test_coverage/bazel.xml instead of skipping; update the else branch to mkdir -p
test_coverage and write a small XML like a <testsuites>/<testsuite> wrapper with
tests="0" failures="0" and a timestamp or placeholder to ensure CI consumers
treat it as a valid artifact (reference ${junit_report} and
test_coverage/bazel.xml in your change).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b9006bf8-f9c8-42eb-b127-14190acee288

📥 Commits

Reviewing files that changed from the base of the PR and between e03f2e2 and 0bcc61b.

📒 Files selected for processing (3)
  • build/jenkins_collect_coverage.sh
  • build/jenkins_unit_test.sh
  • build/jenkins_unit_test_ddlargsv1.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • build/jenkins_unit_test.sh

@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 9, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (3)
build/jenkins_unit_test.sh (2)

26-26: ⚠️ Potential issue | 🟠 Major

Same unused floating install here should be removed.

Line 26 has the same unused go install ...@latest risk as the collector script.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@build/jenkins_unit_test.sh` at line 26, Remove the unused floating Go install
command "go install github.com/hawkingrei/bazel_collect@latest" from the script;
locate the occurrence of that exact install invocation in the
jenkins_unit_test.sh script and delete it (or replace it with a proper explicit
dependency installation step tied to a variable or build target if needed) so
there are no stray `@latest` installs left.

37-41: ⚠️ Potential issue | 🟠 Major

JUnit missing-file fallback should create a minimal XML artifact.

Same fallback gap as the sibling script: skipping file creation can still cause downstream junit collection failures.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@build/jenkins_unit_test.sh` around lines 37 - 41, The script currently skips
creating a JUnit artifact when the ${junit_report} file is missing; change the
else branch to write a minimal valid JUnit XML to test_coverage/bazel.xml so
downstream collectors always find a file. In the else branch, create the
test_coverage directory if needed and write a small XML skeleton (e.g., empty
<testsuites> or a single <testsuite> with zero tests) to
test_coverage/bazel.xml, and keep the warning message — this ensures consumers
that expect test_coverage/bazel.xml won't fail when ${junit_report} is absent.
build/jenkins_collect_coverage.sh (1)

34-38: ⚠️ Potential issue | 🟠 Major

Fallback should still emit a valid JUnit artifact file.

When bazel.xml is missing, this now only logs and skips artifact creation. That can still break downstream steps expecting test_coverage/bazel.xml to exist. Please write a minimal valid empty JUnit XML instead.

🩹 Proposed fix
 if [ -f "${junit_report}" ]; then
     mv "${junit_report}" test_coverage/bazel.xml
 else
-    echo "warning: junit report ${junit_report} not found, skipping junit artifact collection" >&2
+    cat > test_coverage/bazel.xml <<'EOF'
+<?xml version="1.0" encoding="UTF-8"?>
+<testsuite name="bazel" tests="0" failures="0" errors="0" skipped="0"/>
+EOF
+    echo "warning: junit report ${junit_report} not found, created empty test_coverage/bazel.xml" >&2
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@build/jenkins_collect_coverage.sh` around lines 34 - 38, When ${junit_report}
is missing the script currently only logs and skips creating
test_coverage/bazel.xml; instead ensure the directory exists and write a minimal
valid JUnit XML to test_coverage/bazel.xml so downstream steps always find a
JUnit artifact. Modify the else branch to mkdir -p test_coverage and create a
small XML file (e.g. with an XML prolog and an empty <testsuites> or a
<testsuite name="empty" tests="0" failures="0"/> element) into
test_coverage/bazel.xml, while still emitting the existing warning to stderr
using the same message.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@build/jenkins_collect_coverage.sh`:
- Line 26: Remove the unused "go install
github.com/hawkingrei/bazel_collect@latest" invocation from the script; locate
the literal install line in build/jenkins_collect_coverage.sh, delete it, and
ensure there are no other references or invocations of bazel_collect in the
script (if any exist, either remove them or add a justified, pinned installation
and invocation), so CI no longer pulls this external dependency with a floating
version.

---

Duplicate comments:
In `@build/jenkins_collect_coverage.sh`:
- Around line 34-38: When ${junit_report} is missing the script currently only
logs and skips creating test_coverage/bazel.xml; instead ensure the directory
exists and write a minimal valid JUnit XML to test_coverage/bazel.xml so
downstream steps always find a JUnit artifact. Modify the else branch to mkdir
-p test_coverage and create a small XML file (e.g. with an XML prolog and an
empty <testsuites> or a <testsuite name="empty" tests="0" failures="0"/>
element) into test_coverage/bazel.xml, while still emitting the existing warning
to stderr using the same message.

In `@build/jenkins_unit_test.sh`:
- Line 26: Remove the unused floating Go install command "go install
github.com/hawkingrei/bazel_collect@latest" from the script; locate the
occurrence of that exact install invocation in the jenkins_unit_test.sh script
and delete it (or replace it with a proper explicit dependency installation step
tied to a variable or build target if needed) so there are no stray `@latest`
installs left.
- Around line 37-41: The script currently skips creating a JUnit artifact when
the ${junit_report} file is missing; change the else branch to write a minimal
valid JUnit XML to test_coverage/bazel.xml so downstream collectors always find
a file. In the else branch, create the test_coverage directory if needed and
write a small XML skeleton (e.g., empty <testsuites> or a single <testsuite>
with zero tests) to test_coverage/bazel.xml, and keep the warning message — this
ensures consumers that expect test_coverage/bazel.xml won't fail when
${junit_report} is absent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0be426e1-51f6-4f63-83bd-c5fda6a29839

📥 Commits

Reviewing files that changed from the base of the PR and between 0bcc61b and b4353b4.

📒 Files selected for processing (3)
  • build/jenkins_collect_coverage.sh
  • build/jenkins_unit_test.sh
  • build/jenkins_unit_test_ddlargsv1.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • build/jenkins_unit_test_ddlargsv1.sh

Comment thread build/jenkins_collect_coverage.sh
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 9, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, Defined2014

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [D3Hunter,Defined2014]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 9, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 9, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-09 03:42:39.041549036 +0000 UTC m=+1014164.246909093: ☑️ agreed by D3Hunter.
  • 2026-04-09 04:16:58.736055491 +0000 UTC m=+1016223.941415558: ☑️ agreed by Defined2014.

@ti-chi-bot ti-chi-bot Bot merged commit e0b4e44 into pingcap:master Apr 9, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. skip-issue-check Indicates that a PR no need to check linked issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants