Skip to content

Commit

Permalink
chore(workflow): install pre-commit
Browse files Browse the repository at this point in the history
My home-made commit-hook wasn't working.
  • Loading branch information
MrMarble committed Mar 12, 2022
1 parent 0068ef1 commit 794f83f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ linters:
- revive
- unconvert
- wsl
- gosec

linters-settings:
errcheck:
Expand Down
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v1.2.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
- repo: https://github.com/TekWizely/pre-commit-golang
rev: v1.0.0-beta.5
hooks:
- id: go-fumpt
- id: golangci-lint-mod
- id: go-test-mod
exclude: 'examples|testdata'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# termsvg

[![golangci-lint](https://github.com/MrMarble/termsvg/actions/workflows/golangci-lint.yml/badge.svg)](https://github.com/MrMarble/termsvg/actions/workflows/golangci-lint.yml)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/mrmarble/termsvg)
[![Go Reference](https://pkg.go.dev/badge/github.com/mrmarble/termsvg.svg)](https://pkg.go.dev/github.com/mrmarble/termsvg)

Expand Down
15 changes: 5 additions & 10 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ tasks:
dev:
desc: Setup pre-commit hook
cmds:
- |
echo "#!/bin/bash
FILES=\$(git diff --cached --name-only --diff-filter=ACMR)
gofumpt -l -w .
golangci-lint run --new --fix
git add $FILES" > .git/hooks/pre-commit
- pre-commit install
- pre-commit install --hook-type commit-msg
setup:
desc: Install dependencies
cmds:
Expand Down Expand Up @@ -63,9 +57,10 @@ tasks:
desc: Run all CI steps
cmds:
- task: setup
- task: build
- task: lint
- task: test

- task: build

default:
desc: Runs the default tasks
cmds:
Expand Down

0 comments on commit 794f83f

Please sign in to comment.