Skip to content

BUILD-10215 Standardize GitHub Actions output logging#226

Merged
bwalsh434 merged 1 commit intomasterfrom
BUILD-10215-standardize-ghaction-output-logging
Mar 9, 2026
Merged

BUILD-10215 Standardize GitHub Actions output logging#226
bwalsh434 merged 1 commit intomasterfrom
BUILD-10215-standardize-ghaction-output-logging

Conversation

@bwalsh434
Copy link
Contributor

@bwalsh434 bwalsh434 commented Mar 3, 2026

Convert all echo >&2 error/warning messages to use GitHub Actions workflow commands (::error and ::warning) so they appear as annotations at the top of the run page instead of being invisible in log output.

Test Plan

Dummy PRs that succeed as normal (actions aren't failing even though ::error:: logs cause actions to fail)

Dummy PR that is purposely configured wrong so that an ::error:: log is thrown and thus the action fails:

@hashicorp-vault-sonar-prod
Copy link

hashicorp-vault-sonar-prod bot commented Mar 3, 2026

BUILD-10215

@bwalsh434 bwalsh434 marked this pull request as ready for review March 4, 2026 00:08
@bwalsh434 bwalsh434 requested a review from a team as a code owner March 4, 2026 00:08
Copilot AI review requested due to automatic review settings March 4, 2026 00:08
Copy link

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 standardizes shell-script error/warning logging to use GitHub Actions workflow commands (::error / ::warning) so messages appear as run annotations, and updates ShellSpec expectations accordingly.

Changes:

  • Replaced plain stderr error/warn echo messages with GitHub Actions annotation commands across build/config/promote scripts.
  • Added annotation metadata (e.g., title=..., and file=... where relevant) to improve visibility and context.
  • Updated ShellSpec tests to assert the new annotation-formatted output.

Reviewed changes

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

Show a summary per file
File Description
spec/shared-functions_spec.sh Updates expected stderr for set_sonar_platform_vars / check_tool annotation output.
spec/set_maven_project_version_spec.sh Updates expected Maven expression evaluation error format.
spec/set_gradle_project_version_spec.sh Updates expected Gradle “not found” error format.
spec/promote_spec.sh Updates expected promotion/build-info error strings to ::error ...::.
spec/get_build_number_spec.sh Updates expected invalid build-number error string.
spec/config-npm_spec.sh Updates expected npm version warnings/errors to ::warning / ::error.
spec/build-yarn_spec.sh Updates expected yarn build env/version errors to ::error ...::.
spec/build-poetry_spec.sh Updates expected poetry platform/version warning/error strings.
spec/build-maven_spec.sh Updates expected shadow-scan deployment-disabled warnings to ::warning ...::.
spec/build-maven_deploy-artifacts_spec.sh Updates expected unrecognized artifact warning to ::warning ...::.
spec/build-gradle_spec.sh Updates expected deployment-disabled warnings and gradle-not-found errors; updates mocked check_tool output.
shared/common-functions.sh Converts common error messages to ::error ...:: in shared helpers.
promote/promote.sh Converts promotion gating and build-info retrieval errors to ::error ...::.
get-build-number/get_build_number.sh Converts invalid build-number message to ::error ...::.
config-npm/npm_set_project_version.sh Converts npm version format warning and package.json version error to workflow commands.
config-maven/set_maven_project_version.sh Converts Maven expression evaluation failure to ::error title=...::.
config-gradle/set_gradle_project_version.sh Converts gradle/gradlew-not-found message to ::error title=...::.
build-yarn/build.sh Converts missing files / invalid or unsupported version messages to ::error ...::.
build-poetry/build.sh Converts invalid platform and poetry version retrieval failure to ::error ...::, and truncation notice to ::warning ...::.
build-maven/deploy-artifacts.sh Converts unrecognized artifact path warning to ::warning ...::.
build-maven/build.sh Converts shadow-scan deployment-disabled message to ::warning ...::.
build-gradle/build.sh Converts shadow-scan deployment-disabled message to ::warning ...:: and gradle-not-found to ::error ...::.
Comments suppressed due to low confidence (1)

shared/common-functions.sh:92

  • check_tool uses command -v "$1" directly, which prints the resolved path to stdout on success. This adds extra, unintended log lines before the actual tool output (e.g., check_tool mvn --version will print the mvn path). Redirect command -v output to /dev/null (and ideally stderr too) so the function only emits the tool’s output or the ::error message on failure.
check_tool() {
  # Check if a command is available and runs it, typically: 'some_tool --version'
  if ! command -v "$1"; then
    echo "::error title=Missing tool::$1 is not installed." >&2
    return 1
  fi
  "$@"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know that it now works with redirect to stderr. This was previously an issue in GitHub log parsing.

Then, did/can you check that all "::error" messages are redirected to >&2?
Should we also redirect all the "::warning" message to stderr? It's not consistent at the moment.

@julien-carsique-sonarsource
Copy link
Contributor

Note: We need a separate PR that addresses the fact that these errors are hidden inside groups. Preferably a log that tells us where the errors are.

The errors reported as annotations are clickable with a redirect to error message line, in the opened group.

@bwalsh434 bwalsh434 force-pushed the BUILD-10215-standardize-ghaction-output-logging branch 5 times, most recently from 9702de0 to 22b12d3 Compare March 4, 2026 23:11
Convert all echo >&2 error/warning messages to use GitHub Actions
workflow commands (::error and ::warning) so they appear as annotations
at the top of the run page instead of being invisible in log output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bwalsh434 bwalsh434 force-pushed the BUILD-10215-standardize-ghaction-output-logging branch from 4d5110a to ac1b1ad Compare March 4, 2026 23:20
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

SonarQube reviewer guide

Review in SonarQube

Summary: Standardize error and warning messaging across build scripts by converting plain text messages to GitHub Actions workflow commands format.

Review Focus: This PR converts all error/warning messages to GitHub Actions format (::error::, ::warning::). Key considerations:

  • Ensure all error messages route to stderr (adding >&2 where missing)
  • Verify test assertions match new message formats
  • Check for consistency in title attributes across similar error types
  • Confirm printf usage in one location handles multi-line output correctly

Start review at: build-gradle/build.sh, build-maven/build.sh, build-npm/build.sh, build-poetry/build.sh, build-yarn/build.sh. These files contain the core build logic where error/warning standardization is most critical—they directly impact user experience during CI/CD operations and need careful verification that all stderr redirections are properly placed.

💬 Please send your feedback

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues
0 Dependency risks

Measures
0 Security Hotspots
100.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@bwalsh434 bwalsh434 merged commit d6f6b07 into master Mar 9, 2026
11 checks passed
@bwalsh434 bwalsh434 deleted the BUILD-10215-standardize-ghaction-output-logging branch March 9, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants