Skip to content

Commit 402d111

Browse files
authored
chore: Explicitly run make lint (#1645)
* chore: Explicitly run make lint - Install golangci-lint make target to use in action - Do not run go fmt when generating schemas - Increase golangci timeout Signed-off-by: Evans Mungai <[email protected]> * Add setup env step Signed-off-by: Evans Mungai <[email protected]> * Add build-tags to golangci-lint command Signed-off-by: Evans Mungai <[email protected]> --------- Signed-off-by: Evans Mungai <[email protected]>
1 parent 8105fa0 commit 402d111

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

.github/workflows/build-test-deploy.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,32 @@ concurrency:
2222
jobs:
2323
fail_if_pull_request_is_draft:
2424
if: github.event.pull_request.draft == true
25-
runs-on: ubuntu-20.04
25+
runs-on: ubuntu-latest
2626
steps:
2727
- name: Fails in order to indicate that pull request needs to be marked as ready to review and unit tests workflow needs to pass.
2828
run: exit 1
2929

3030
test:
31-
runs-on: ubuntu-20.04
31+
runs-on: ubuntu-latest
3232
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
3336
- uses: actions/setup-go@v5
3437
with:
3538
go-version: "1.22"
36-
3739
- name: setup env
3840
run: |
3941
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
4042
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
4143
shell: bash
42-
43-
- uses: actions/checkout@v4
44-
45-
- run: make test
44+
- name: Run linters
45+
run: make install-golangci-lint lint
46+
- name: Run tests
47+
run: make test
4648

4749
test-integration:
48-
runs-on: ubuntu-20.04
50+
runs-on: ubuntu-latest
4951
steps:
5052
- uses: actions/setup-go@v5
5153
with:

.github/workflows/license.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17-
18-
- name: Setup Go
19-
uses: actions/setup-go@v5
20-
with:
21-
go-version: 1.21
22-
23-
- name: Install Go deps
24-
run: go mod download
25-
2617
- name: Install trivy
2718
run: |
2819
wget https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.deb

.golangci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
run:
44
allow-parallel-runners: true
5-
timeout: 30s
5+
timeout: 10m
66

77
linters:
88
enable:

Makefile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ VERSION_PACKAGE = github.com/replicatedhq/troubleshoot/pkg/version
77
VERSION ?=`git describe --tags --dirty`
88
DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
99
RUN?=""
10+
GOLANGCI_LINT_VERSION ?= "v1.61.0"
1011

1112
GIT_TREE = $(shell git rev-parse --is-inside-work-tree 2>/dev/null)
1213
ifneq "$(GIT_TREE)" ""
@@ -34,7 +35,8 @@ define LDFLAGS
3435
"
3536
endef
3637

37-
BUILDFLAGS = -tags "netgo containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp" -installsuffix netgo
38+
BUILDTAGS = "netgo containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp"
39+
BUILDFLAGS = -tags ${BUILDTAGS} -installsuffix netgo
3840
BUILDPATHS = ./pkg/... ./cmd/... ./internal/...
3941
E2EPATHS = ./test/e2e/...
4042
TESTFLAGS ?= -v -coverprofile cover.out
@@ -152,7 +154,7 @@ check-schemas: generate schemas
152154
fi
153155

154156
.PHONY: schemas
155-
schemas: fmt vet openapischema bin/schemagen
157+
schemas: openapischema bin/schemagen
156158
./bin/schemagen --output-dir ./schemas
157159

158160
bin/schemagen:
@@ -236,12 +238,16 @@ scan:
236238
./
237239

238240
.PHONY: lint
239-
lint:
240-
golangci-lint run --new -c .golangci.yaml ${BUILDPATHS}
241+
lint: vet
242+
golangci-lint run --new -c .golangci.yaml --build-tags ${BUILDTAGS} ${BUILDPATHS}
241243

242-
.PHONY: fmt lint-and-fix
243-
lint-and-fix:
244-
golangci-lint run --new --fix -c .golangci.yaml ${BUILDPATHS}
244+
.PHONY: lint-and-fix
245+
lint-and-fix: fmt vet
246+
golangci-lint run --new --fix -c .golangci.yaml --build-tags ${BUILDTAGS} ${BUILDPATHS}
247+
248+
.PHONY: install-golangci-lint
249+
install-golangci-lint:
250+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
245251

246252
.PHONY: watch
247253
watch: npm-install

0 commit comments

Comments
 (0)