Skip to content

Commit

Permalink
Merge pull request #217 from tariq1890/add-golangci-lint
Browse files Browse the repository at this point in the history
update golang and controller-tools versions, use golangci-lint
  • Loading branch information
elenz97 authored Sep 20, 2024
2 parents d0f42cc + 427c40a commit c98fd21
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.21
- name: Set up Go 1.23
uses: actions/setup-go@v4
with:
go-version: "1.21"
go-version: "1.23"

- uses: actions/checkout@v3

- name: Set up golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60.3
args: -v --timeout 5m
skip-cache: true

- name: Run go generate
run: |
set -x
Expand All @@ -22,15 +29,13 @@ jobs:
git diff | cat
git status --porcelain=v1
test $(git status --porcelain=v1 | wc -l) -eq 0
env:
GO111MODULE: on
build:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.21' ]
go: [ '1.23' ]

steps:
- uses: actions/checkout@v3
Expand All @@ -40,5 +45,12 @@ jobs:
with:
go-version: ${{ matrix.go }}

- name: Set up golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60.3
args: -v --timeout 5m
skip-cache: true

- name: Run unit tests
run: make test
20 changes: 20 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
run:
timeout: 10m

linters:
enable:
- contextcheck
- gocritic
- gofmt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- misspell
- staticcheck
- unconvert

linters-settings:
goimports:
local-prefixes: github.com/mittwald/go-helm-client
16 changes: 6 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,18 @@ help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)


.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code.
go vet ./...
.PHONY: lint
lint: ## Run golangci-lint against code.
golangci-lint run ./...

##@ Build

.PHONY: build
build: generate fmt vet ## Build binary.
build: generate lint ## Build binary.
go build -o bin/client .

.PHONY: test
test: generate fmt vet ## Run tests.
test: generate lint ## Run tests.
go test ./... -coverprofile cover.out

.PHONY: generate
Expand All @@ -55,7 +51,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen

## Tool Versions
MOCKGEN_VERSION ?= v0.4.0
CONTROLLER_TOOLS_VERSION ?= v0.13.0
CONTROLLER_TOOLS_VERSION ?= v0.16.1

.PHONY: mockgen
mockgen: $(MOCKGEN) ## Download mockgen locally if necessary.
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ func (c *HelmClient) RunChartTests(releaseName string) (bool, error) {
}

// Check that there are no test failures
return checkReleaseForTestFailure(rel) == false, nil
return !checkReleaseForTestFailure(rel), nil
}

// chartExists checks whether a chart is already installed
Expand Down

0 comments on commit c98fd21

Please sign in to comment.