chore: fix CI workflow, golangci-lint config, and minor lint/format issues

- Add checkout and setup-go steps to Gitea CI workflow, use make targets
- Exclude errcheck for test files in golangci-lint config
- Fix staticcheck QF1002 (tagged switch) in repo_test.go
- Fix gofmt trailing newline in triage_rules_test.go

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
wbtiger 2026-05-31 22:45:17 +08:00
parent 5a266867b5
commit 1bf16d31db
4 changed files with 18 additions and 16 deletions

View File

@ -8,23 +8,23 @@ on:
jobs:
check:
name: Build, Test, Vet
name: Build, Lint, Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Build
run: go build ./...
- name: Test
run: go test -race ./...
- name: Lint
run: make lint
- name: Vet
run: go vet ./...
- name: Test
run: make test
- name: Check formatting
run: |
unformatted=$(gofmt -s -l .)
if [ -n "$unformatted" ]; then
echo "Files not formatted:"
echo "$unformatted"
exit 1
fi
run: make fmt

View File

@ -45,6 +45,9 @@ linters:
# Best-effort output rendering
- linters: [errcheck]
path: render\.go$
# errcheck: test helpers intentionally ignore return values
- linters: [errcheck]
path: _test\.go$
# errorlint: type assertions are fine in tests
- linters: [errorlint]
path: _test\.go$

View File

@ -179,13 +179,13 @@ func TestRepoCreate(t *testing.T) {
func TestRepoCreateWithOptions(t *testing.T) {
var body map[string]interface{}
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch {
case r.URL.Path == "/users/me.json":
switch r.URL.Path {
case "/users/me.json":
writeJSON(w, map[string]interface{}{
"login": "creator",
"user_id": float64(42),
})
case r.URL.Path == "/creator/my-repo.json":
case "/creator/my-repo.json":
json.NewDecoder(r.Body).Decode(&body)
writeJSON(w, map[string]interface{}{"name": "my-repo"})
default:

View File

@ -156,4 +156,3 @@ func TestRecommendedAction(t *testing.T) {
})
}
}