Skip to content
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

ci: experiment with codecov "merge context" #4633

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -454,6 +454,30 @@ jobs:
components: llvm-tools-preview,rust-src
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- 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=refs/heads/${{ github.event.pull_request.base.ref }}
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
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 $MERGE_BASE \
--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
- uses: codecov/codecov-action@v4
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
comment: off
comment: false

coverage:
status:
Expand Down
Loading