Skip to content

Commit f6ed72a

Browse files
committed
Added crd validation ci workflow.
1 parent 58a7e6c commit f6ed72a

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CRD Validation
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
crd-validation:
12+
name: CRD Validation Check
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
persist-credentials: false
19+
fetch-depth: 0
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v6
23+
24+
- name: Install crdify
25+
run: |
26+
go install sigs.k8s.io/crdify@latest
27+
28+
- name: Run CRD Validation Check
29+
run: |
30+
git fetch origin ${{ github.base_ref }}
31+
BASE_REF="origin/${{ github.base_ref }}"
32+
33+
FAILED=0
34+
35+
for crd in config/crd/bases/*.yaml; do
36+
if ! crdify "git://${BASE_REF}?path=$crd" "git://HEAD?path=$crd"; then
37+
echo "❌ Incompatible change detected in $crd"
38+
((FAILED++))
39+
else
40+
echo "✅ $crd is valid"
41+
fi
42+
done
43+
44+
if [ "$FAILED" -gt 0 ]; then
45+
echo "::error::Validation failed! Found $FAILED incompatible CRD change(s)."
46+
exit 1
47+
fi
48+
49+
echo "All CRDs are compatible."

0 commit comments

Comments
 (0)