From 54109b1bbb99df8c7a476bb1dfcda8676ef7a6fe Mon Sep 17 00:00:00 2001 From: grokspawn Date: Tue, 6 Jan 2026 16:00:17 -0600 Subject: [PATCH] standardizing approach for required-tests-with-occasional-overrides Signed-off-by: grokspawn --- .github/workflows/crd-diff.yaml | 20 ++++++++++++++++++-- .github/workflows/go-verdiff.yaml | 14 +++++++++++++- hack/tools/check-go-version.sh | 16 ---------------- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/.github/workflows/crd-diff.yaml b/.github/workflows/crd-diff.yaml index be973786ef..7be4d0b1ee 100644 --- a/.github/workflows/crd-diff.yaml +++ b/.github/workflows/crd-diff.yaml @@ -8,13 +8,29 @@ jobs: - uses: actions/checkout@v6 with: fetch-depth: 0 - - uses: actions/setup-go@v6 with: go-version-file: go.mod - - name: Run make verify-crd-compatibility + id: verify-crd-compatibility + continue-on-error: true run: | make verify-crd-compatibility \ CRD_DIFF_ORIGINAL_REF="git://${{ github.event.pull_request.base.sha }}?path=" \ CRD_DIFF_UPDATED_REF="git://${{ github.event.pull_request.head.sha }}?path=" + - name: Check for override label + if: ${{ steps.verify-crd-compatibility.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: "crd-diff-override" \ No newline at end of file diff --git a/.github/workflows/go-verdiff.yaml b/.github/workflows/go-verdiff.yaml index f8fb06b6c3..62f89bf9f3 100644 --- a/.github/workflows/go-verdiff.yaml +++ b/.github/workflows/go-verdiff.yaml @@ -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" \ No newline at end of file diff --git a/hack/tools/check-go-version.sh b/hack/tools/check-go-version.sh index 59eb8b9711..fb9bc8fecc 100755 --- a/hack/tools/check-go-version.sh +++ b/hack/tools/check-go-version.sh @@ -46,7 +46,6 @@ fi GO_MAJOR=${MAX_VER[0]} GO_MINOR=${MAX_VER[1]} GO_PATCH=${MAX_VER[2]} -OVERRIDE_LABEL="override-go-verdiff" RETCODE=0 @@ -118,19 +117,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}