diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 233b996..095c62f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,4 +1,4 @@ -name: Go +name: CI on: push: @@ -12,13 +12,13 @@ permissions: pull-requests: read jobs: - build: + test: strategy: fail-fast: false matrix: go: [stable, oldstable] os: [macos-latest, windows-latest, ubuntu-latest] - name: build + name: test runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v7 @@ -30,6 +30,17 @@ jobs: run: go build -v ./... - name: Test run: mise run test + check: + name: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-go@v6 + with: + go-version: stable + - uses: jdx/mise-action@v4 + - name: pre-commit + run: prek run --all-files coverage: name: coverage permissions: @@ -37,7 +48,7 @@ jobs: concurrency: group: coverage runs-on: ubuntu-latest - needs: [build] + needs: [test] steps: - name: Update coverage report uses: ncruces/go-coverage-report@v0 diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml deleted file mode 100644 index fcabaa3..0000000 --- a/.github/workflows/golangci-lint.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: golangci-lint - -on: - push: - branches: [ "main" ] - tags: [ "*" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - pull-requests: read - checks: write - -jobs: - golangci: - strategy: - matrix: - go: [stable, oldstable] - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: actions/setup-go@v6 - with: - go-version: ${{ matrix.go }} - - name: golangci-lint - uses: golangci/golangci-lint-action@v9 - with: - version: latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 49dd070..746754b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,3 @@ -ci: - skip: [golangci-lint-full, go-test] - repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 @@ -8,15 +5,17 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/golangci/golangci-lint - rev: v2.12.2 - hooks: - - id: golangci-lint-full - repo: local hooks: + - id: golangci-lint + name: golangci-lint + language: system + types_or: [go] + pass_filenames: false + entry: mise run lint - id: go-test name: go test ./... - language: golang + language: system types_or: [go] pass_filenames: false entry: mise run test diff --git a/CLAUDE.md b/CLAUDE.md index 519d7cf..a22aced 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -13,7 +13,8 @@ also vendored into `golangci-lint` (since v1.58.0). - Run tests: `mise run test` (`go test -race -v ./...`) - Run a single test: `go test -race -run TestSuggestedFixes ./pkg/analyzer/` -- Lint (runs pre-commit, incl. golangci-lint + tests): `mise run lint` +- Lint (golangci-lint with autofix): `mise run lint` +- Run the full hook suite (file hooks + golangci-lint + tests): `prek run --all-files` - Build the CLI: `go build ./cmd/fatcontext` - Release: push a git tag (`git tag -a vX.Y.Z -m "vX.Y.Z" && git push --follow-tags`), which triggers GoReleaser via GitHub Actions. diff --git a/mise.toml b/mise.toml index 0ed72a8..b7ae9e1 100644 --- a/mise.toml +++ b/mise.toml @@ -1,8 +1,17 @@ [env] CGO_ENABLED = 1 -[tasks.lint] -run = "pre-commit run --all-files" +[tools] +golangci-lint = "2.12.2" +goreleaser = "2" +prek = "latest" [tasks.test] run = "go test -race -v ./..." + +[tasks.lint] +run = "golangci-lint run --fix" + +# Test a release locally without pushing a tag. +[tasks.release-snapshot] +run = "goreleaser release --snapshot --clean"