Skip to content

Commit f23bb33

Browse files
authored
Add kubeconform to workflow (#1846)
Signed-off-by: Dani Louca <[email protected]>
1 parent e4448a6 commit f23bb33

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

.github/workflows/kubeconform.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: kubeconform
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
tags:
8+
- "v[0-9]+.[0-9]+.[0-9]+*"
9+
10+
jobs:
11+
get-test-matrix:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: get matrix
18+
id: test_matrix
19+
run: |
20+
echo "Getting test matrix"
21+
matrix=`cat ci-matrix.json | jq '.kubeconform_tests' | jq -r 'tostring' | tr -d '\n'`
22+
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
23+
outputs:
24+
matrix: ${{ steps.test_matrix.outputs.matrix }}
25+
26+
kubeconform:
27+
runs-on: ubuntu-latest
28+
needs: get-test-matrix
29+
strategy:
30+
matrix: ${{ fromJSON(needs.get-test-matrix.outputs.matrix) }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Install kubeconform
35+
run: |
36+
curl -L -o kubeconform.tar.gz https://github.com/yannh/kubeconform/releases/latest/download/kubeconform-linux-amd64.tar.gz
37+
tar -xzf kubeconform.tar.gz
38+
sudo mv kubeconform /usr/local/bin/
39+
echo "done"
40+
41+
- name: Run kubeconform on rendered examples
42+
run: |
43+
for dir in examples/*/; do
44+
base_dir="$(basename "$dir")"
45+
[[ "$base_dir" == "distribution-openshift" || "$base_dir" == *operator* ]] && continue
46+
cmd="kubeconform -strict -schema-location default -output pretty -verbose -kubernetes-version ${{ matrix.k8s-version }} \"$dir\"/rendered_manifests"
47+
if ! eval $cmd; then
48+
echo "kubeconform version: $(kubeconform -v)"
49+
echo "Failed command: $cmd"
50+
exit 1
51+
fi
52+
done

ci-matrix.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,17 @@
4343
"v1.26.6",
4444
"v1.25.11"
4545
]
46+
},
47+
"kubeconform_tests": {
48+
"k8s-version": [
49+
"1.26.15",
50+
"1.27.15",
51+
"1.28.15",
52+
"1.29.15",
53+
"1.30.13",
54+
"1.31.9",
55+
"1.32.5",
56+
"1.33.1"
57+
]
4658
}
4759
}

0 commit comments

Comments
 (0)