diff --git a/.circleci/config.yml b/.circleci/config.yml index cb2768e0..c0a066ab 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,8 +4,7 @@ jobs: unit_test: machine: enabled: true - image: ubuntu-2004:202111-02 - resource_class: small + image: ubuntu-2204:2023.02.1 steps: - checkout - run: @@ -16,7 +15,6 @@ jobs: pip install tox tox - workflows: version: 2 test: diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index d181832c..76e78365 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -76,6 +76,15 @@ files: \.go$ exclude: vendor\/.*$ +- id: golangci-lint + name: golangci-lint + description: golangci-lint is a Go linters aggregator + entry: hooks/golangci-lint.sh + language: script + language: script + files: \.go$ + require_serial: true + - id: yapf name: yapf description: yapf (Yet Another Python Formatter) is a python formatter from Google diff --git a/README.md b/README.md index 429c5628..363a4fd8 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,8 @@ supported hooks are: * **shellcheck**: Run [`shellcheck`](https://www.shellcheck.net/) to lint files that contain a bash [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)). * **gofmt**: Automatically run `gofmt` on all Golang code (`*.go` files). * **goimports**: Automatically run `goimports` on all Golang code (`*.go` files). -* **golint**: Automatically run `golint` on all Golang code (`*.go` files). +* **golint**: Automatically run `golint` on all Golang code (`*.go` files). [**DEPRECATED**]: Please use `golangci-lint` below. +* **golangci-lint**: Automatically run `golangci-lint` on all Golang code (`*.go` files). * **yapf**: Automatically run [`yapf`](https://github.com/google/yapf) on all python code (`*.py` files). * **helmlint** Automatically run [`helm lint`](https://helm.sh/docs/helm/helm_lint/) on your Helm chart files. [See caveats here](#helm-lint-caveats). * **markdown-link-check** Automatically run [markdown-link-check](https://github.com/tcort/markdown-link-check) on diff --git a/hooks/golangci-lint.sh b/hooks/golangci-lint.sh new file mode 100755 index 00000000..b6d35cc6 --- /dev/null +++ b/hooks/golangci-lint.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e + +# OSX GUI apps do not pick up environment variables the same way as Terminal apps and there are no easy solutions, +# especially as Apple changes the GUI app behavior every release (see https://stackoverflow.com/q/135688/483528). As a +# workaround to allow GitHub Desktop to work, add this (hopefully harmless) setting here. +original_path=$PATH +export PATH=$PATH:/usr/local/bin + +# Store and return last failure from fmt so this can validate every directory passed before exiting +FMT_ERROR=0 + +for file in "$@"; do + golangci-lint run --new-from-rev HEAD "$file" || FMT_ERROR=$? +done + +# reset path to the original value +export PATH=$original_path + +exit ${FMT_ERROR} diff --git a/test/.python-version b/test/.python-version index f4f3171d..d98960e2 100644 --- a/test/.python-version +++ b/test/.python-version @@ -1 +1 @@ -2.7.18:3.9.7 +2.7.18:3.11.1 diff --git a/test/tox.ini b/test/tox.ini index 6f7833c1..fec17471 100644 --- a/test/tox.ini +++ b/test/tox.ini @@ -1,6 +1,6 @@ [tox] skipsdist = True -envlist = py27,py39 +envlist = py27,py311 [testenv] deps =