diff --git a/.github/workflows/go-apidiff.yaml b/.github/workflows/go-apidiff.yaml index f79e77bb8..5461c0231 100644 --- a/.github/workflows/go-apidiff.yaml +++ b/.github/workflows/go-apidiff.yaml @@ -25,4 +25,22 @@ jobs: go-version-file: 'go.mod' id: go - name: Run go-apidiff + id: check-api + continue-on-error: true uses: joelanford/go-apidiff@main + - 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" diff --git a/.github/workflows/go-verdiff.yaml b/.github/workflows/go-verdiff.yaml index 8695f93fc..581ccc1ee 100644 --- a/.github/workflows/go-verdiff.yaml +++ b/.github/workflows/go-verdiff.yaml @@ -2,7 +2,7 @@ name: go-verdiff on: pull_request: branches: - - master + - master jobs: go-verdiff: runs-on: ubuntu-latest @@ -11,12 +11,24 @@ jobs: with: fetch-depth: 0 - name: Check golang version + id: check-version + continue-on-error: true run: | - export LABELS="$(gh api repos/$OWNER/$REPO/pulls/$PR --jq '.labels.[].name')" hack/tools/check-go-version.sh -b "${{ github.event.pull_request.base.sha }}" shell: bash + - name: Check for override label + if: ${{ steps.check-version.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-verdiff-override" diff --git a/hack/tools/check-go-version.sh b/hack/tools/check-go-version.sh index 73787ddf3..de1a66ccb 100755 --- a/hack/tools/check-go-version.sh +++ b/hack/tools/check-go-version.sh @@ -63,7 +63,6 @@ fi GO_MAJOR=${MAX_VER[0]} GO_MINOR=${MAX_VER[1]} GO_PATCH=${MAX_VER[2]} -OVERRIDE_LABEL="override-go-verdiff" RETCODE=0 @@ -135,19 +134,4 @@ for f in $(find . -name "*.mod"); do fi done -for l in ${LABELS}; do - if [ "$l" == "${OVERRIDE_LABEL}" ]; then - if [ ${RETCODE} -eq 1 ]; then - echo "" - echo "Found ${OVERRIDE_LABEL} label, overriding failed results." - RETCODE=0 - fi - fi -done - -if [ ${RETCODE} -eq 1 ]; then - echo "" - echo "This test result may be overridden by applying the (${OVERRIDE_LABEL}) label to this PR and re-running the CI job." -fi - exit ${RETCODE}