Skip to content

Commit bf31f42

Browse files
authored
Fix DMT problems (#88)
Signed-off-by: v.oleynikov <[email protected]>
1 parent 7b80e2f commit bf31f42

29 files changed

+372
-282
lines changed

.dmtlint.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
linters-settings:
2+
container:
3+
exclude-rules:
4+
liveness-probe:
5+
- kind: Deployment
6+
name: csi-controller
7+
container: snapshotter
8+
- kind: Deployment
9+
name: csi-controller
10+
container: resizer
11+
- kind: Deployment
12+
name: csi-controller
13+
container: attacher
14+
- kind: Deployment
15+
name: csi-controller
16+
container: provisioner
17+
- kind: Deployment
18+
name: csi-controller
19+
container: livenessprobe
20+
- kind: DaemonSet
21+
name: csi-nfs
22+
container: tlshd
23+
- kind: DaemonSet
24+
name: csi-nfs
25+
container: node-driver-registrar
26+
readiness-probe:
27+
- kind: Deployment
28+
name: csi-controller
29+
container: snapshotter
30+
- kind: Deployment
31+
name: csi-controller
32+
container: resizer
33+
- kind: Deployment
34+
name: csi-controller
35+
container: attacher
36+
- kind: Deployment
37+
name: csi-controller
38+
container: provisioner
39+
- kind: Deployment
40+
name: csi-controller
41+
container: livenessprobe
42+
- kind: Deployment
43+
name: csi-controller
44+
container: controller
45+
- kind: DaemonSet
46+
name: csi-nfs
47+
container: tlshd
48+
- kind: DaemonSet
49+
name: csi-nfs
50+
container: node
51+
- kind: DaemonSet
52+
name: csi-nfs
53+
container: node-driver-registrar
54+
openapi:
55+
exclude-rules:
56+
enum:
57+
- spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.mountOptions.properties.mountMode

.github/workflows/build_dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Copy openapi/values_ce.yaml to openapi/values.yaml
3535
run: |
3636
if [ -f openapi/values_ce.yaml ]; then
37-
cp openapi/values_ce.yaml openapi/values.yaml
37+
cp -f openapi/values_ce.yaml openapi/values.yaml
3838
fi
3939
- uses: deckhouse/modules-actions/lint@main
4040
env:
@@ -43,7 +43,7 @@ jobs:
4343
- name: Copy openapi/values_ee.yaml to openapi/values.yaml
4444
run: |
4545
if [ -f openapi/values_ee.yaml ]; then
46-
cp openapi/values_ee.yaml openapi/values.yaml
46+
cp -f openapi/values_ee.yaml openapi/values.yaml
4747
fi
4848
- uses: deckhouse/modules-actions/lint@main
4949
env:

.github/workflows/go_checks.yaml

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
name: Go checks for images
2+
3+
env:
4+
GO_BUILD_TAGS: "ce ee se seplus csepro"
5+
6+
on:
7+
pull_request:
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
go_linter:
14+
name: Go linter for images
15+
runs-on: [self-hosted, regular]
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v2
20+
21+
- name: Setup Go environment
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: "1.24"
25+
26+
- name: Install golangci-lint
27+
run: go install github.com/golangci/golangci-lint/cmd/[email protected]
28+
29+
- name: Run Go lint
30+
run: |
31+
basedir=$(pwd)
32+
failed='false'
33+
for i in $(find images -type f -name go.mod);do
34+
dir=$(echo $i | sed 's/go.mod$//')
35+
cd $basedir/$dir
36+
# check all editions
37+
for edition in $GO_BUILD_TAGS ;do
38+
echo "Running linter in $dir (edition: $edition)"
39+
golangci-lint run --build-tags $edition
40+
if [ $? -ne 0 ]; then
41+
echo "Linter failed in $dir (edition: $edition)"
42+
failed='true'
43+
fi
44+
done
45+
done
46+
if [ $failed == 'true' ]; then
47+
exit 1
48+
fi
49+
50+
go_tests:
51+
name: Go tests for images
52+
runs-on: [self-hosted, regular]
53+
54+
steps:
55+
- name: Checkout repository
56+
uses: actions/checkout@v2
57+
58+
- name: Setup Go environment
59+
uses: actions/setup-go@v5
60+
with:
61+
go-version: "1.24"
62+
63+
- name: Run Go tests
64+
run: |
65+
basedir=$(pwd)
66+
failed='false'
67+
for i in $(find images -type f -name '*_test.go');do
68+
dir=$(echo $i | sed 's/[a-z_A-Z0-9-]*_test.go$//')
69+
cd $basedir/$dir
70+
# check all editions
71+
for edition in $GO_BUILD_TAGS ;do
72+
echo "Running tests in $dir (edition: $edition)"
73+
go test -v -tags $edition
74+
if [ $? -ne 0 ]; then
75+
echo "Tests failed in $dir (edition: $edition)"
76+
failed='true'
77+
fi
78+
done
79+
done
80+
if [ $failed == 'true' ]; then
81+
exit 1
82+
fi
83+
84+
go_test_coverage:
85+
name: Go test coverage for images
86+
runs-on: [self-hosted, regular]
87+
88+
steps:
89+
- name: Checkout repository
90+
uses: actions/checkout@v2
91+
92+
- name: Setup Go environment
93+
uses: actions/setup-go@v5
94+
with:
95+
go-version: "1.24"
96+
97+
- name: Run Go test coverage count
98+
run: |
99+
if [ ! -d "images" ]; then
100+
echo "No images/ directory found. Please run this script from the root of the repository."
101+
exit 1
102+
fi
103+
104+
find images/ -type f -name "go.mod" | while read -r gomod; do
105+
dir=$(dirname "$gomod")
106+
107+
echo "Test coverage in $dir"
108+
109+
cd "$dir" || continue
110+
111+
for tag in $GO_BUILD_TAGS; do
112+
echo " Build tag: $tag"
113+
114+
go test ./... -cover -tags "$tag"
115+
done
116+
117+
cd - > /dev/null
118+
119+
echo "----------------------------------------"
120+
done
121+
122+
go_modules_check:
123+
name: Go modules version
124+
runs-on: [self-hosted, regular]
125+
126+
steps:
127+
- name: Checkout repository
128+
uses: actions/checkout@v2
129+
130+
- name: Setup Go environment
131+
uses: actions/setup-go@v5
132+
with:
133+
go-version: "1.24"
134+
135+
- name: Run Go modules version check
136+
run: |
137+
search_dir=$(pwd)"/images"
138+
139+
if [ ! -d "$search_dir" ]; then
140+
echo "Directory $search_dir does not exist."
141+
exit 1
142+
fi
143+
144+
temp_dir=$(mktemp -d)
145+
touch "$temp_dir/incorrect_alert"
146+
147+
trap 'rm -rf "$temp_dir"' EXIT
148+
149+
find images/ -type f -name "go.mod" | while read -r gomod; do
150+
dir=$(dirname "$gomod")
151+
152+
echo "Checking $dir"
153+
154+
cd "$dir" || continue
155+
156+
go list -m all | grep deckhouse | grep -v '=>' | while IFS= read -r line; do
157+
module_name=$(echo "$line" | awk '{print $1}')
158+
module_version=$(echo "$line" | awk '{print $2}')
159+
160+
if [ -z "$module_version" ]; then
161+
echo " Checking module name $module_name"
162+
correct_module_name="github.com"/"$GITHUB_REPOSITORY"/"$dir"
163+
if [ "$module_name" != "$correct_module_name" ]; then
164+
echo " Incorrect module name: $module_name, expected: $correct_module_name"
165+
echo " Incorrect module name: $module_name, expected: $correct_module_name" >> "$temp_dir/incorrect_alert"
166+
else
167+
echo " Correct module name: $module_name"
168+
fi
169+
else
170+
echo " Checking module tag $module_name"
171+
repository=$(echo "$line" | awk '{print $1}' | awk -F'/' '{ print "https://"$1"/"$2"/"$3".git" }')
172+
pseudo_tag=$(echo "$line" | awk '{print $2}')
173+
174+
echo " Cloning repo $repository into $temp_dir"
175+
git clone "$repository" "$temp_dir/$repository" >/dev/null 2>&1
176+
177+
cd "$temp_dir/$repository" || continue
178+
179+
commit_info=$(git log -1 --pretty=format:"%H %cd" --date=iso-strict -- api/*)
180+
short_hash=$(echo "$commit_info" | awk '{print substr($1,1,12)}')
181+
commit_date=$(echo "$commit_info" | awk '{print $2}')
182+
commit_date=$(date -u -d "$commit_date" +"%Y%m%d%H%M%S")
183+
actual_pseudo_tag="v0.0.0-"$commit_date"-"$short_hash
184+
pseudo_tag_date=$(echo $pseudo_tag | awk -F'-' '{ print $2 }')
185+
echo " Latest commit in $repository: $short_hash $commit_date"
186+
187+
if [[ "$module_version" != "$commit_date" ]]; then
188+
echo " Incorrect pseudo tag for repo $repository in file "$go_mod_file" (current: "$pseudo_tag", actual:"$actual_pseudo_tag")"
189+
echo " Incorrect pseudo tag for repo $repository in file "$go_mod_file" (current: "$pseudo_tag", actual:"$actual_pseudo_tag")" >> $temp_dir"/incorrect_alert"
190+
fi
191+
192+
cd - >/dev/null 2>&1
193+
fi
194+
done
195+
196+
cd - > /dev/null
197+
198+
echo "----------------------------------------"
199+
done
200+
201+
alert_lines_count=$(cat $temp_dir"/incorrect_alert" | wc -l)
202+
203+
if [ $alert_lines_count != 0 ]; then
204+
echo "We have non-actual pseudo-tags or modules names in repository's go.mod files"
205+
exit 1
206+
fi

.github/workflows/go_lint.yaml

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)