From 86c5754721ac51462a952ef8e1308b7488a968d7 Mon Sep 17 00:00:00 2001 From: arthurlw Date: Sat, 22 Nov 2025 21:21:59 -0800 Subject: [PATCH 1/5] Pre-commit config --- .pre-commit-config.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..15e9824 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +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-yaml + - id: check-added-large-files + + - 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 \ No newline at end of file From c0e2999f0a7b78e9773aa9cde009c5e463deba04 Mon Sep 17 00:00:00 2001 From: arthurlw Date: Sat, 22 Nov 2025 21:25:03 -0800 Subject: [PATCH 2/5] github workflow --- .github/workflows/precommit.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/precommit.yml diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml new file mode 100644 index 0000000..a1eef55 --- /dev/null +++ b/.github/workflows/precommit.yml @@ -0,0 +1,27 @@ +name: Pre-commit Checks + +on: + pull_request: + branches: [ main ] + +jobs: + auto-fix: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.23' + cache: true + + - name: Install pre-commit + run: pip install pre-commit + + - name: Run pre-commit + continue-on-error: true + run: pre-commit run --all-files --show-diff-on-failure From 7784376f80010f6506497ea5799b81c5fe8a8259 Mon Sep 17 00:00:00 2001 From: arthurlw Date: Sat, 22 Nov 2025 21:29:30 -0800 Subject: [PATCH 3/5] Updated workflow --- .github/workflows/precommit.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index a1eef55..322c5ac 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -5,18 +5,15 @@ on: branches: [ main ] jobs: - auto-fix: + Code-Checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - + - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.23' + go-version: '1.25.1' cache: true - name: Install pre-commit From f4b5d6e5cf3d7de5263d1cdc626a79bb48bd0d61 Mon Sep 17 00:00:00 2001 From: arthurlw Date: Sat, 22 Nov 2025 21:39:15 -0800 Subject: [PATCH 4/5] Update continue on error and run command --- .github/workflows/precommit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 322c5ac..a542bae 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -20,5 +20,5 @@ jobs: run: pip install pre-commit - name: Run pre-commit - continue-on-error: true - run: pre-commit run --all-files --show-diff-on-failure + continue-on-error: false + run: pre-commit run --all-files From 0883bd8b912d6b04d676689715093def8413ae49 Mon Sep 17 00:00:00 2001 From: arthurlw Date: Sun, 23 Nov 2025 19:12:07 -0800 Subject: [PATCH 5/5] Caching + more hooks --- .github/workflows/precommit.yml | 6 ++++++ .pre-commit-config.yaml | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index a542bae..2b3653f 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -16,6 +16,12 @@ jobs: 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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 15e9824..cb2b668 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,18 @@ +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-yaml - 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 @@ -19,4 +26,5 @@ repos: - id: mdformat additional_dependencies: - mdformat-gfm - - mdformat-frontmatter \ No newline at end of file + - mdformat-frontmatter + files: ^docs/