Skip to content

Commit 9dccb4b

Browse files
authored
Added crd validation ci workflow. (#1879)
* Added crd validation ci workflow. * Added go module caching. * fetching proper base_ref. * Test branch fetching. * Substitute branch name with sha. * another try. * Removed debug comment.
1 parent f357ece commit 9dccb4b

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
with:
24+
go-version: "1.25"
25+
cache: true
26+
27+
- name: Install crdify
28+
run: |
29+
go install sigs.k8s.io/crdify@latest
30+
31+
- name: Run CRD Validation Check
32+
run: |
33+
git fetch origin ${{ github.base_ref }}:upstream_base
34+
BASE_SHA=$(git rev-parse upstream_base)
35+
36+
FAILED=0
37+
for crd in config/crd/bases/*.yaml; do
38+
if ! crdify "git://${BASE_SHA}?path=$crd" "git://HEAD?path=$crd"; then
39+
echo "❌ Incompatible change detected in $crd"
40+
((FAILED++))
41+
else
42+
echo "✅ $crd is valid"
43+
fi
44+
done
45+
46+
if [ "$FAILED" -gt 0 ]; then
47+
echo "::error::Validation failed! Found $FAILED incompatible CRD change(s)."
48+
exit 1
49+
fi
50+
51+
echo "All CRDs are compatible."

0 commit comments

Comments
 (0)