Skip to content

Commit

Permalink
Update CI and pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Dec 9, 2024
1 parent 5200d71 commit 18e73d7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
42 changes: 12 additions & 30 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,31 @@ name: Go

on: [push, pull_request]

env:
GOTOOLCHAIN: local

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: [1.19]
go-version: ["1.22", "1.23"]
name: Lint ${{ matrix.go-version == '1.23' && 'latest' || 'old' }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Install goimports
- name: Install dependencies
run: |
go install golang.org/x/tools/cmd/goimports@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
export PATH="$HOME/go/bin:$PATH"
- name: Install pre-commit
run: pip install pre-commit

- name: Lint
run: pre-commit run -a

build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: [1.18, 1.19]

steps:
- uses: actions/checkout@v3

- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
- name: Run pre-commit
uses: pre-commit/[email protected]
12 changes: 10 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude_types: [markdown]
Expand All @@ -9,6 +9,14 @@ repos:
- id: check-added-large-files

- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-beta.5
rev: v1.0.0-rc.1
hooks:
- id: go-imports-repo
args:
- "-local"
- "maunium.net/go/mauview"
- "-w"
- id: go-mod-tidy
- id: go-vet-repo-mod
# TODO fix and enable this
#- id: go-staticcheck-repo-mod

0 comments on commit 18e73d7

Please sign in to comment.