-
Notifications
You must be signed in to change notification settings - Fork 5
233 lines (207 loc) · 7.67 KB
/
dev_validation.yaml
File metadata and controls
233 lines (207 loc) · 7.67 KB
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# Copyright 2024 Flant JSC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Validations
env:
GO_VERSION: "1.24.13"
on:
pull_request:
types: [opened, synchronize, labeled, unlabeled]
concurrency:
group: "${{ github.workflow }}-${{ github.event.number || github.ref }}"
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
paths_filter:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'validation/skip/helm_templates') }}
runs-on: ubuntu-latest
name: Filter changed paths
outputs:
helm_templates: ${{ steps.paths_filter.outputs.helm_templates }}
vm_route_forge: ${{ steps.paths_filter.outputs.vm_route_forge }}
steps:
# For pull requests it's not necessary to checkout the code, this action uses Github API.
- uses: dorny/paths-filter@v3
id: paths_filter
with:
filters: |
helm_templates:
- 'crds/**'
- 'charts/**'
- 'tools/kubeconform/**'
- 'templates/**'
- .helmignore
- Chart.yaml
- Taskfile.yaml
route_forge:
- 'images/vm-route-forge/bpf/route_watcher.c'
no_cyrillic:
if: "!contains(github.event.pull_request.labels.*.name, 'validation/skip/no_cyrillic')"
runs-on: ubuntu-latest
name: Validation no-cyrillic
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Run validation "No cyrillic"
run: |
task validation:no-cyrillic
doc_changes:
if: "!contains(github.event.pull_request.labels.*.name, 'validation/skip/doc_changes')"
runs-on: ubuntu-latest
name: Validation doc-changes
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Run validation "Doc changes"
run: |
task validation:doc-changes
# Run helm templates validation on changes in related files and without the skip labels.
helm_templates:
needs: paths_filter
if: ${{ needs.paths_filter.outputs.helm_templates == 'true' && !contains(github.event.pull_request.labels.*.name, 'validation/skip/helm_templates') }}
# 22.04 image contains Helm v3.17.2, it is not affected by MaxDecompressedFileSize limit.
# TODO change back to latest after Helm people fix this issue: https://github.com/helm/helm/issues/30738
runs-on: ubuntu-22.04
name: Validate helm templates with OpenAPI schemas
steps:
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: azure/setup-helm@v4.3.0
with:
version: v3.17.2
id: install
- uses: actions/checkout@v4
- name: Run validation "Helm templates"
run: |
task validation:helm-templates
check_gens_files:
name: Check auto-generated files are up-to-date
needs: paths_filter
runs-on: ubuntu-latest
strategy:
matrix:
# Define two groups of components with their respective Go versions
components:
- { component: virtualization-artifact, go-version: "1.24.13" }
- { component: vm-route-forge, go-version: "1.24.13" }
- { component: api, go-version: "1.24.13" }
steps:
- name: Set skip flag
run: |
# Only run vm-route-forge if relevant files were changed
if [[ "${{ needs.paths_filter.outputs.vm_route_forge }}" == "true" ]]; then
echo "route_forge_skip=false" >> $GITHUB_ENV
else
echo "route_forge_skip=true" >> $GITHUB_ENV
fi
- name: Setup Go ${{ matrix.components.go-version }}
if: matrix.components.component != 'vm-route-forge' || env.route_forge_skip != 'true'
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.components.go-version }}
- name: Install Task
if: matrix.components.component != 'vm-route-forge' || env.route_forge_skip != 'true'
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
if: matrix.components.component != 'vm-route-forge' || env.route_forge_skip != 'true'
run: |
echo "Install packages"
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y -qq \
llvm linux-headers-$(uname -r) clang \
libbpf-dev uuid-runtime \
gcc-multilib yq
sudo apt-get clean
- uses: actions/checkout@v4
if: matrix.components.component != 'vm-route-forge' || env.route_forge_skip != 'true'
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Run check gen files - ${{ matrix.components.component }}
if: matrix.components.component != 'vm-route-forge' || env.route_forge_skip != 'true'
run: |
function check_diffs() {
local folder=$1
if ! git diff --exit-code; then
echo "Error: Some generated files are out of date. Run 'go generate' and commit the changes."
echo "::group::📂 Diffs for ${{ matrix.components.component }}"
echo "=== git diff ==="
git diff origin/main -- "$folder"
echo "=== end git diff ==="
echo "::endgroup::"
exit 1
else
echo "✅ No differences found in '$folder'. All files are up to date."
fi
}
case "${{ matrix.components.component }}" in
virtualization-artifact)
cd ./images/virtualization-artifact
echo "Installing go dependencies..."
go install tool
cd ..
task controller:dev:gogenerate
check_diffs ./images/virtualization-artifact
;;
vm-route-forge)
task vm-route-forge:gen
check_diffs ./images/vm-route-forge
;;
api)
cd ./api
export GOPATH=$(go env GOPATH)
echo "GOPATH=$GOPATH" >> $GITHUB_ENV
echo "Installing k8s tools..."
go install tool
echo "Run generate"
task generate
# task controller:api:generate
cd ..
check_diffs ./api
;;
*)
echo "❌ Unknown component: ${{ matrix.components.component }}"
exit 1
;;
esac