Skip to content

Commit 92f9360

Browse files
authored
chore(tests): add linting to e2e tests (#1254)
* chore(tests): add linting to e2e tests Signed-off-by: Maksim Fedotov <[email protected]> * fix newline Signed-off-by: Maksim Fedotov <[email protected]> * fix name Signed-off-by: Maksim Fedotov <[email protected]> * remove prune path Signed-off-by: Maksim Fedotov <[email protected]> * fix e2e config Signed-off-by: Maksim Fedotov <[email protected]> * handle errors Signed-off-by: Maksim Fedotov <[email protected]> * update .golangci.yaml Signed-off-by: Maksim Fedotov <[email protected]> * fix updatedVmObj & updatedVmObjC Signed-off-by: Maksim Fedotov <[email protected]> * fix %s in fmt.Errorf Signed-off-by: Maksim Fedotov <[email protected]> * fix insecureTls Signed-off-by: Maksim Fedotov <[email protected]> * fix ApiVersion Signed-off-by: Maksim Fedotov <[email protected]> * fix VmConfiguration Signed-off-by: Maksim Fedotov <[email protected]> * fix Vm* variables Signed-off-by: Maksim Fedotov <[email protected]> * fix SshUser Signed-off-by: Maksim Fedotov <[email protected]> * fix SshOptions Signed-off-by: Maksim Fedotov <[email protected]> * fix VmConf Signed-off-by: Maksim Fedotov <[email protected]> * fix SshCommand Signed-off-by: Maksim Fedotov <[email protected]> * fix LocalSshOpts Signed-off-by: Maksim Fedotov <[email protected]> * fix VmLabelAnnotation & GetFullApiResourceName Signed-off-by: Maksim Fedotov <[email protected]> * golangci-lint run --fix Signed-off-by: Maksim Fedotov <[email protected]> * fix stylecheck dot imports error Signed-off-by: Maksim Fedotov <[email protected]> * disable all initials except VM and SSH Signed-off-by: Maksim Fedotov <[email protected]> * fix Vm->VM ST1003 errors by stylecheck Signed-off-by: Maksim Fedotov <[email protected]> * fix fmt.Errorf() formatting Signed-off-by: Maksim Fedotov <[email protected]> * replace other initialisms Signed-off-by: Maksim Fedotov <[email protected]> * golangci-lint --fix Signed-off-by: Maksim Fedotov <[email protected]> --------- Signed-off-by: Maksim Fedotov <[email protected]> Signed-off-by: Maxim Fedotov <[email protected]>
1 parent 1b07169 commit 92f9360

27 files changed

+377
-279
lines changed

tests/e2e/.golangci.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
run:
2+
concurrency: 4
3+
timeout: 10m
4+
issues:
5+
# Show all errors.
6+
max-issues-per-linter: 0
7+
max-same-issues: 0
8+
exclude:
9+
- "don't use an underscore in package name"
10+
output:
11+
sort-results: true
12+
13+
exclude-files:
14+
- "^zz_generated.*"
15+
16+
linters-settings:
17+
gofumpt:
18+
extra-rules: true
19+
gci:
20+
sections:
21+
- standard
22+
- default
23+
- prefix(github.com/deckhouse/)
24+
goimports:
25+
local-prefixes: github.com/deckhouse/
26+
errcheck:
27+
exclude-functions: fmt:.*,[rR]ead|[wW]rite|[cC]lose,io:Copy
28+
revive:
29+
rules:
30+
- name: dot-imports
31+
disabled: true
32+
stylecheck:
33+
dot-import-whitelist:
34+
- github.com/onsi/gomega
35+
- github.com/onsi/ginkgo/v2
36+
- github.com/deckhouse/virtualization/tests/e2e/helper
37+
nolintlint:
38+
# Exclude following linters from requiring an explanation.
39+
# Default: []
40+
allow-no-explanation: [funlen, gocognit, lll]
41+
# Enable to require an explanation of nonzero length after each nolint directive.
42+
# Default: false
43+
require-explanation: true
44+
# Enable to require nolint directives to mention the specific linter being suppressed.
45+
# Default: false
46+
require-specific: true
47+
48+
linters:
49+
disable-all: true
50+
enable:
51+
- asciicheck # checks that your code does not contain non-ASCII identifiers
52+
- bidichk # checks for dangerous unicode character sequences
53+
- bodyclose # checks whether HTTP response body is closed successfully
54+
- contextcheck # [maby too many false positives] checks the function whether use a non-inherited context
55+
- dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
56+
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
57+
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
58+
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
59+
- copyloopvar # detects places where loop variables are copied (Go 1.22+)
60+
- gci # controls golang package import order and makes it always deterministic
61+
- gocritic # provides diagnostics that check for bugs, performance and style issues
62+
- gofmt # [replaced by goimports] checks whether code was gofmt-ed
63+
- gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed
64+
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
65+
- gosimple # specializes in simplifying a code
66+
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
67+
- ineffassign # detects when assignments to existing variables are not used
68+
- misspell # finds commonly misspelled English words in comments
69+
- nolintlint # reports ill-formed or insufficient nolint directives
70+
- reassign # Checks that package variables are not reassigned.
71+
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
72+
- stylecheck # is a replacement for golint
73+
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
74+
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code
75+
- testifylint # checks usage of github.com/stretchr/testify
76+
- unconvert # removes unnecessary type conversions
77+
- unparam # reports unused function parameters
78+
- unused # checks for unused constants, variables, functions and types
79+
- usetesting # reports uses of functions with replacement inside the testing package
80+
- testableexamples # checks if examples are testable (have an expected output)
81+
- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers
82+
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
83+
- whitespace # detects leading and trailing whitespace
84+
- wastedassign # Finds wasted assignment statements.

tests/e2e/Taskfile.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ tasks:
159159
echo "Error: Deckhouse is not ready."
160160
exit 1
161161
fi
162-
d8 k patch mpo virtualization --type merge -p "{\"spec\":{\"imageTag\":\"$v12n_tag\"}}"
162+
d8 k patch mpo virtualization --type merge -p "{\"spec\":{\"imageTag\":\"$v12n_tag\"}}"
163163
images_hash=$(crane export "dev-registry.deckhouse.io/sys/deckhouse-oss/modules/virtualization:$v12n_tag" - | tar -Oxf - images_digests.json)
164164
v12n_pods=$(kubectl -n d8-virtualization get pods -o json | jq -c)
165165
retry_count=0
166166
max_retries=120
167-
sleep_interval=5
167+
sleep_interval=5
168168
169169
while true; do
170170
all_hashes_found=true
@@ -193,7 +193,7 @@ tasks:
193193
if [ "$all_hashes_found" = true ]; then
194194
echo "All image hashes found in pods."
195195
break
196-
fi
196+
fi
197197
198198
retry_count=$((retry_count + 1))
199199
echo "Some hashes are missing, rechecking... Attempt: $retry_count"
@@ -206,3 +206,22 @@ tasks:
206206
# Wait for the specified interval before retrying
207207
sleep "$sleep_interval"
208208
done
209+
210+
_ensure:golangci-lint:
211+
desc: "Ensure golangci-lint is available"
212+
internal: true
213+
cmds:
214+
- |
215+
echo -e >&2 "Please install golangci-lint https://golangci-lint.run/usage/install/"
216+
exit 1
217+
status:
218+
- |
219+
[ -f ./golangci-lint ] || which golangci-lint
220+
221+
lint:go:
222+
desc: "Run golangci-lint"
223+
deps:
224+
- _ensure:golangci-lint
225+
cmds:
226+
- |
227+
golangci-lint run --sort-results

0 commit comments

Comments
 (0)