chore: setup pre-commit

This commit is contained in:
Julian Tölle 2024-05-20 16:44:04 +02:00
parent 043c73cf7d
commit 9fc97a2421
No known key found for this signature in database
GPG key ID: 23645912EA28C2DB
5 changed files with 61 additions and 7 deletions

View file

@ -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:

View file

@ -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

57
.pre-commit-config.yaml Normal file
View file

@ -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

View file

@ -11,6 +11,9 @@
"gomodTidy",
"gomodUpdateImportPaths"
],
"pre-commit": {
"enabled": true
},
"customManagers": [
{
"customType": "regex",

View file

@ -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