| 1 |
# This GitHub action is used to compare API state snapshots of Main |
| 2 |
# to Head of the PR in order to validate releases are not breaking |
| 3 |
# backwards compatibility. |
| 4 |
# |
| 5 |
# This GitHub action will fail if there are incompatible changes. |
| 6 |
# |
| 7 |
name: "Inform Incompatible PRs" |
| 8 |
on: |
| 9 |
pull_request: |
| 10 |
branches: |
| 11 |
- main |
| 12 |
|
| 13 |
permissions: read-all |
| 14 |
|
| 15 |
jobs: |
| 16 |
Check-Compatibility: |
| 17 |
runs-on: ubuntu-latest |
| 18 |
env: |
| 19 |
BASE_REF: ${{ github.base_ref }} |
| 20 |
HEAD_REF: ${{ github.head_ref }} |
| 21 |
steps: |
| 22 |
- name: Checkout-Main |
| 23 |
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 24 |
with: |
| 25 |
ref: ${{ github.base_ref }} |
| 26 |
path: ${{ github.base_ref }} |
| 27 |
|
| 28 |
- name: Checkout-HEAD |
| 29 |
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 30 |
with: |
| 31 |
path: ${{ github.head_ref }} |
| 32 |
|
| 33 |
- name: Setup Go |
| 34 |
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 |
| 35 |
with: |
| 36 |
go-version: oldstable |
| 37 |
cache: false |
| 38 |
|
| 39 |
- name: Cache Go |
| 40 |
id: go-cache |
| 41 |
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 42 |
with: |
| 43 |
path: | |
| 44 |
~/go/bin |
| 45 |
~/go/pkg/mod |
| 46 |
key: go-cache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/go.sum') }} |
| 47 |
|
| 48 |
# Generate apidiff states of Main |
| 49 |
- name: Generate-States |
| 50 |
run: | |
| 51 |
cd $BASE_REF |
| 52 |
make apidiff-build |
| 53 |
|
| 54 |
# Compare apidiff states of Main with PR |
| 55 |
- name: Compare-States |
| 56 |
env: |
| 57 |
CI: true |
| 58 |
COMPARE_OPTS: -d "../${{ github.base_ref }}/internal/data/apidiff" |
| 59 |
run: | |
| 60 |
cd $HEAD_REF |
| 61 |
make apidiff-compare |
| 62 |
|
| 63 |
# Fail GitHub Action if there are incompatible changes |
| 64 |
- name: Check-States |
| 65 |
env: |
| 66 |
CI: true |
| 67 |
COMPARE_OPTS: -d "../${{ github.base_ref }}/internal/data/apidiff" -c |
| 68 |
run: | |
| 69 |
cd $HEAD_REF |
| 70 |
make apidiff-compare |