forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 2
210 lines (184 loc) · 7.36 KB
/
lint-workflows.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: GitHub Workflow Related Checks
# Any change in triggers needs to be reflected in the concurrency group.
on:
pull_request: {}
push:
branches:
- v1.14
- ft/v1.14/**
permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
jobs:
ginkgo-workflow-comments:
name: Lint Ginko Workflows Comments
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
# hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
path: src/github.com/cilium/cilium
# Load Ginkgo build from GitHub
- name: Load ginkgo linter from GH cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: cache
with:
path: /tmp/.ginkgo-build/
key: ${{ runner.os }}-ginkgo-linter-${{ hashFiles('src/github.com/cilium/cilium/**/*.go') }}
- name: Install Go
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
cache-dependency-path: "src/github.com/cilium/cilium/*.sum"
# renovate: datasource=golang-version depName=go
go-version: 1.22.9
- name: Build Ginkgo
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium
go install github.com/onsi/ginkgo/[email protected]
mkdir -p /tmp/.ginkgo-build
- name: Building Ginkgo Linter Test
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium
git apply contrib/testing/ginkgo-get-all-test-names.patch
cd test
/home/runner/go/bin/ginkgo build
strip test.test
tar -cz test.test -f test.tgz
- name: Store Ginkgo Linter Test in GitHub cache path
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium
mkdir -p /tmp/.ginkgo-build/
if [ -f test/test.tgz ]; then
cp test/test.tgz /tmp/.ginkgo-build/
echo "file copied"
fi
- name: Copy Ginkgo binary
if: ${{ steps.cache.outputs.cache-hit == 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium/test/
tar -xf /tmp/.ginkgo-build/test.tgz
- name: Reading Comments From Workflows
shell: bash
run: |
cd src/github.com/cilium/cilium
grep '# K8s' .github/actions/ginkgo/main-focus.yaml | \
sed -e 's/^[[:space:]]\+# //g' | \
sort -u > /tmp/ginkgo-workflow-comments.txt
grep '# Runtime' .github/workflows/conformance-runtime.yaml | \
sed -e 's/^[[:space:]]\+# //g' | \
sort -u > /tmp/runtime-workflow-comments.txt
- name: Getting test runs output
shell: bash
run: |
cd src/github.com/cilium/cilium/test
./test.test -ginkgo.failFast -ginkgo.dryRun -- --cilium.testScope=K8s | \
grep TestRun | \
grep -v 'TestRun\[Top Level\] Runtime' | \
sed 's/TestRun\[Top Level\]\ //g' | \
sort -u > /tmp/ginkgo-tests.txt
./test.test -ginkgo.failFast -ginkgo.dryRun -- --cilium.testScope=Runtime | \
grep TestRun | \
grep -v 'TestRun\[Top Level\] K8s' | \
sed 's/TestRun\[Top Level\]\ //g' | \
sort -u > /tmp/runtime-tests.txt
- name: Checking diff Ginkgo Workflow
shell: bash
run: |
diff /tmp/ginkgo-workflow-comments.txt /tmp/ginkgo-tests.txt --suppress-common-lines
if [ $? -ne 0 ]; then
echo ""
echo "Ginkgo tests out of sync with comments from GH workflow:"
echo "$diff"
echo "Please fix the comments from .github/actions/ginkgo/main-focus.yaml accordingly"
echo ""
exit 1
fi
- name: Checking diff Runtime Workflow
shell: bash
run: |
diff /tmp/runtime-workflow-comments.txt /tmp/runtime-tests.txt --suppress-common-lines
if [ $? -ne 0 ]; then
echo ""
echo "Ginkgo tests out of sync with comments from GH workflow:"
echo "$diff"
echo ""
echo "Please fix the comments from .github/workflows/conformance-runtime.yaml accordingly"
exit 1
fi
ginkgo-schema-validation:
name: Validate Ginko Schema
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.10'
- name: Install yamela
run: pip install yamale
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
# hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
path: src/github.com/cilium/cilium
- name: Validate schema of ginkgo action files
shell: bash
run: |
cd src/github.com/cilium/cilium/.github/actions/ginkgo/
for type in focus k8s-versions prs scheduled; do
yamale -s ${type}-schema.yaml *-${type}.yaml;
done
conformance-schema-validation:
name: Validate k8s Versions Schema
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.10'
- name: Install yamela
run: pip install yamale
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
# hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
path: src/github.com/cilium/cilium
- name: Validate schema of aws, azure and gke action files
shell: bash
run: |
for dir in aws azure gke;do
dir_base=".github/actions/${dir}"
file_base="${dir_base}/k8s-versions"
if [ -f ${file_base}.yaml ];then
yamale -s ${file_base}-schema.yaml ${file_base}.yaml;
fi
if [ -f ${dir_base}/test-config-schema.yaml ];then
yamale -s ${dir_base}/test-config-schema.yaml ${dir_base}/test-config-classic.yaml
yamale -s ${dir_base}/test-config-schema.yaml ${dir_base}/test-config-helm.yaml
fi
done
- name: Validate Absence of Trailing Spaces
shell: bash
working-directory: src/github.com/cilium/cilium/
run: |
if grep --quiet --recursive '[[:blank:]]$' .github; then
echo "Found trailing spaces in the following workflow files"
grep --files-with-matches --recursive '[[:blank:]]$' .github
echo
echo "Please run:"
echo " find .github -type f -exec sed -ri 's/[[:blank:]]+$//' {} \;"
echo "and submit your changes"
exit 1
fi