diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml new file mode 100644 index 0000000..2b3653f --- /dev/null +++ b/.github/workflows/precommit.yml @@ -0,0 +1,30 @@ +name: Pre-commit Checks + +on: + pull_request: + branches: [ main ] + +jobs: + Code-Checks: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.25.1' + cache: true + + - name: Cache pre-commit hooks + uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Install pre-commit + run: pip install pre-commit + + - name: Run pre-commit + continue-on-error: false + run: pre-commit run --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..cb2b668 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +exclude: ^vendor/|^bin/|^dist/ + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-yaml + exclude: \.tmpl$ + - id: check-json + exclude: \.tmpl$ + + - repo: https://github.com/golangci/golangci-lint + rev: v2.6.2 + hooks: + - id: golangci-lint + entry: golangci-lint run + + - repo: https://github.com/executablebooks/mdformat + rev: 0.7.19 + hooks: + - id: mdformat + additional_dependencies: + - mdformat-gfm + - mdformat-frontmatter + files: ^docs/