From 108ad3c7c39424e1e674520038f400f55ef83bb5 Mon Sep 17 00:00:00 2001 From: Nick Farrell Date: Sat, 17 Dec 2022 18:18:16 +1100 Subject: [PATCH] Add pre-commit hooks This will ensure that there is standard linting applied to files in the repository. It assists in avoiding conflicts due to different contributers' IDEs. It is recommended that contributers run the following: `pre-commit install -t pre-push -t pre-commit` --- .github/workflows/pre-commit.yml | 13 +++++++++++++ .pre-commit-config.yaml | 26 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..aa30ae02 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,13 @@ +name: pre-commit + +on: + pull_request: + push: + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..3ba457c1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +repos: + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v2.7.1" + hooks: + - id: prettier + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: end-of-file-fixer + stages: ["commit"] + - id: trailing-whitespace + stages: ["commit"] + + - repo: https://github.com/Bahjat/pre-commit-golang + rev: v1.0.2 + hooks: + - id: go-fmt-import + - id: go-vet + - id: go-lint + - id: go-unit-tests + stages: ["push"] + - id: gofumpt # requires github.com/mvdan/gofumpt + - id: golangci-lint # requires github.com/golangci/golangci-lint + args: [--config=.github/linters/.golangci.yml] # optional + - id: go-ruleguard # requires https://github.com/quasilyte/go-ruleguard + args: [rules/rules.go] # required