From f84ac2b98d2a67950f53bc08b730d387a9c25a21 Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Wed, 15 Nov 2023 12:40:21 +0100 Subject: [PATCH] Fix baseline commit and branch for code coverage (#5769) ## Problem `HEAD` commit for a PR is a phantom merge commit which skews the baseline commit for coverage reports. See https://github.com/neondatabase/neon/pull/5751#issuecomment-1790717867 ## Summary of changes - Use commit hash instead of `HEAD` for finding baseline commits for code coverage - Use the base branch for PRs or the current branch for pushes --- .github/workflows/build_and_test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index ff7d8c1a62..ed7c0d3dfa 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -586,10 +586,13 @@ jobs: id: upload-coverage-report-new env: BUCKET: neon-github-public-dev + # A differential coverage report is available only for PRs. + # (i.e. for pushes into main/release branches we have a regular coverage report) COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + BASE_SHA: ${{ github.event.pull_request.base.sha || github.sha }} run: | - BASELINE="$(git merge-base HEAD origin/main)" CURRENT="${COMMIT_SHA}" + BASELINE="$(git merge-base $BASE_SHA $CURRENT)" cp /tmp/coverage/report/lcov.info ./${CURRENT}.info