Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add pre-commit on pr and fix cache linting #27

Merged
merged 11 commits into from
Jan 22, 2024
11 changes: 7 additions & 4 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
---
name: pre-commit
on:
push:
branches: ["*"]
branches: ["master"]
pull_request:
branches:
- master
jobs:
pre-commit:
permissions: read-all
runs-on: ubuntu-latest
container:
image: alpine:3.17
image: alpine:3.19
env:
GOPATH: ~/.cache/go
APK_CACHE_DIR: ~/.cache/apk
Expand All @@ -34,8 +38,7 @@ jobs:
apk update --cache-dir $APK_CACHE_DIR
apk add --cache-dir $APK_CACHE_DIR go python3-dev py3-pip gcc musl-dev
go install github.com/kisielk/[email protected]
go install honnef.co/go/tools/cmd/[email protected]
pip install pre-commit
pip install pre-commit --break-system-packages
- name: Run pre-commit-hooks
run: |
git config --global --add safe.directory $PWD
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin/
_output/
*.test
/.cache
16 changes: 7 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: check-added-large-files
- id: detect-private-key
- id: end-of-file-fixer
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.31.0
rev: v1.33.0
hooks:
- id: yamllint
args: [-c=.yaml-lint.yml]
- repo: https://github.com/golangci/golangci-lint
rev: v1.55.2
hooks:
- id: golangci-lint-full
- repo: https://github.com/Bahjat/pre-commit-golang
rev: v1.0.3
hooks:
- id: go-fmt-import
- id: go-vet
- id: go-lint
- id: go-err-check
- id: go-static-check
- id: go-unit-tests
- 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
- id: gofumpt # requires github.com/mvdan/gofumpt