Skip to content

Commit 05b1c95

Browse files
committed
build: customize package URLs in coverage tables inside PR comments
1 parent ada1567 commit 05b1c95

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

.github/workflows/run_tests_coverage.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ jobs:
178178
else
179179
directories="${{ steps.changed-directories.outputs.directories }}"
180180
fi
181+
182+
# Append suffix to coverage base URL for PRs:
183+
if [ -n "${{ github.event.pull_request.number }}" ]; then
184+
PR_NUMBER=${{ github.event.pull_request.number }}
185+
export COVERAGE_BASE_URL="https://coverage.stdlib.io/pr-${PR_NUMBER}"
186+
else
187+
export COVERAGE_BASE_URL="https://coverage.stdlib.io"
188+
fi
189+
181190
. "$GITHUB_WORKSPACE/.github/workflows/scripts/run_tests_coverage" "$directories"
182191
timeout-minutes: 30
183192

.github/workflows/scripts/run_tests_coverage

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ set -o pipefail
4242

4343
# VARIABLES #
4444

45+
# Define the base URL for coverage reports, defaulting to 'https://coverage.stdlib.io':
46+
coverage_base_url="${COVERAGE_BASE_URL:-https://coverage.stdlib.io}"
47+
4548
# Get the list of changed files:
4649
changed="$*"
4750

@@ -159,11 +162,11 @@ main() {
159162
for package in ${directories}; do
160163
# For each package, extract coverage values from the respective coverage report:
161164
pkg=`echo $package | sed -E 's/^.*stdlib\///'`
162-
165+
163166
if [ -f "lib/node_modules/@stdlib/${pkg}/binding.gyp" ]; then
164167
NODE_ADDONS_PATTERN="${pkg}" make install-node-addons
165168
fi
166-
169+
167170
make test-javascript-cov TESTS_FILTER=".*/${pkg}/test/.*"
168171

169172
if [ ! -f reports/coverage/lcov-report/${pkg}/lib/index.html ]; then
@@ -187,7 +190,7 @@ main() {
187190
pkg_functions_cov_fraction=${pkg_cov_fractions[2]}
188191
pkg_lines_cov_fraction=${pkg_cov_fractions[3]}
189192

190-
old_cov_report=$(curl -s --fail "https://coverage.stdlib.io/${pkg}/lib/index.html" 2>/dev/null || true)
193+
old_cov_report=$(curl -s --fail "${coverage_base_url}/${pkg}/lib/index.html" 2>/dev/null || true)
191194
if [ -z "$old_cov_report" ]; then
192195
old_statements_cov=0
193196
old_branches_cov=0
@@ -208,7 +211,7 @@ main() {
208211

209212
pkg_cov="| $pkg_statements_cov_fraction <br> $cov_change_statements | $pkg_branches_cov_fraction <br> $cov_change_branches | $pkg_functions_cov_fraction <br> $cov_change_functions | $pkg_lines_cov_fraction <br> $cov_change_lines |"
210213

211-
pkg_url="https://coverage.stdlib.io/${pkg}/index.html"
214+
pkg_url="${coverage_base_url}/${pkg}/index.html"
212215
pkg_link="<a href="$pkg_url">$pkg</a>"
213216
coverage="$coverage\n| $pkg_link $pkg_cov"
214217

0 commit comments

Comments
 (0)