Skip to content

Commit

Permalink
chore: Explicitly run make lint (#1645)
Browse files Browse the repository at this point in the history
* 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 <evans@replicated.com>

* Add setup env step

Signed-off-by: Evans Mungai <evans@replicated.com>

* Add build-tags to golangci-lint command

Signed-off-by: Evans Mungai <evans@replicated.com>

---------

Signed-off-by: Evans Mungai <evans@replicated.com>
  • Loading branch information
banjoh authored Oct 9, 2024
1 parent 8105fa0 commit 402d111
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/build-test-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,32 @@ concurrency:
jobs:
fail_if_pull_request_is_draft:
if: github.event.pull_request.draft == true
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Fails in order to indicate that pull request needs to be marked as ready to review and unit tests workflow needs to pass.
run: exit 1

test:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: setup env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
shell: bash

- uses: actions/checkout@v4

- run: make test
- name: Run linters
run: make install-golangci-lint lint
- name: Run tests
run: make test

test-integration:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/license.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Install Go deps
run: go mod download

- name: Install trivy
run: |
wget https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.deb
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

run:
allow-parallel-runners: true
timeout: 30s
timeout: 10m

linters:
enable:
Expand Down
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ VERSION_PACKAGE = github.com/replicatedhq/troubleshoot/pkg/version
VERSION ?=`git describe --tags --dirty`
DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
RUN?=""
GOLANGCI_LINT_VERSION ?= "v1.61.0"

GIT_TREE = $(shell git rev-parse --is-inside-work-tree 2>/dev/null)
ifneq "$(GIT_TREE)" ""
Expand Down Expand Up @@ -34,7 +35,8 @@ define LDFLAGS
"
endef

BUILDFLAGS = -tags "netgo containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp" -installsuffix netgo
BUILDTAGS = "netgo containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp"
BUILDFLAGS = -tags ${BUILDTAGS} -installsuffix netgo
BUILDPATHS = ./pkg/... ./cmd/... ./internal/...
E2EPATHS = ./test/e2e/...
TESTFLAGS ?= -v -coverprofile cover.out
Expand Down Expand Up @@ -152,7 +154,7 @@ check-schemas: generate schemas
fi

.PHONY: schemas
schemas: fmt vet openapischema bin/schemagen
schemas: openapischema bin/schemagen
./bin/schemagen --output-dir ./schemas

bin/schemagen:
Expand Down Expand Up @@ -236,12 +238,16 @@ scan:
./

.PHONY: lint
lint:
golangci-lint run --new -c .golangci.yaml ${BUILDPATHS}
lint: vet
golangci-lint run --new -c .golangci.yaml --build-tags ${BUILDTAGS} ${BUILDPATHS}

.PHONY: fmt lint-and-fix
lint-and-fix:
golangci-lint run --new --fix -c .golangci.yaml ${BUILDPATHS}
.PHONY: lint-and-fix
lint-and-fix: fmt vet
golangci-lint run --new --fix -c .golangci.yaml --build-tags ${BUILDTAGS} ${BUILDPATHS}

.PHONY: install-golangci-lint
install-golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}

.PHONY: watch
watch: npm-install
Expand Down

0 comments on commit 402d111

Please sign in to comment.