-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
chore: coverage scripts collection simplifications #5724
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
Open
denis256
wants to merge
15
commits into
main
Choose a base branch
from
OSS-2282-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c0b14c8
chore: coverage scripts collection simplifications
denis256 aaf83f7
chore: simplified code coverage scripts
denis256 b08acc7
chore: extracted common scripts in github action
denis256 779f05b
chore: download cleanup
denis256 67dfccd
chore: set threshold to report coverage
denis256 88072d2
chore: pr comments
denis256 cfe3d89
Merge remote-tracking branch 'origin/main' into OSS-2282-improvements
denis256 62f9a90
Merge branch 'main' into OSS-2282-improvements
denis256 744179f
docs: Adding a changelog (#5754)
yhakbar c0f02e6
docs: Adding changelog copy button (#5755)
yhakbar 7f32e0b
docs: Adding more `v1.0.0` changelog docs (#5756)
yhakbar fcbbf22
chore: Adding tests to confirm #4395 is resolved (#5761)
yhakbar 35f2000
fix: Fixing #5624 (#5766)
yhakbar cd78cd0
docs: Adding `v1.0.0` call out (#5768)
yhakbar 4ee9cb6
Merge remote-tracking branch 'origin/main' into OSS-2282-improvements
denis256 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| REPO="${REPO:?Required environment variable REPO}" | ||
| BRANCH="${BRANCH:?Required environment variable BRANCH}" | ||
| CURRENT_RUN_ID="${CURRENT_RUN_ID:?Required environment variable CURRENT_RUN_ID}" | ||
| OUTPUT_DIR="${1:-previous}" | ||
|
|
||
| mkdir -p "$OUTPUT_DIR" | ||
|
|
||
| # Find last successful CI run on this branch (excluding current) | ||
| PREV_RUN_ID=$(gh api "repos/${REPO}/actions/workflows/ci.yml/runs?branch=${BRANCH}&status=success&per_page=5" \ | ||
| --jq "[.workflow_runs[] | select(.id != ${CURRENT_RUN_ID})][0].id") | ||
|
|
||
| if [[ -z "$PREV_RUN_ID" || "$PREV_RUN_ID" == "null" ]]; then | ||
| echo "No previous successful run found on $BRANCH" | ||
| echo "has_previous=false" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Previous run: $PREV_RUN_ID" | ||
|
|
||
| # Find the coverage-summary.json artifact in that run | ||
| ARTIFACT_ID=$(gh api "repos/${REPO}/actions/runs/${PREV_RUN_ID}/artifacts" \ | ||
| --jq '.artifacts[] | select(.name == "coverage-summary.json") | .id') | ||
|
|
||
| if [[ -z "$ARTIFACT_ID" || "$ARTIFACT_ID" == "null" ]]; then | ||
| echo "No coverage artifact in previous run" | ||
| echo "has_previous=false" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Download and extract | ||
| gh api "repos/${REPO}/actions/artifacts/${ARTIFACT_ID}/zip" >/tmp/prev-coverage.zip | ||
| unzip -o /tmp/prev-coverage.zip -d "$OUTPUT_DIR/" | ||
| echo "has_previous=true" |
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,53 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| REPORT="${1:-comparison-report.json}" | ||
| BASE_REF="${BASE_REF:-base}" | ||
| HEAD_REF="${HEAD_REF:-head}" | ||
| SUMMARY_FILE="${GITHUB_STEP_SUMMARY:-/dev/stdout}" | ||
|
|
||
| if [[ ! -f "$REPORT" ]]; then | ||
| echo "No comparison report found, skipping summary." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Sanitize user inputs for markdown injection | ||
| BASE_REF=$(echo "$BASE_REF" | tr -d '<>|`\n\r') | ||
| HEAD_REF=$(echo "$HEAD_REF" | tr -d '<>|`\n\r') | ||
|
|
||
| CURR=$(jq -r '.current_total' "$REPORT") | ||
| PREV=$(jq -r '.previous_total' "$REPORT") | ||
| DELTA=$(jq -r '.total_delta' "$REPORT") | ||
|
|
||
| { | ||
| echo "## Coverage Comparison: ${BASE_REF} vs ${HEAD_REF}" | ||
| echo "" | ||
| echo "| Ref | Coverage |" | ||
| echo "|-----|----------|" | ||
| echo "| ${BASE_REF} (base) | ${PREV}% |" | ||
| echo "| ${HEAD_REF} (head) | ${CURR}% |" | ||
| echo "| Delta | ${DELTA}% |" | ||
| echo "" | ||
| } >>"$SUMMARY_FILE" | ||
|
|
||
| DROPS=$(jq -r '.top_drops[:10][] | "| \(.package) | \(.previous)% | \(.current)% | \(.delta)% |"' "$REPORT" 2>/dev/null || true) | ||
| if [[ -n "$DROPS" ]]; then | ||
| { | ||
| echo "### Top Drops" | ||
| echo "| Package | Base | Head | Delta |" | ||
| echo "|---------|------|------|-------|" | ||
| echo "$DROPS" | ||
| } >>"$SUMMARY_FILE" | ||
| fi | ||
|
|
||
| GAINS=$(jq -r '.top_gains[:5][] | "| \(.package) | \(.previous)% | \(.current)% | +\(.delta)% |"' "$REPORT" 2>/dev/null || true) | ||
| if [[ -n "$GAINS" ]]; then | ||
| { | ||
| echo "" | ||
| echo "### Top Gains" | ||
| echo "| Package | Base | Head | Delta |" | ||
| echo "|---------|------|------|-------|" | ||
| echo "$GAINS" | ||
| } >>"$SUMMARY_FILE" | ||
| fi | ||
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,58 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| REPORT="${1:-comparison-report.json}" | ||
| SUMMARY_FILE="${GITHUB_STEP_SUMMARY:-/dev/stdout}" | ||
|
|
||
| if [[ ! -f "$REPORT" ]]; then | ||
| echo "No comparison report found, skipping summary." | ||
| exit 0 | ||
| fi | ||
|
|
||
| BASELINE=$(jq -r '.baseline' "$REPORT") | ||
|
|
||
| if [[ "$BASELINE" == "true" ]]; then | ||
| { | ||
| echo "## Coverage Baseline Established" | ||
| echo "" | ||
| echo "Total: $(jq -r '.current_total' "$REPORT")%" | ||
| } >>"$SUMMARY_FILE" | ||
| exit 0 | ||
| fi | ||
|
|
||
| CURR=$(jq -r '.current_total' "$REPORT") | ||
| PREV=$(jq -r '.previous_total' "$REPORT") | ||
| DELTA=$(jq -r '.total_delta' "$REPORT") | ||
|
|
||
| { | ||
| echo "## :bar_chart: Coverage Diff" | ||
| echo "" | ||
| echo "| Metric | Value |" | ||
| echo "|--------|-------|" | ||
| echo "| Current | ${CURR}% |" | ||
| echo "| Previous | ${PREV}% |" | ||
| echo "| Delta | ${DELTA}% |" | ||
| echo "" | ||
| } >>"$SUMMARY_FILE" | ||
|
|
||
| DROPS=$(jq -r '.top_drops[:5][] | "| \(.package) | \(.previous)% | \(.current)% | \(.delta)% |"' "$REPORT" 2>/dev/null || true) | ||
| if [[ -n "$DROPS" ]]; then | ||
| { | ||
| echo "### Top Drops" | ||
| echo "| Package | Previous | Current | Delta |" | ||
| echo "|---------|----------|---------|-------|" | ||
| echo "$DROPS" | ||
| } >>"$SUMMARY_FILE" | ||
| fi | ||
|
|
||
| GAINS=$(jq -r '.top_gains[:5][] | "| \(.package) | \(.previous)% | \(.current)% | +\(.delta)% |"' "$REPORT" 2>/dev/null || true) | ||
| if [[ -n "$GAINS" ]]; then | ||
| { | ||
| echo "" | ||
| echo "### Top Gains" | ||
| echo "| Package | Previous | Current | Delta |" | ||
| echo "|---------|----------|---------|-------|" | ||
| echo "$GAINS" | ||
| } >>"$SUMMARY_FILE" | ||
| fi |
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
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.
NIT: Useless echo