Skip to content

Commit a868e48

Browse files
Igor Drozdovashmckenzie
authored andcommitted
Merge branch 'ashmckenzie/improve-lint-error-reporting' into 'main'
Improve lint error reporting See merge request https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/1133 Merged-by: Igor Drozdov <[email protected]> Approved-by: Oscar Tovar <[email protected]> Approved-by: Igor Drozdov <[email protected]> Reviewed-by: Oscar Tovar <[email protected]> Co-authored-by: Ash McKenzie <[email protected]>
2 parents 2137366 + 29b1a52 commit a868e48

File tree

47 files changed

+567
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+567
-95
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ variables:
1616
TRANSFER_METER_FREQUENCY: "1s"
1717
DOCKER_VERSION: "20.10.15"
1818
BUNDLE_FROZEN: "true"
19-
GO_VERSION: "golang-1.22"
19+
GO_VERSION: "golang-1.23"
2020
GOPATH: $CI_PROJECT_DIR/.GOPATH
2121
DEBIAN_VERSION: "bookworm"
2222
RUBY_VERSION: "3.2.4"

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ output:
6161
# print linter name in the end of issue text, default is true
6262
print-linter-name: true
6363

64+
sort-results: true
65+
6466
# all available settings of specific linters
6567
linters-settings:
6668
errcheck:

Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ coverage: coverage_golang
8686
coverage_golang:
8787
[ -f cover.out ] && go tool cover -func cover.out
8888

89-
lint: ${GOLANGCI_LINT_FILE}
90-
${GOLANGCI_LINT_FILE} --version
91-
${GOLANGCI_LINT_FILE} run --issues-exit-code 0 --print-issued-lines=false ${GOLANGCI_LINT_ARGS}
89+
lint:
90+
@support/lint.sh ./...
91+
92+
golangci: ${GOLANGCI_LINT_FILE}
93+
@${GOLANGCI_LINT_FILE} run --issues-exit-code 0 --print-issued-lines=false ${GOLANGCI_LINT_ARGS}
9294

9395
${GOLANGCI_LINT_FILE}:
94-
mkdir -p $(shell dirname ${GOLANGCI_LINT_FILE})
95-
curl -L https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-${OS}-${ARCH}.tar.gz | tar --strip-components 1 -zOxf - golangci-lint-${GOLANGCI_LINT_VERSION}-${OS}-${ARCH}/golangci-lint > ${GOLANGCI_LINT_FILE} && chmod +x ${GOLANGCI_LINT_FILE}
96+
@mkdir -p $(shell dirname ${GOLANGCI_LINT_FILE})
97+
@curl -L https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-${OS}-${ARCH}.tar.gz | tar --strip-components 1 -zOxf - golangci-lint-${GOLANGCI_LINT_VERSION}-${OS}-${ARCH}/golangci-lint > ${GOLANGCI_LINT_FILE} && chmod +x ${GOLANGCI_LINT_FILE}
9698

9799
setup: make_necessary_dirs bin/gitlab-shell
98100

client/client_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,45 +36,45 @@ func TestClients(t *testing.T) {
3636
}{
3737
{
3838
desc: "Socket client",
39-
server: testserver.StartSocketHttpServer,
39+
server: testserver.StartSocketHTTPServer,
4040
secret: secret,
4141
},
4242
{
4343
desc: "Socket client with a relative URL at /",
4444
relativeURLRoot: "/",
45-
server: testserver.StartSocketHttpServer,
45+
server: testserver.StartSocketHTTPServer,
4646
secret: secret,
4747
},
4848
{
4949
desc: "Socket client with relative URL at /gitlab",
5050
relativeURLRoot: "/gitlab",
51-
server: testserver.StartSocketHttpServer,
51+
server: testserver.StartSocketHTTPServer,
5252
secret: secret,
5353
},
5454
{
5555
desc: "Http client",
56-
server: testserver.StartHttpServer,
56+
server: testserver.StartHTTPServer,
5757
secret: secret,
5858
},
5959
{
6060
desc: "Https client",
6161
caFile: path.Join(testRoot, "certs/valid/server.crt"),
6262
server: func(t *testing.T, handlers []testserver.TestRequestHandler) string {
63-
return testserver.StartHttpsServer(t, handlers, "")
63+
return testserver.StartHTTPSServer(t, handlers, "")
6464
},
6565
secret: secret,
6666
},
6767
{
6868
desc: "Secret with newlines",
6969
caFile: path.Join(testRoot, "certs/valid/server.crt"),
7070
server: func(t *testing.T, handlers []testserver.TestRequestHandler) string {
71-
return testserver.StartHttpsServer(t, handlers, "")
71+
return testserver.StartHTTPSServer(t, handlers, "")
7272
},
7373
secret: "\n" + secret + "\n",
7474
},
7575
{
7676
desc: "Retry client",
77-
server: testserver.StartRetryHttpServer,
77+
server: testserver.StartRetryHTTPServer,
7878
secret: secret,
7979
},
8080
}

