Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions .github/workflows/crd-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ name: CRD Validation

on:
pull_request:
types: [opened, edited, synchronize, reopened]
types: [opened, edited, synchronize, reopened, labeled, unlabeled]

permissions:
contents: read
pull-requests: write

jobs:
crd-validation:
Expand All @@ -28,7 +29,17 @@ jobs:
run: |
go install sigs.k8s.io/crdify@latest

- name: Reset Validation Approval
if: github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'ack-breaking-changes')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "ack-breaking-changes"
echo "⚠️ Removed 'ack-breaking-changes' label due to new changes. Re-approval required."

- name: Run CRD Validation Check
env:
ALLOW_BREAKING: ${{ contains(github.event.pull_request.labels.*.name, 'ack-breaking-changes') && github.event.action != 'synchronize' }}
run: |
git fetch origin ${{ github.base_ref }}:upstream_base
BASE_SHA=$(git rev-parse upstream_base)
Expand All @@ -37,15 +48,21 @@ jobs:
for crd in config/crd/bases/*.yaml; do
if ! crdify "git://${BASE_SHA}?path=$crd" "git://HEAD?path=$crd"; then
echo "❌ Incompatible change detected in $crd"
((FAILED++))
FAILED=$((FAILED + 1))
else
echo "✅ $crd is valid"
fi
done

if [ "$FAILED" -gt 0 ]; then
echo "::error::Validation failed! Found $FAILED incompatible CRD change(s)."
exit 1
if [[ "$ALLOW_BREAKING" == "true" ]]; then
echo "⚠️ Validation failed with $FAILED incompatible change(s), but allowed via 'ack-breaking-changes' label."
exit 0
else
echo "❌ error: Validation failed! Found $FAILED incompatible CRD change(s)."
echo "⚠️ notice: To allow these changes, a reviewer must add the 'ack-breaking-changes' label to the PR."
exit 1
fi
fi

echo "All CRDs are compatible."