Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Refer to golangci-lint's example config file for more options and information:
# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml

version: 2

run:
timeout: 5m
modules-download-mode: readonly
Expand All @@ -9,22 +11,32 @@ linters:
enable:
- errcheck
- errname
- goimports
- govet
- prealloc
- predeclared
- revive
- staticcheck
- unused
exclusions:
rules:
- linters:
- revive
path: internal/exec/
text: "var-naming: avoid package names that conflict with Go standard library package names"
- linters:
- revive
path: internal/path/
text: "var-naming: avoid package names that conflict with Go standard library package names"

formatters:
enable:
- goimports

linters-settings:
revive:
rules:
- name: package-comments
disabled: true
enable-all-rules: true

issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0
exclude-dirs:
- .asdf
67 changes: 46 additions & 21 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,34 @@ includes:
dir: ./docs

tasks:
_fmt-deps:
internal: true
cmds:
- go get -tool mvdan.cc/gofumpt
- go get -tool github.com/segmentio/golines

_vet-deps:
internal: true
cmds:
- go get -tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint

_cov-deps:
internal: true
cmds:
- go get -tool github.com/boumenot/gocover-cobertura

_mockgen-deps:
internal: true
cmds:
- go get -tool github.com/golang/mock/mockgen

deps:
desc: Install dependencies
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- go install github.com/princjef/gomarkdoc/cmd/gomarkdoc@latest
- go install golang.org/x/vuln/cmd/govulncheck@latest
- go install github.com/jstemmer/go-junit-report@latest
- go install github.com/segmentio/golines@latest
- go install github.com/golang/mock/mockgen@latest
- go install github.com/boumenot/gocover-cobertura@latest
- go install mvdan.cc/gofumpt@latest
- go install github.com/goreleaser/goreleaser/v2@latest
- task: _fmt-deps
- task: _vet-deps
- task: _cov-deps
- task: _mockgen-deps
- go get github.com/bats-core/bats-core@latest
- bash $(go env GOMODCACHE)/$(go list -m github.com/bats-core/bats-core | tr ' ' @)/install.sh ./test/integration/vendor/bats

Expand All @@ -49,13 +65,15 @@ tasks:

vet:
desc: Report likely mistakes in packages
deps:
- _vet-deps
cmds:
- $(go env GOPATH)/bin/golangci-lint run --config {{ .GIT_ROOT }}/.golangci.yml
- go tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint run --config {{ .GIT_ROOT }}/.golangci.yml

vuln:
desc: Run Go's vulnerability scanner
cmds:
- govulncheck ./...
- go tool golang.org/x/vuln/cmd/govulncheck ./...

run:
desc: Compile and run Go program
Expand All @@ -77,7 +95,6 @@ tasks:
cmds:
- ./test/integration/vendor/bats/bin/bats test/integration


test:
desc: Test all
cmds:
Expand All @@ -90,10 +107,12 @@ tasks:

cov:
desc: Generate coverage
deps:
- _cov-deps
cmds:
# NOTE(nic): Exclude mocks and code covered by integration tests from coverage
- go test -race -coverprofile=cover.out -v $(go list ./... | grep -v /mocks | grep -v /cmd | grep -v /pkg/repositories | egrep -v 'v2$')
- gocover-cobertura < cover.out > cobertura.xml
- go tool github.com/boumenot/gocover-cobertura < cover.out > cobertura.xml
- go tool cover -func=cover.out

cov:map:
Expand All @@ -104,16 +123,20 @@ tasks:

fmt:
desc: Reformat files whose formatting differs from `go_fmt_command`
deps:
- _fmt-deps
cmds:
- gofumpt -l -w .
- golines --base-formatter=gofumpt -w .
- go tool mvdan.cc/gofumpt -l -w .
- go tool github.com/segmentio/golines --base-formatter="go tool mvdan.cc/gofumpt" -w .

fmt:check:
desc: Check files whose formatting differs from `go_fmt_command`
deps:
- _fmt-deps
cmds:
# https://github.com/mvdan/gofumpt/issues/114
- test -z "$(gofumpt -d -e . | tee /dev/stderr)"
- test -z "$(golines -l --dry-run --base-formatter=gofumpt -w .)"
- test -z "$(go tool mvdan.cc/gofumpt -d -e . | tee /dev/stderr)"
- test -z "$(go tool github.com/segmentio/golines --dry-run --base-formatter="go tool mvdan.cc/gofumpt" -l | tee /dev/stderr)"

build:
desc: Build ARCH compatible binary.
Expand All @@ -127,8 +150,10 @@ tasks:

mockgen:
desc: Generate mock for interface
deps:
- _mockgen-deps
cmds:
- mockgen -source=internal/git.go -destination=internal/mocks/git/git_mock.go -package=git
- mockgen -source=internal/repository.go -destination=internal/mocks/repository/repository_mock.go -package=repository
- mockgen -source=internal/exec.go -destination=internal/mocks/exec/exec_mock.go -package=exec
- mockgen -source=internal/repository/types.go -destination=internal/mocks/repository/copy_mock.go -package=repository
- go tool github.com/golang/mock/mockgen -source=internal/git.go -destination=internal/mocks/git/git_mock.go -package=git
- go tool github.com/golang/mock/mockgen -source=internal/repository.go -destination=internal/mocks/repository/repository_mock.go -package=repository
- go tool github.com/golang/mock/mockgen -source=internal/exec.go -destination=internal/mocks/exec/exec_mock.go -package=exec
- go tool github.com/golang/mock/mockgen -source=internal/repository/types.go -destination=internal/mocks/repository/copy_mock.go -package=repository
3 changes: 2 additions & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

// Package cmd implements the CLI commands for gilt.
package cmd

import (
Expand All @@ -39,7 +40,7 @@ var initCmd = &cobra.Command{
Short: "Initialize Gilt with a Giltfile",
Long: `Initializes Gilt by creating a default config file in the shell's
current working directory.`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
var b bytes.Buffer

// set configFile defaults
Expand Down
2 changes: 1 addition & 1 deletion cmd/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var overlayCmd = &cobra.Command{
Short: "Install Gilt dependencies",
Long: `Overlay the repositories from the Giltfile into their respective
destinations.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
// By the time we reach this point, we know that the arguments were
// properly parsed, and we don't want to show the usage if an error
// occurs
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var (
versionCmd = &cobra.Command{
Use: "version",
Short: "Display the version of tool",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
version := buildVersion(version, commit, date, builtBy, treeState)

jsonOut, _ := version.JSONString()
Expand Down
Loading
Loading