Repository navigation
🌱 OPRUN-4784: Move demo E2E steps and recording into platform #9598
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: go-apidiff | |
| on: | |
| merge_group: | |
| pull_request: | |
| types: [opened, synchronize, reopened, labeled, unlabeled] | |
| jobs: | |
| go-apidiff: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-go@v7.0.0 | |
| with: | |
| go-version-file: go.mod | |
| - name: Determine comparison base | |
| id: base | |
| env: | |
| PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| MG_BASE_SHA: ${{ github.event.merge_group.base_sha }} | |
| run: | | |
| set -euo pipefail | |
| if [[ -n "${PR_BASE_SHA}" ]]; then | |
| # Compare the PR head against its merge base so the check only | |
| # covers changes introduced by the PR itself. Comparing against the | |
| # base branch tip instead attributes API changes from PRs that merged | |
| # after this PR was created to this PR (e.g. when a label change | |
| # re-triggers the workflow after the base branch has advanced). | |
| # go-apidiff compares base-ref against the working tree, and | |
| # actions/checkout checks out the synthetic merge commit for | |
| # pull_request events. That merge commit contains base branch changes | |
| # made after the merge base, so they would still leak into the head | |
| # side of the comparison. Fetch the PR head explicitly (the merge | |
| # checkout may not include it) and check it out so both comparison | |
| # endpoints are immutable git objects. | |
| git fetch --no-tags origin "refs/pull/${PR_NUMBER}/head" | |
| git checkout --quiet "${PR_HEAD_SHA}" | |
| BASE_REF="$(git merge-base "${PR_BASE_SHA}" "${PR_HEAD_SHA}")" | |
| else | |
| # merge_group events compare against the base of the merge group. | |
| BASE_REF="${MG_BASE_SHA}" | |
| fi | |
| if [[ -z "${BASE_REF}" ]]; then | |
| echo "Unable to determine comparison base" >&2 | |
| exit 1 | |
| fi | |
| echo "Using comparison base: ${BASE_REF}" | |
| echo "ref=${BASE_REF}" >> "${GITHUB_OUTPUT}" | |
| - uses: joelanford/go-apidiff@main | |
| id: check-api | |
| with: | |
| base-ref: ${{ steps.base.outputs.ref }} | |
| continue-on-error: true | |
| - name: Check for override label | |
| if: ${{ steps.check-api.outcome == 'failure' }} | |
| run: | | |
| if gh api repos/$OWNER/$REPO/pulls/$PR --jq '.labels.[].name' | grep -q "${OVERRIDE_LABEL}"; then | |
| echo "Found ${OVERRIDE_LABEL} label, overriding failed results." | |
| exit 0 | |
| else | |
| echo "No ${OVERRIDE_LABEL} label found, failing the job." | |
| exit 1 | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| OWNER: ${{ github.repository_owner }} | |
| REPO: ${{ github.event.repository.name }} | |
| PR: ${{ github.event.pull_request.number }} | |
| OVERRIDE_LABEL: "go-apidiff-override" |