-
Notifications
You must be signed in to change notification settings - Fork 15
Robertomonteromiguel/gitlab collapsible sections #7095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
robertomonteromiguel
merged 6 commits into
main
from
robertomonteromiguel/gitlab_collapsible_sections
Jun 9, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
33c69a5
SSI Refactor: extract GitLab CI log-rendering into a reusable script
robertomonteromiguel 55ceffd
SSI Refactor: extract GitLab CI log-rendering into a reusable script
robertomonteromiguel 5f06c7d
fix k8s
robertomonteromiguel e23a3ea
rebase
robertomonteromiguel e92a3bb
SSI: make logs debug doc URL parametrizable and capture docker-ssi ru…
robertomonteromiguel 43c1c19
k8s build section
robertomonteromiguel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Render a job's logs at the END of a GitLab CI after_script: | ||
| # 1. Dump every file under reports/ as its own collapsible section. | ||
| # 2. Re-print the captured run.sh summary (when available). | ||
| # 3. Print a final banner explaining how to navigate the logs. | ||
| # | ||
| # Shared by the SSI / onboarding / k8s jobs so the logic lives in one place. | ||
| # | ||
| # Optional environment variables: | ||
| # SCENARIO_SUFIX Label shown in the section headers (defaults to "logs"). | ||
| # CI_PROJECT_DIR GitLab built-in; used to locate run_output.log. | ||
| # AWS_CONSOLE_URL S3 console URL printed in the banner when set. | ||
| # DEBUG_LOGS_DOC_URL Documentation URL printed in the banner explaining how to | ||
| # interpret the logs (defaults to the AWS onboarding debug | ||
| # section). Set it per scenario type (k8s, docker-ssi, ...). | ||
|
|
||
| set -uo pipefail | ||
|
|
||
| # The collapsible-section helper lives next to this script. | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| COLLAPSIBLE_LOGS_SCRIPT="${SCRIPT_DIR}/gitlab_collapsible_logs.sh" | ||
|
|
||
| LABEL="${SCENARIO_SUFIX:-logs}" | ||
| DOC_URL="${DEBUG_LOGS_DOC_URL:-https://github.com/DataDog/system-tests/blob/main/docs/understand/scenarios/onboarding.md#how-to-debug-your-environment-and-tests-results}" | ||
|
|
||
| # 1. Dump every log file as a collapsible section (full content). | ||
| if [ -f "${COLLAPSIBLE_LOGS_SCRIPT}" ]; then | ||
| while IFS= read -r -d '' file; do | ||
| section_id=$(printf '%s' "$file" | tr -c '[:alnum:]' '_') | ||
| bash "${COLLAPSIBLE_LOGS_SCRIPT}" "$file" "logs_${LABEL}_${section_id}" "Logs for ${LABEL} - ${file}" | ||
| done < <(find reports -type f \! -name report.json \! -name tests.log -print0) | ||
| else | ||
| echo "Skipping collapsible log dump: ${COLLAPSIBLE_LOGS_SCRIPT} not found" | ||
| fi | ||
|
|
||
| # 2. Re-print the captured run.sh summary at the END. | ||
| if [ -n "${CI_PROJECT_DIR:-}" ] && [ -f "${CI_PROJECT_DIR}/run_output.log" ]; then | ||
| printf '\n%s\n Test run summary (captured from script: step)\n%s\n\n' \ | ||
| "================================================================================" \ | ||
| "================================================================================" | ||
| tail -c 200000 "${CI_PROJECT_DIR}/run_output.log" | ||
| fi | ||
|
|
||
| # 3. Final info banner with everything the user needs to navigate the log. | ||
| printf '\n%s\n Logs for %s\n%s\n' \ | ||
| "================================================================================" \ | ||
| "${LABEL}" \ | ||
| "--------------------------------------------------------------------------------" | ||
| printf ' - Each log file above is wrapped in its own collapsible section.\n' | ||
| printf ' Click the triangle on the section header to expand/collapse it.\n' | ||
| printf ' - If some sections appear uncollapsed in this view, click\n' | ||
| printf ' "View full log" To view all collapsed sections (all logs)\n' | ||
| printf ' - You can always download the logs attached to the job\n' | ||
| if [ -n "${AWS_CONSOLE_URL:-}" ]; then | ||
| printf ' - Full raw logs (including files >50MB stripped from the artifact)\n' | ||
| printf ' are uploaded to S3:\n %s\n' "${AWS_CONSOLE_URL}" | ||
| fi | ||
| printf ' - How to interpret these logs:\n %s\n' \ | ||
| "${DOC_URL}" | ||
| printf '%s\n\n' \ | ||
| "================================================================================" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the K8s base job after_script, this replacement jumps straight from feature-parity handling to
gitlab_print_logs.sh; the previousdatadog-ci junit upload reports/logs*/reportJunit.xml ...block was removed here. For everyK8S_LIB_INJECTIONjob that producesreportJunit.xml, Datadog Test Optimization will stop receiving K8s results while the Docker SSI job still uploads them, so CI dashboards/ownership tags lose coverage for these workflows. Please keep the JUnit upload block before rendering the collapsible logs.Useful? React with 👍 / 👎.