From 6e945a73924439d85030a9b4c51c4f144397cb07 Mon Sep 17 00:00:00 2001 From: Doug Gschwind Date: Mon, 11 Sep 2023 15:30:20 -0700 Subject: [PATCH] feat: drop support for golangcilint BREAKING CHANGE: Use golangci-lint hook rather than golangcilint. --- .pre-commit-hooks.yaml | 6 ------ README.md | 10 ++++------ containers/golangci_lint/Dockerfile | 15 --------------- containers/golangci_lint/docker-compose.yaml | 6 ------ docs/breaking-changes/v4.md | 4 ++++ versions.env | 1 - 6 files changed, 8 insertions(+), 34 deletions(-) delete mode 100644 containers/golangci_lint/Dockerfile delete mode 100644 containers/golangci_lint/docker-compose.yaml create mode 100644 docs/breaking-changes/v4.md diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 3691363..7efb3f6 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -34,12 +34,6 @@ entry: --entrypoint go-fmt.sh ghcr.io/turo/pre-commit-hooks/gotools:1.0.0 language: docker_image files: '\.go$' -- 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.43.0 - language: docker_image - files: \.go$ # Hooks that run locally only, and require golang - id: go-test-unit name: "go-test-unit: Run tagged unit tests" diff --git a/README.md b/README.md index 536e52b..9c19b12 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,12 @@ This section tells you how to install. First you must have [pre-commit](https://pre-commit.com/) installed and configured. -The pre-commit hooks which start with `go-` require that the [golang environment +The pre-commit hooks in this section require that the [golang environment be installed](https://golang.org/doc/install) to run successfully: - go-test-unit - go-build +- golangci-lint - go-mod-tidy - go-vet - go-fmt @@ -39,7 +40,6 @@ installed](https://docs.docker.com/get-docker/) to run successfully: - gocyclo - goimports - gofmt -- golangci-lint ### Hooks installation @@ -49,7 +49,7 @@ in this example, some of the hooks enabled would be redundant. ```yaml repos: - repo: https://github.com/turo/pre-commit-hooks - rev: v3.0.0 # You may version pin this if desired + rev: v3.5.0 # You may version pin this if desired hooks: - id: go-test-unit - id: go-build @@ -77,8 +77,6 @@ The following hooks are available: other linters, may be slow to run the first time, but uses caching within the repository to speed up the container on subsequent runs. **This should be your preferred Golang linter unless its just plain too slow.** -- **golangcilint** (_requires docker_) - Same as golangci-lint, but runs in a - docker container. - **gocyclo** (_requires docker_) - Cyclomatic complexity checker - **goimports** (_requres docker_) - Superceded `go fmt` as the Go style formatter - **gofmt** (_requires docker_) - Original Go style formatter, a bit more relaxed @@ -103,7 +101,7 @@ A typical `pre-commit-config.yaml` for a Golang project would look like this: ```yaml repos: - repo: https://github.com/turo/pre-commit-hooks - rev: v3.0.0 # You may version pin this if desired + rev: v3.5.0 # You may version pin this if desired hooks: - id: go-mod-tidy # Clean up go.mod - id: go-build # Check compilation diff --git a/containers/golangci_lint/Dockerfile b/containers/golangci_lint/Dockerfile deleted file mode 100644 index 5fa3a2a..0000000 --- a/containers/golangci_lint/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# Args for images -ARG golangci_lint_version - -# golangci-lint needs a full go env for it to work, so we just derive our image -FROM golangci/golangci-lint:v${golangci_lint_version} AS bin -# Associate this image with our repository -LABEL org.opencontainers.image.source https://github.com/turo/pre-commit-hooks -# Make our cache directory -RUN mkdir /.cache && chmod a+rwx /.cache -# Copy in our pre-commit hook -COPY hooks/golang/golangci-lint.sh /bin -# Force HOME to /src so we can cache packages in the external volume -ENV HOME=/src -# Set our hook entrypoint -ENTRYPOINT ["/bin/golangci-lint.sh"] diff --git a/containers/golangci_lint/docker-compose.yaml b/containers/golangci_lint/docker-compose.yaml deleted file mode 100644 index 7c0a3be..0000000 --- a/containers/golangci_lint/docker-compose.yaml +++ /dev/null @@ -1,6 +0,0 @@ -version: '3.8' -services: - generic: - build: - args: - - golangci_lint_version diff --git a/docs/breaking-changes/v4.md b/docs/breaking-changes/v4.md new file mode 100644 index 0000000..83357a8 --- /dev/null +++ b/docs/breaking-changes/v4.md @@ -0,0 +1,4 @@ +# Breaking Changes in v4 + +The `golangcilint` hook will no longer be supported in favor of using the `golangci-lint` hook instead. The latter +is put in place via the `packer-github-actions-general` repo. diff --git a/versions.env b/versions.env index 214b778..fa326e7 100644 --- a/versions.env +++ b/versions.env @@ -4,7 +4,6 @@ docker_compose_version=1.29.2 gocyclo_version=0.3.1 goimports_version=0.1.5 golang_version=1.16-buster -golangci_lint_version=1.43.0 gosec_version=2.8.1 gotools_version=1.0.0 pre_commit_version=2.13.0