client/httpclient_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func TestRequestWithUserAgent(t *testing.T) {
125125
}
126126

127127
func setup(t *testing.T, username, password string, requests []testserver.TestRequestHandler) *GitlabNetClient {
128-
url := testserver.StartHttpServer(t, requests)
128+
url := testserver.StartHTTPServer(t, requests)
129129

130130
httpClient, err := NewHTTPClientWithOpts(url, "", "", "", 1, nil)
131131
require.NoError(t, err)

client/httpsclient_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func setupWithRequests(t *testing.T, caFile, caPath, clientCAPath, clientCertPat
123123
},
124124
}
125125

126-
url := testserver.StartHttpsServer(t, requests, clientCAPath)
126+
url := testserver.StartHTTPSServer(t, requests, clientCAPath)
127127

128128
opts := defaultHttpOpts
129129
if clientCertPath != "" && clientKeyPath != "" {

client/testserver/testserver.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ type TestRequestHandler struct {
2222
Handler func(w http.ResponseWriter, r *http.Request)
2323
}
2424

25-
func StartSocketHttpServer(t *testing.T, handlers []TestRequestHandler) string {
25+
// StartSocketHTTPServer starts a socket based HTTP server
26+
func StartSocketHTTPServer(t *testing.T, handlers []TestRequestHandler) string {
2627
t.Helper()
2728

2829
// We can't use t.TempDir() here because it will create a directory that
@@ -55,7 +56,8 @@ func StartSocketHttpServer(t *testing.T, handlers []TestRequestHandler) string {
5556
return url
5657
}
5758

58-
func StartHttpServer(t *testing.T, handlers []TestRequestHandler) string {
59+
// StartHTTPServer starts a TCP based HTTP server
60+
func StartHTTPServer(t *testing.T, handlers []TestRequestHandler) string {
5961
t.Helper()
6062

6163
server := httptest.NewServer(buildHandler(handlers))
@@ -64,7 +66,8 @@ func StartHttpServer(t *testing.T, handlers []TestRequestHandler) string {
6466
return server.URL
6567
}
6668

67-
func StartRetryHttpServer(t *testing.T, handlers []TestRequestHandler) string {
69+
// StartRetryHTTPServer starts a TCP based HTTP server with retry capabilities
70+
func StartRetryHTTPServer(t *testing.T, handlers []TestRequestHandler) string {
6871
attempts := map[string]int{}
6972

7073
retryMiddileware := func(next func(w http.ResponseWriter, r *http.Request)) http.Handler {
@@ -92,7 +95,8 @@ func StartRetryHttpServer(t *testing.T, handlers []TestRequestHandler) string {
9295
return server.URL
9396
}
9497

95-
func StartHttpsServer(t *testing.T, handlers []TestRequestHandler, clientCAPath string) string {
98+
// StartHTTPSServer starts a TCP based HTTPS capable server
99+
func StartHTTPSServer(t *testing.T, handlers []TestRequestHandler, clientCAPath string) string {
96100
t.Helper()
97101

98102
testRoot := testhelper.PrepareTestRootDir(t)

cmd/gitlab-sshd/acceptance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func startGitOverHTTPServer(t *testing.T) string {
137137
},
138138
}
139139

140-
return testserver.StartHttpServer(t, requests)
140+
return testserver.StartHTTPServer(t, requests)
141141
}
142142

143143
func buildAllowedResponse(t *testing.T, filename string) string {

internal/command/authorizedkeys/authorized_keys_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var (
4343
)
4444

4545
func TestExecute(t *testing.T) {
46-
url := testserver.StartSocketHttpServer(t, requests)
46+
url := testserver.StartSocketHTTPServer(t, requests)
4747

4848
defaultConfig := &config.Config{RootDir: "/tmp", GitlabUrl: url}
4949

internal/command/discover/discover_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var requests = []testserver.TestRequestHandler{
4545
}
4646

4747
func TestExecute(t *testing.T) {
48-
url := testserver.StartSocketHttpServer(t, requests)
48+
url := testserver.StartSocketHTTPServer(t, requests)
4949

5050
testCases := []struct {
5151
desc string
@@ -96,7 +96,7 @@ func TestExecute(t *testing.T) {
9696
}
9797

9898
func TestFailingExecute(t *testing.T) {
99-
url := testserver.StartSocketHttpServer(t, requests)
99+
url := testserver.StartSocketHTTPServer(t, requests)
100100

101101
testCases := []struct {
102102
desc string

0 commit comments

Comments
 (0)