Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/actions/go-checks/action.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
---
name: 'Go Code Quality Checks'
description: 'Runs Go code quality checks (formatting, linting, testing).'
name: "Go Code Quality Checks"
description: "Runs Go code quality checks (formatting, linting, testing)."
inputs:
go-version:
description: 'The Go version to use.'
description: "The Go version to use."
required: false
default: 'stable'
default: "stable"
golangci-lint-version:
description: "The golangci-lint version to use."
required: false
default: "latest"
working-directory:
description: 'Directory where Go code is located.'
description: "Directory where Go code is located."
required: false
default: '.'
default: "."
token:
description: 'GITHUB_TOKEN for API operations (reporting).'
description: "GITHUB_TOKEN for API operations (reporting)."
required: true
outputs:
go-status:
Expand Down Expand Up @@ -79,7 +83,8 @@ runs:
uses: golangci/golangci-lint-action@v6
continue-on-error: true
with:
version: latest
version: ${{ inputs.golangci-lint-version }}
install-mode: goinstall
working-directory: ${{ inputs.working-directory }}
args: --timeout=5m

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/reusables-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on: # yamllint disable-line rule:truthy
required: false
type: string
default: "stable"
golangci-lint-version:
description: "The golangci-lint version to use"
required: false
type: string
default: "latest"
working-directory:
description: "Directory where Go code is located"
required: false
Expand Down Expand Up @@ -47,5 +52,6 @@ jobs:
uses: sessatakuma/org-workflows/.github/actions/go-checks@main
with:
go-version: ${{ inputs.go-version }}
golangci-lint-version: ${{ inputs.golangci-lint-version }}
working-directory: ${{ inputs.working-directory }}
token: ${{ secrets.CHECKER_TOKEN }}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
# Requires: Go project with go.mod file (golangci-lint config optional)
# Checks: go mod tidy, golangci-lint, tests (race detector), build
run-go-checks: false
go-version: 'stable'
golangci-lint-version: 'latest'
```

就是這樣!您的 PR 現在會自動執行這些檢查並在留言中回報結果。
Expand All @@ -67,6 +69,7 @@ jobs:
| `run-frontend-checks` | `boolean` | 是否執行前端品質檢查 (Prettier, ESLint)。 | `false` |
| `run-go-checks` | `boolean` | 是否執行 Go 品質檢查 (Lint, Test, Build)。 | `false` |
| `go-version` | `string` | 使用的 Go 版本 (例如 `1.21` 或 `stable`)。 | `'stable'` |
| `golangci-lint-version` | `string` | 使用的 golangci-lint 版本。 | `'latest'` |
| `go-working-directory` | `string` | Go 專案的工作目錄 (若不在根目錄時使用)。 | `'.'` |
| `run-config-checks` | `boolean` | 是否驗證 YAML, JSON, TOML 檔案語法。 | `false` |

Expand Down