1
name: GitHub Workflow Related Checks
3
# Any change in triggers needs to be reflected in the concurrency group.
14
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
15
cancel-in-progress: true
18
ginkgo-workflow-comments:
19
name: Lint Ginko Workflows Comments
20
runs-on: ubuntu-latest
23
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
25
persist-credentials: false
26
# hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
27
path: src/github.com/cilium/cilium
29
# Load Ginkgo build from GitHub
30
- name: Load ginkgo linter from GH cache
31
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
34
path: /tmp/.ginkgo-build/
35
key: ${{ runner.os }}-ginkgo-linter-${{ hashFiles('src/github.com/cilium/cilium/**/*.go') }}
38
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
39
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
41
# renovate: datasource=golang-version depName=go
45
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
48
cd src/github.com/cilium/cilium
49
go install github.com/onsi/ginkgo/ginkgo@v1.16.5
50
mkdir -p /tmp/.ginkgo-build
52
- name: Building Ginkgo Linter Test
53
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
56
cd src/github.com/cilium/cilium
57
git apply contrib/testing/ginkgo-get-all-test-names.patch
60
/home/runner/go/bin/ginkgo build
62
tar -cz test.test -f test.tgz
64
- name: Store Ginkgo Linter Test in GitHub cache path
65
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
68
cd src/github.com/cilium/cilium
69
mkdir -p /tmp/.ginkgo-build/
70
if [ -f test/test.tgz ]; then
71
cp test/test.tgz /tmp/.ginkgo-build/
75
- name: Copy Ginkgo binary
76
if: ${{ steps.cache.outputs.cache-hit == 'true' }}
79
cd src/github.com/cilium/cilium/test/
80
tar -xf /tmp/.ginkgo-build/test.tgz
82
- name: Reading Comments From Workflows
85
cd src/github.com/cilium/cilium
87
grep '# K8s' .github/actions/ginkgo/main-focus.yaml | \
88
sed -e 's/^[[:space:]]\+# //g' | \
89
sort -u > /tmp/ginkgo-workflow-comments.txt
91
grep '# Runtime' .github/workflows/conformance-runtime.yaml | \
92
sed -e 's/^[[:space:]]\+# //g' | \
93
sort -u > /tmp/runtime-workflow-comments.txt
95
- name: Getting test runs output
98
cd src/github.com/cilium/cilium/test
100
./test.test -ginkgo.failFast -ginkgo.dryRun -- --cilium.testScope=K8s | \
102
grep -v 'TestRun\[Top Level\] Runtime' | \
103
sed 's/TestRun\[Top Level\]\ //g' | \
104
sort -u > /tmp/ginkgo-tests.txt
106
./test.test -ginkgo.failFast -ginkgo.dryRun -- --cilium.testScope=Runtime | \
108
grep -v 'TestRun\[Top Level\] K8s' | \
109
sed 's/TestRun\[Top Level\]\ //g' | \
110
sort -u > /tmp/runtime-tests.txt
112
- name: Checking diff Ginkgo Workflow
115
diff /tmp/ginkgo-workflow-comments.txt /tmp/ginkgo-tests.txt --suppress-common-lines
117
if [ $? -ne 0 ]; then
119
echo "Ginkgo tests out of sync with comments from GH workflow:"
121
echo "Please fix the comments from .github/actions/ginkgo/main-focus.yaml accordingly"
126
- name: Checking diff Runtime Workflow
129
diff /tmp/runtime-workflow-comments.txt /tmp/runtime-tests.txt --suppress-common-lines
131
if [ $? -ne 0 ]; then
133
echo "Ginkgo tests out of sync with comments from GH workflow:"
136
echo "Please fix the comments from .github/workflows/conformance-runtime.yaml accordingly"
140
ginkgo-schema-validation:
141
name: Validate Ginko Schema
142
runs-on: ubuntu-latest
145
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
147
python-version: '3.10'
148
- name: Install yamela
149
run: pip install yamale
150
- name: Checkout code
151
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
153
persist-credentials: false
154
# hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
155
path: src/github.com/cilium/cilium
157
- name: Validate schema of ginkgo action files
160
cd src/github.com/cilium/cilium/.github/actions/ginkgo/
161
for type in focus k8s-versions prs scheduled; do
162
yamale -s ${type}-schema.yaml *-${type}.yaml;
165
conformance-schema-validation:
166
name: Validate k8s Versions Schema
167
runs-on: ubuntu-latest
170
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
172
python-version: '3.10'
173
- name: Install yamela
174
run: pip install yamale
175
- name: Checkout code
176
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
178
persist-credentials: false
179
# hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
180
path: src/github.com/cilium/cilium
182
- name: Validate schema of aws, azure and gke action files
185
for dir in aws azure gke;do
186
dir_base=".github/actions/${dir}"
187
file_base="${dir_base}/k8s-versions"
188
if [ -f ${file_base}.yaml ];then
189
yamale -s ${file_base}-schema.yaml ${file_base}.yaml;
191
if [ -f ${dir_base}/test-config-schema.yaml ];then
192
yamale -s ${dir_base}/test-config-schema.yaml ${dir_base}/test-config-classic.yaml
193
yamale -s ${dir_base}/test-config-schema.yaml ${dir_base}/test-config-helm.yaml
198
name: Validate Workflow Names
199
runs-on: ubuntu-latest
201
- name: Checkout code
202
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
204
persist-credentials: false
205
# hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
206
path: src/github.com/cilium/cilium
208
- name: Validate Job and Step names
212
cd src/github.com/cilium/cilium/.github/workflows
213
for FILE in *.yaml;do
214
JOBS=$(yq '.jobs | to_entries | .[] | select(.value.name == null) | " " + .key' $FILE)
215
STEPS=$(yq '.jobs | to_entries | .[] as $job | $job.value.steps[] | {"key": $job.key, "name": .name} | select(.name == null) | " "+.key' $FILE)
216
if [ "${JOBS}" != "" ];then
217
echo Jobs are missing name field, in file $FILE
218
echo "${JOBS}" | awk '{for (i=1; i<=NF; i++) print " " $i}'
221
if [ "${STEPS}" != "" ];then
222
echo Steps are missing name field, under these Jobs in file $FILE
223
echo "${STEPS}" | awk '{for (i=1; i<=NF; i++) print " " $i}'