Skip to content

Commit

Permalink
feat(hooks): make a local golangci-lint hook (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
shakefu authored Sep 13, 2021
1 parent dfcdbcb commit 3dc1bd7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 11 additions & 3 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
######################
# Docker related hooks
- id: docker-lint
name: "hadolint: Dockerfile linting"
Expand All @@ -12,6 +13,7 @@
language: docker_image
entry: ghcr.io/turo/pre-commit-hooks/docker_compose:1.29.2
files: docker-compose\.([-_a-zA-Z0-9]+\.)*y(a)?ml$
######################
# Golang related hooks
# These run in a container and have no other dependencies
- id: gocyclo
Expand All @@ -32,9 +34,9 @@
entry: --entrypoint go-fmt.sh ghcr.io/turo/pre-commit-hooks/gotools:1.0.0
language: docker_image
files: '\.go$'
- id: golangci-lint
name: "golangci-lint: Lint all the things"
description: "Runs `golangci-lint`, a meta-linter which comprises many others"
- id: golangcilint
name: "golangcilint: Lint all the things (docker)"
description: "Runs `golangci-lint`, a meta-linter which comprises many others, in docker"
entry: ghcr.io/turo/pre-commit-hooks/golangci_lint:1.41.1
language: docker_image
files: \.go$
Expand Down Expand Up @@ -69,3 +71,9 @@
entry: hooks/golang/go-fmt.sh
language: 'script'
files: '\.go$'
- id: golangci-lint
name: "golangci-lint: Lint all the things"
description: "Runs `golangci-lint`, a meta-linter which comprises many others"
entry: hooks/golang/golangci-lint.sh
language: script
files: \.go$
5 changes: 4 additions & 1 deletion hooks/golang/go-test-unit.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env bash
FILES=$(go list ./... | grep -v /vendor/)

go test -tags=unit -timeout 30s -short -v ${FILES}
# We don't use build tags commonly enough, so we're just going to run all tests
# locally and let the tests use environment flags to run integration tests.
# go test -tags=unit -timeout 30s -short -v ${FILES}
go test -timeout 30s -short -v ${FILES}

returncode=$?
if [ $returncode -ne 0 ]; then
Expand Down
1 change: 0 additions & 1 deletion hooks/golang/golangci-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ main (){
exit $ret
}

# lint "./..."
main "$@"

0 comments on commit 3dc1bd7

Please sign in to comment.