Skip to content

Commit

Permalink
Linting workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-spencer committed Nov 15, 2024
1 parent 6d25dc1 commit ff9bac5
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
Empty file added .codespellignore
Empty file.
32 changes: 32 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: linting

on: ["push", "pull_request"]

jobs:
ci:
name: "run linting"
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest"]
go: ["1.23.x"]
runs-on: ${{ matrix.os }}
steps:
- name: "checkout"
uses: actions/checkout@v2
- name: "fetch unshallow"
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: "fmt"
run: if [ "$(go fmt ./... | wc -l)" -gt 0 ]; then echo "go fmt failed, please run again locally"; exit 1; fi
if: matrix.os == 'ubuntu-latest'
- name: "imports"
run: if [ "$(goimports -l . | wc -l)" -gt 0 ]; then echo "goimports failed, please run again locally"; exit 1; fi
- name: "vet"
run: "go vet ./..."
- run: "go install honnef.co/go/tools/cmd/staticcheck@latest"
- name: staticcheck
run: "staticcheck ./..."
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: linting

on: ["push", "pull_request"]

jobs:
ci:
name: "run linting"
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "windows-latest", "macOS-latest"]
go: ["1.22.x", "1.23.x"]
runs-on: ${{ matrix.os }}
steps:
- name: "checkout"
uses: actions/checkout@v2
- name: "fetch unshallow"
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: "test"
run: "go test ./..."
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
- id: check-json
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-case-conflict
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.42.0
hooks:
- id: markdownlint
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: [-I, .codespellignore]
17 changes: 17 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# CLI helpers.

# help
help:
@echo "Command line helpers for this project.\n"
@just -l

# Run go linting
linting:
goimports -w .
go fmt .
- go vet .
- staticcheck .

# Run pre-commit
all-checks:
pre-commit run --all-files

0 comments on commit ff9bac5

Please sign in to comment.