diff --git a/.github/internal/plans/MASTER.md b/.github/internal/plans/MASTER.md index 90746eb..15c2934 100644 --- a/.github/internal/plans/MASTER.md +++ b/.github/internal/plans/MASTER.md @@ -34,8 +34,8 @@ Each item links to its detailed implementation plan. | S1 | Commit Validation | 🟢 | [sdlc/01-commit-validation.md](sdlc/01-commit-validation.md) | Lefthook + Go commitlint | | S2 | Changelog Automation | ⏭️ | — | Auto-generate CHANGELOG.md from commits | | S3 | Release Workflow | ⏭️ | — | GitHub Actions with goreleaser | -| S4 | Pre-commit Hooks | ⏭️ | — | Run fmt/lint before commit | -| S5 | Test Coverage | ⏭️ | — | Coverage reporting in CI | +| S4 | Pre-commit Hooks | 🟢 | — | Run fmt/lint before commit | +| S5 | Test Coverage | 🟢 | — | Coverage reporting in CI | --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08a3e06..82b166c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,15 @@ on: pull_request: jobs: + pr-title: + name: Validate PR Title + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + lint: runs-on: ubuntu-latest steps: diff --git a/lefthook.yml b/lefthook.yml index 7dbcd57..443d49b 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -1,6 +1,31 @@ # Lefthook configuration for git hooks # Setup: make setup-hooks +pre-commit: + parallel: true + commands: + gofmt: + glob: "*.go" + run: | + if [ -z "{staged_files}" ]; then exit 0; fi + unformatted="$(gofmt -l {staged_files})" || exit $? + test -z "$unformatted" + fail_text: "Files need formatting. Run 'make fmt'" + + goimports: + glob: "*.go" + run: | + if [ -z "{staged_files}" ]; then exit 0; fi + unformatted="$(goimports -l {staged_files})" || exit $? + test -z "$unformatted" + fail_text: "Imports need formatting. Run 'make fmt'" + + golangci-lint: + glob: "*.go" + run: | + if [ -z "{staged_files}" ]; then exit 0; fi + golangci-lint run {staged_files} + commit-msg: commands: commitlint: