Skip to content

Conversation

@RobertIndie
Copy link
Member

@RobertIndie RobertIndie commented May 14, 2025

Motivation

This PR #1351 introduced some changes but breaked the CI. Currently, even if there are some failed tests, the CI won't be failed: https://github.com/apache/pulsar-client-go/actions/runs/14973771263/job/42060743359?pr=1364#step:6:9285

The root cause is because it captures the exit status of the tee command instead of the go test command. This causes the script to report "Tests passed" even when tests actually fail, leading to false positive CI results.

$TEST_CMD 2>&1 | tee $TEST_LOG

Modification

  • Use set -o pipefail to correctly capture the exit status of the go test command in the pipeline

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API: (yes / no)
  • The schema: (yes / no / don't know)
  • The default values of configurations: (yes / no)
  • The wire protocol: (yes / no)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / GoDocs / not documented)
  • If a feature is not applicable for documentation, explain why?
  • If a feature is not documented yet in this PR, please create a followup issue for adding the documentation

@RobertIndie RobertIndie requested review from Copilot and lhotari May 14, 2025 07:02
@RobertIndie RobertIndie self-assigned this May 14, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes an issue where CI was not failing despite test failures by correctly capturing the exit status of the piped go test command. Key changes include:

  • Replacing the usage of "$?" with "${PIPESTATUS[0]}" in the run-ci scripts.
  • Updating four CI scripts to ensure accurate test result reporting.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
scripts/run-ci.sh Updated to capture the correct exit status of go test
scripts/run-ci-extensible-load-manager.sh Updated to capture the correct exit status of go test
scripts/run-ci-clustered.sh Updated to capture the correct exit status of go test
scripts/run-ci-blue-green-cluster.sh Updated to capture the correct exit status of go test

@RobertIndie RobertIndie requested a review from Copilot May 14, 2025 07:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes CI scripts to correctly fail when go test encounters errors by enabling pipefail and capturing the real test command exit status.

  • Adds set -o pipefail to ensure pipeline failures propagate
  • Replaces retval=$? with retval=${PIPESTATUS[0]} to grab the exit code of go test instead of tee

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
scripts/run-ci.sh Enables pipefail to prevent silent pipeline success
scripts/run-ci-extensible-load-manager.sh Enables pipefail and captures test exit via PIPESTATUS
scripts/run-ci-clustered.sh Enables pipefail and captures test exit via PIPESTATUS
scripts/run-ci-blue-green-cluster.sh Enables pipefail and captures test exit via PIPESTATUS
Comments suppressed due to low confidence (3)

scripts/run-ci-extensible-load-manager.sh:20

  • The pipefail option and ${PIPESTATUS} array are Bash-specific. Ensure the script’s shebang (e.g., #!/usr/bin/env bash) invokes Bash rather than a POSIX shell to guarantee these features work.
set -o pipefail

scripts/run-ci-clustered.sh:20

  • The pipefail option and ${PIPESTATUS} array are Bash-specific. Ensure the script’s shebang (e.g., #!/usr/bin/env bash) invokes Bash rather than a POSIX shell to guarantee these features work.
set -o pipefail

scripts/run-ci-blue-green-cluster.sh:20

  • The pipefail option and ${PIPESTATUS} array are Bash-specific. Ensure the script’s shebang (e.g., #!/usr/bin/env bash) invokes Bash rather than a POSIX shell to guarantee these features work.
set -o pipefail

@RobertIndie RobertIndie requested a review from Copilot May 14, 2025 07:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses a CI issue where the pipeline incorrectly passes despite test failures by ensuring that the exit status of the go test command is correctly captured.

  • Added "set -o pipefail" in multiple CI scripts to capture the proper exit status from the tee command.
  • Updates include modifications to run-ci.sh, run-ci-extensible-load-manager.sh, run-ci-clustered.sh, and run-ci-blue-green-cluster.sh.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
scripts/run-ci.sh Adds "set -o pipefail" to correctly capture exit status
scripts/run-ci-extensible-load-manager.sh Adds "set -o pipefail" to correctly capture exit status
scripts/run-ci-clustered.sh Adds "set -o pipefail" to correctly capture exit status
scripts/run-ci-blue-green-cluster.sh Adds "set -o pipefail" to correctly capture exit status

@geniusjoe
Copy link
Contributor

LGTM

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@RobertIndie RobertIndie marked this pull request as ready for review May 15, 2025 06:45
@RobertIndie RobertIndie merged commit a5c6dee into apache:master May 15, 2025
7 checks passed
@RobertIndie RobertIndie deleted the fix-ci-not-failed branch May 15, 2025 06:46
RobertIndie added a commit that referenced this pull request May 15, 2025
### Motivation

This PR #1351 introduced some changes but breaked the CI. Currently, even if there are some failed tests, the CI won't be failed: https://github.com/apache/pulsar-client-go/actions/runs/14973771263/job/42060743359?pr=1364#step:6:9285

The root cause is because it captures the exit status of the tee command instead of the go test command. This causes the script to report "Tests passed" even when tests actually fail, leading to false positive CI results.

```
$TEST_CMD 2>&1 | tee $TEST_LOG
```

### Modification

- Use `set -o pipefail` to correctly capture the exit status of the `go test` command in the pipeline

(cherry picked from commit a5c6dee)
@RobertIndie RobertIndie added this to the v0.16.0 milestone Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants