Skip to content
Merged
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
23 changes: 20 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
permissions:
contents: read
id-token: write # for GitHub id-token auth
actions: read # to query workflow runs for coverage baseline

jobs:
go-test:
Expand Down Expand Up @@ -53,15 +54,31 @@ jobs:
path: src/coverage.txt
overwrite: true

- name: Download main branch coverage
- name: Find merge-base run ID
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/v')
id: merge-base-run
continue-on-error: true # no baseline yet on first run
run: |
git fetch origin main --depth=50
MERGE_BASE=$(git merge-base HEAD origin/main)
echo "Merge base: $MERGE_BASE"
RUN_ID=$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/go.yml/runs" \
-X GET -f branch=main -f per_page=100 \
--jq ".workflow_runs[] | select(.head_sha == \"$MERGE_BASE\" and .conclusion == \"success\") | .id" \
| head -1)
echo "run_id=${RUN_ID}" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Download merge-base coverage
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/v') && steps.merge-base-run.outputs.run_id != ''
uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20
with:
workflow: go.yml
branch: main
run_id: ${{ steps.merge-base-run.outputs.run_id }}
name: coverage-main
path: coverage-main
continue-on-error: true # no baseline yet on first run
continue-on-error: true # artifact may have expired

- name: Verify Go modules
working-directory: src
Expand Down
Loading