BUILD-10215 Standardize GitHub Actions output logging#226
Conversation
There was a problem hiding this comment.
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
echomessages with GitHub Actions annotation commands across build/config/promote scripts. - Added annotation metadata (e.g.,
title=..., andfile=...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_toolusescommand -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 --versionwill print the mvn path). Redirectcommand -voutput to/dev/null(and ideally stderr too) so the function only emits the tool’s output or the::errormessage 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.
julien-carsique-sonarsource
left a comment
There was a problem hiding this comment.
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.
The errors reported as annotations are clickable with a redirect to error message line, in the opened group. |
9702de0 to
22b12d3
Compare
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>
4d5110a to
ac1b1ad
Compare
SonarQube reviewer guideSummary: 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 (
Start review at:
|




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: