Skip to content

Commit

Permalink
workflow/semver-auto: rebase PR
Browse files Browse the repository at this point in the history
When testing if a PR is API backward compatible or not, we need to test
against the base branch, not the head against the PR branched is based
on.

Otherwise it can lead to the case where a breaking change was merged
after that a PR was proposed, go-apidiff will fail because it'll test
the repo against base_ref.

The PR needs to be rebased on base_ref so the actual compatibility can be
verified.

If the PR can't be rebase for any reason, we'll return a failure and add
the label `semver:unknown`.
  • Loading branch information
EmilienM committed Aug 31, 2023
1 parent a6cf357 commit 6d5929c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/labels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
- color: '6E7624'
description: No API change
name: semver:patch
- color: 'EC0101'
description: Unable to figure out the semver type
name: semver:unknown
12 changes: 12 additions & 0 deletions .github/workflows/semver-auto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}

- uses: peter-evans/rebase@v2
with:
base: ${{ github.base_ref }}

- name: Add semver:unknown label
if: failure()
uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: semver:unknown

- uses: actions/setup-go@v4
with:
go-version: '1'
Expand All @@ -23,6 +34,7 @@ jobs:
semver:patch
semver:minor
semver:major
semver:unknown
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Checking Go API Compatibility
Expand Down

0 comments on commit 6d5929c

Please sign in to comment.