From 9fc97a242133be44ba52f3f7f1614f98d830ebce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Mon, 20 May 2024 16:44:04 +0200 Subject: [PATCH] chore: setup pre-commit --- .github/workflows/ci.yaml | 2 -- .goreleaser.yaml | 4 --- .pre-commit-config.yaml | 57 +++++++++++++++++++++++++++++++++++++++ renovate.json | 3 +++ scripts/completions.sh | 2 +- 5 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e0191ca..8490870 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,7 +30,6 @@ jobs: args: --timeout 5m working-directory: hcloudimages - test: runs-on: ubuntu-latest steps: @@ -45,7 +44,6 @@ jobs: - name: Run tests run: go test -v -race -coverpkg=./...,./hcloudimages/... ./... ./hcloudimages/... - go-mod-tidy: runs-on: ubuntu-latest steps: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index ac3b3c2..c5e227e 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -76,7 +76,6 @@ nfpms: file_info: mode: 0644 - aurs: - name: hcloud-upload-image-bin homepage: "https://github.com/apricote/hcloud-upload-image" @@ -104,12 +103,9 @@ aurs: install -Dm644 "./completions/hcloud-upload-image.zsh" "${pkgdir}/usr/share/zsh/site-functions/_hcloud-upload-image" install -Dm644 "./completions/hcloud-upload-image.fish" "${pkgdir}/usr/share/fish/vendor_completions.d/hcloud-upload-image.fish" - snapshot: name_template: "{{ .Version }}-dev+{{ .ShortCommit }}" changelog: # Generated by release-please disable: true - - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9534ace --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,57 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-symlinks + - id: destroyed-symlinks + + - id: check-json + - id: check-yaml + - id: check-toml + + - id: check-merge-conflict + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.1.0 + hooks: + - id: prettier + files: \.(md|ya?ml)$ + exclude: CHANGELOG.md + + - repo: local + hooks: + - id: shfmt + name: shfmt + description: Format shell scripts with shfmt + language: golang + additional_dependencies: [mvdan.cc/sh/v3/cmd/shfmt@v3.7.0] + entry: shfmt -i 2 -ci -sr -kp -w + types: [shell] + + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck + + - repo: https://github.com/golangci/golangci-lint + rev: v1.58.2 + hooks: + - id: golangci-lint-full + name: golangci-lint cli + exclude: hcloudimages/ + - id: golangci-lint-full + name: golangci-lint lib + files: hcloudimages/ + + - repo: https://github.com/dnephin/pre-commit-golang + rev: v0.5.1 + hooks: + - id: go-mod-tidy diff --git a/renovate.json b/renovate.json index d970352..05d77fc 100644 --- a/renovate.json +++ b/renovate.json @@ -11,6 +11,9 @@ "gomodTidy", "gomodUpdateImportPaths" ], + "pre-commit": { + "enabled": true + }, "customManagers": [ { "customType": "regex", diff --git a/scripts/completions.sh b/scripts/completions.sh index 1d81d44..277d9da 100755 --- a/scripts/completions.sh +++ b/scripts/completions.sh @@ -3,5 +3,5 @@ set -e rm -rf completions mkdir completions for sh in bash zsh fish; do - go run . completion "$sh" >"completions/hcloud-upload-image.$sh" + go run . completion "$sh" > "completions/hcloud-upload-image.$sh" done