Skip to content

Commit fde86c4

Browse files
gustavoliraclaude
andauthored
feat: only upload E2E coverage for plugins owned by redhat-developer/rhdh-plugins (redhat-developer#2578)
feat: only upload E2E coverage for plugins we own the Codecov project for Codecov anchors every report to a repo + commit + file tree, so coverage is only accurate when uploaded to the repo where those source files and commits actually live. The upload target is derived per workspace from source.json, which spans ~10 repos across 9 GitHub orgs (36 -> backstage/community-plugins, 18 -> redhat-developer/rhdh-plugins, plus RoadieHQ, PagerDuty, etc.). We can only get a Codecov upload token for repos we own, and uploading a plugin's coverage to a repo where its commit/files don't exist produces orphaned, inaccurate metrics. Gate the upload on the source slug: only proceed when it matches the owned project (CODECOV_UPLOAD_SLUG, default redhat-developer/rhdh-plugins); otherwise log and skip. Plugins sourced from backstage/community-plugins and other orgs are skipped for now. The lcov is still generated locally either way. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 59d7fdc commit fde86c4

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

scripts/upload-coverage.sh

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
# E2E_COLLECT_COVERAGE=true ./run-e2e.sh -w tech-radar
1010
# ./scripts/upload-coverage.sh tech-radar
1111
#
12-
# The script reads source.json to determine the upstream repo and SHA,
13-
# then uploads the lcov coverage to Codecov attributed to that repo.
12+
# The script reads source.json to determine the upstream repo and SHA, and only
13+
# uploads when that repo is the Codecov project we own (CODECOV_UPLOAD_SLUG,
14+
# default redhat-developer/rhdh-plugins). Plugins sourced from other orgs are
15+
# skipped — see the gate below for why.
1416
#
1517
# Required environment:
16-
# CODECOV_TOKEN - Codecov upload token (org-level for cross-repo uploads).
17-
# Falls back to VAULT_CODECOV_TOKEN (see below).
18+
# CODECOV_TOKEN - Codecov upload token for the owned project.
19+
# Falls back to VAULT_CODECOV_TOKEN (see below).
20+
# Optional environment:
21+
# CODECOV_UPLOAD_SLUG - GitHub slug of the owned Codecov project to upload to.
22+
# Default: redhat-developer/rhdh-plugins.
1823

1924
set -euo pipefail
2025

@@ -87,6 +92,20 @@ fi
8792
# Extract GitHub slug from repo URL (e.g., "redhat-developer/rhdh-plugins")
8893
SLUG=$(echo "$REPO_URL" | sed 's|https://github.com/||; s|\.git$||')
8994

95+
# Only upload coverage for plugins whose source repo we can attribute it to.
96+
# Codecov anchors every report to a repo + commit + file tree, so the metric is
97+
# only accurate when uploaded to the repo where those source files and commits
98+
# actually live. We own the Codecov project for redhat-developer/rhdh-plugins;
99+
# plugins sourced from other orgs (e.g. backstage/community-plugins) can't be
100+
# reported accurately without that org's token, so skip them for now. Override
101+
# the owned slug with CODECOV_UPLOAD_SLUG if the target project ever changes.
102+
UPLOAD_SLUG="${CODECOV_UPLOAD_SLUG:-redhat-developer/rhdh-plugins}"
103+
if [[ "$SLUG" != "$UPLOAD_SLUG" ]]; then
104+
echo "[INFO] Skipping Codecov upload for '$WORKSPACE': source repo '$SLUG' is not the owned project '$UPLOAD_SLUG'."
105+
echo "[INFO] Cross-org coverage attribution isn't supported; lcov is available locally at $LCOV_FILE."
106+
exit 0
107+
fi
108+
90109
echo "=== Uploading E2E coverage to Codecov ==="
91110
echo " Workspace: $WORKSPACE"
92111
echo " LCOV file: $LCOV_FILE"

0 commit comments

Comments
 (0)