From c0296406ee904a2f11039c670d0a520ef23fcab6 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sat, 19 Oct 2024 21:39:51 +0100 Subject: [PATCH 1/9] ci: experiment with codecov "merge context" --- .github/workflows/ci.yml | 8 ++++---- codecov.yml | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f53f2c31292..d786a047000 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -439,10 +439,10 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - with: - # Use the PR head, not the merge commit, because the head commit (and the base) - # is what codecov uses to calculate diffs. - ref: ${{ github.event.pull_request.head.sha }} + # with: + # # Use the PR head, not the merge commit, because the head commit (and the base) + # # is what codecov uses to calculate diffs. + # ref: ${{ github.event.pull_request.head.sha }} - uses: actions/setup-python@v5 with: python-version: '3.12' diff --git a/codecov.yml b/codecov.yml index d30f0ff47dc..5b539eff49d 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,12 +1,20 @@ -comment: off +comment: false coverage: status: + merge: + project: + default: + target: auto + # Allow a tiny drop of overall project coverage in PR to reduce spurious failures. + threshold: 0.25% project: default: target: auto # Allow a tiny drop of overall project coverage in PR to reduce spurious failures. threshold: 0.25% + branches: + - main ignore: - tests/ From 0ffbd621a73133a698918c7febfe4488aea9a52b Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sat, 19 Oct 2024 22:42:14 +0100 Subject: [PATCH 2/9] try passing merge commit to codecov --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d786a047000..ab8b1d9372b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -461,6 +461,8 @@ jobs: file: coverage.json name: ${{ matrix.os }} token: ${{ secrets.CODECOV_TOKEN }} + override_commit: ${{ github.sha }} + override_pr: ${{ github.event.pull_request.number}} emscripten: name: emscripten From d6e52f63dbc81b452ed253809510685767fed6ad Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sat, 19 Oct 2024 22:51:05 +0100 Subject: [PATCH 3/9] remove invalid yaml section --- codecov.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/codecov.yml b/codecov.yml index 5b539eff49d..fb14616e5ee 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,12 +2,6 @@ comment: false coverage: status: - merge: - project: - default: - target: auto - # Allow a tiny drop of overall project coverage in PR to reduce spurious failures. - threshold: 0.25% project: default: target: auto From b7456e4aeb3bb5b314c2638db3cb2d86311aa928 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sat, 19 Oct 2024 23:17:52 +0100 Subject: [PATCH 4/9] try to inform codecov about the PR base --- .github/workflows/ci.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab8b1d9372b..81ee23b7f23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -456,13 +456,29 @@ jobs: uses: taiki-e/install-action@cargo-llvm-cov - run: python -m pip install --upgrade pip && pip install nox - run: nox -s coverage + - name: Set PR base on codecov + run: | + # fetch the merge commit between the PR base and head + git fetch --progress --depth=1 origin "+refs/heads/$BASE_REF:refs/heads/$BASE_REF" + while [ -z "$(git merge-base "$BASE_REF" "$HEAD_REF")" ]; do + git fetch -q --deepen="10" origin "$BASE_REF" "$HEAD_REF"; + done + + # inform codecov about the merge base + curl -Os https://cli.codecov.io/latest/linux/codecov + sudo chmod +x codecov + ./codecov pr-base-picking \ + --base-sha $(git merge-base "$BASE_REF" "$HEAD_REF") \ + --pr ${{ github.event.number }} + --slug PyO3/pyo3 + --token ${{ secrets.CODECOV_TOKEN }} + --service github + shell: bash - uses: codecov/codecov-action@v4 with: file: coverage.json name: ${{ matrix.os }} token: ${{ secrets.CODECOV_TOKEN }} - override_commit: ${{ github.sha }} - override_pr: ${{ github.event.pull_request.number}} emscripten: name: emscripten From 16e72849a5c86a595bc2766e48ed5e92b84efa40 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sat, 19 Oct 2024 23:26:38 +0100 Subject: [PATCH 5/9] reset codecov.yml --- codecov.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/codecov.yml b/codecov.yml index fb14616e5ee..242ba0fccc4 100644 --- a/codecov.yml +++ b/codecov.yml @@ -7,8 +7,6 @@ coverage: target: auto # Allow a tiny drop of overall project coverage in PR to reduce spurious failures. threshold: 0.25% - branches: - - main ignore: - tests/ From e1178b540824977f8f44f76fb14519c251295ad0 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sun, 20 Oct 2024 07:13:11 +0100 Subject: [PATCH 6/9] fixup --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81ee23b7f23..fa1123871b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -457,8 +457,12 @@ jobs: - run: python -m pip install --upgrade pip && pip install nox - run: nox -s coverage - name: Set PR base on codecov + if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' }} run: | # fetch the merge commit between the PR base and head + BASE_REF=${{ github.event.pull_request.base.ref }} + HEAD_REF=${{ github.sha }} + git fetch --progress --depth=1 origin "+refs/heads/$BASE_REF:refs/heads/$BASE_REF" while [ -z "$(git merge-base "$BASE_REF" "$HEAD_REF")" ]; do git fetch -q --deepen="10" origin "$BASE_REF" "$HEAD_REF"; From b486ac44e4a360a1fc0f0051749f205ebc6168d7 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sun, 20 Oct 2024 08:50:34 +0100 Subject: [PATCH 7/9] fixup merge base --- .github/workflows/ci.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa1123871b1..e20becfcf2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -454,30 +454,32 @@ jobs: components: llvm-tools-preview,rust-src - name: Install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov - - run: python -m pip install --upgrade pip && pip install nox - - run: nox -s coverage - name: Set PR base on codecov if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' }} run: | # fetch the merge commit between the PR base and head - BASE_REF=${{ github.event.pull_request.base.ref }} - HEAD_REF=${{ github.sha }} + BASE_REF=refs/heads/${{ github.event.pull_request.base.ref }} + MERGE_REF=refs/pull${{ github.event.pull_request.number }}/merge - git fetch --progress --depth=1 origin "+refs/heads/$BASE_REF:refs/heads/$BASE_REF" - while [ -z "$(git merge-base "$BASE_REF" "$HEAD_REF")" ]; do - git fetch -q --deepen="10" origin "$BASE_REF" "$HEAD_REF"; + git fetch --progress --depth=1 origin "+$BASE_REF:$BASE_REF" "+$MERGE_REF:$MERGE_REF" + while [ -z "$(git merge-base "$BASE_REF" "$MERGE_REF")" ]; do + git fetch -q --deepen="10" origin "$BASE_REF" "$MERGE_REF"; done + MERGE_BASE=$(git merge-base "$BASE_REF" "$MERGE_REF") + echo "Merge base: $MERGE_BASE" + # inform codecov about the merge base curl -Os https://cli.codecov.io/latest/linux/codecov sudo chmod +x codecov ./codecov pr-base-picking \ - --base-sha $(git merge-base "$BASE_REF" "$HEAD_REF") \ + --base-sha $MERGE_BASE \ --pr ${{ github.event.number }} --slug PyO3/pyo3 --token ${{ secrets.CODECOV_TOKEN }} --service github - shell: bash + - run: python -m pip install --upgrade pip && pip install nox + - run: nox -s coverage - uses: codecov/codecov-action@v4 with: file: coverage.json From 41f96fed0c505100fbf4271b7a3e55110cd6afe7 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sun, 20 Oct 2024 08:57:43 +0100 Subject: [PATCH 8/9] fixup --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e20becfcf2c..aa31ad2ef5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -459,7 +459,7 @@ jobs: run: | # fetch the merge commit between the PR base and head BASE_REF=refs/heads/${{ github.event.pull_request.base.ref }} - MERGE_REF=refs/pull${{ github.event.pull_request.number }}/merge + MERGE_REF=refs/pull/${{ github.event.pull_request.number }}/merge git fetch --progress --depth=1 origin "+$BASE_REF:$BASE_REF" "+$MERGE_REF:$MERGE_REF" while [ -z "$(git merge-base "$BASE_REF" "$MERGE_REF")" ]; do From d8718e04d6d91c2bcec70460bad57838fdade929 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Sun, 20 Oct 2024 09:48:56 +0100 Subject: [PATCH 9/9] add missing newline escapes --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa31ad2ef5f..6d0da698017 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -474,9 +474,9 @@ jobs: sudo chmod +x codecov ./codecov pr-base-picking \ --base-sha $MERGE_BASE \ - --pr ${{ github.event.number }} - --slug PyO3/pyo3 - --token ${{ secrets.CODECOV_TOKEN }} + --pr ${{ github.event.number }} \ + --slug PyO3/pyo3 \ + --token ${{ secrets.CODECOV_TOKEN }} \ --service github - run: python -m pip install --upgrade pip && pip install nox - run: nox -s coverage