Skip to content

Commit b7c3f27

Browse files
authored
sync test override pattern with op-con (#1874)
Signed-off-by: grokspawn <jordan@nimblewidget.com>
1 parent 30827e3 commit b7c3f27

3 files changed

Lines changed: 32 additions & 18 deletions

File tree

.github/workflows/go-apidiff.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,22 @@ jobs:
2525
go-version-file: 'go.mod'
2626
id: go
2727
- name: Run go-apidiff
28+
id: check-api
29+
continue-on-error: true
2830
uses: joelanford/go-apidiff@main
31+
- name: Check for override label
32+
if: ${{ steps.check-api.outcome == 'failure' }}
33+
run: |
34+
if gh api repos/$OWNER/$REPO/pulls/$PR --jq '.labels.[].name' | grep -q "${OVERRIDE_LABEL}"; then
35+
echo "Found ${OVERRIDE_LABEL} label, overriding failed results."
36+
exit 0
37+
else
38+
echo "No ${OVERRIDE_LABEL} label found, failing the job."
39+
exit 1
40+
fi
41+
env:
42+
GH_TOKEN: ${{ github.token }}
43+
OWNER: ${{ github.repository_owner }}
44+
REPO: ${{ github.event.repository.name }}
45+
PR: ${{ github.event.pull_request.number }}
46+
OVERRIDE_LABEL: "go-apidiff-override"

.github/workflows/go-verdiff.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: go-verdiff
22
on:
33
pull_request:
44
branches:
5-
- master
5+
- master
66
jobs:
77
go-verdiff:
88
runs-on: ubuntu-latest
@@ -11,12 +11,24 @@ jobs:
1111
with:
1212
fetch-depth: 0
1313
- name: Check golang version
14+
id: check-version
15+
continue-on-error: true
1416
run: |
15-
export LABELS="$(gh api repos/$OWNER/$REPO/pulls/$PR --jq '.labels.[].name')"
1617
hack/tools/check-go-version.sh -b "${{ github.event.pull_request.base.sha }}"
1718
shell: bash
19+
- name: Check for override label
20+
if: ${{ steps.check-version.outcome == 'failure' }}
21+
run: |
22+
if gh api repos/$OWNER/$REPO/pulls/$PR --jq '.labels.[].name' | grep -q "${OVERRIDE_LABEL}"; then
23+
echo "Found ${OVERRIDE_LABEL} label, overriding failed results."
24+
exit 0
25+
else
26+
echo "No ${OVERRIDE_LABEL} label found, failing the job."
27+
exit 1
28+
fi
1829
env:
1930
GH_TOKEN: ${{ github.token }}
2031
OWNER: ${{ github.repository_owner }}
2132
REPO: ${{ github.event.repository.name }}
2233
PR: ${{ github.event.pull_request.number }}
34+
OVERRIDE_LABEL: "go-verdiff-override"

hack/tools/check-go-version.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ fi
6363
GO_MAJOR=${MAX_VER[0]}
6464
GO_MINOR=${MAX_VER[1]}
6565
GO_PATCH=${MAX_VER[2]}
66-
OVERRIDE_LABEL="override-go-verdiff"
6766

6867
RETCODE=0
6968

@@ -135,19 +134,4 @@ for f in $(find . -name "*.mod"); do
135134
fi
136135
done
137136

138-
for l in ${LABELS}; do
139-
if [ "$l" == "${OVERRIDE_LABEL}" ]; then
140-
if [ ${RETCODE} -eq 1 ]; then
141-
echo ""
142-
echo "Found ${OVERRIDE_LABEL} label, overriding failed results."
143-
RETCODE=0
144-
fi
145-
fi
146-
done
147-
148-
if [ ${RETCODE} -eq 1 ]; then
149-
echo ""
150-
echo "This test result may be overridden by applying the (${OVERRIDE_LABEL}) label to this PR and re-running the CI job."
151-
fi
152-
153137
exit ${RETCODE}

0 commit comments

Comments
 (0)