Skip to content

Commit 649d196

Browse files
committed
ci: add GitHub Actions workflow and golangci-lint config
Workflow jobs: - lint: runs golangci-lint - test: runs tests with race detection and coverage - build: builds on Linux, macOS, Windows Linters enabled: - errcheck, govet, staticcheck, unused, gosimple - ineffassign, typecheck, gofmt, goimports - misspell, gosec Makefile additions: - lint: run golangci-lint locally - ci: run lint + test + build - tools: install golangci-lint
1 parent 17c1b25 commit 649d196

3 files changed

Lines changed: 104 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
name: Lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version-file: go.mod
22+
23+
- name: golangci-lint
24+
uses: golangci/golangci-lint-action@v6
25+
with:
26+
version: latest
27+
28+
test:
29+
name: Test
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- uses: actions/setup-go@v5
35+
with:
36+
go-version-file: go.mod
37+
38+
- name: Run tests
39+
run: go test -v -race -coverprofile=coverage.out ./...
40+
41+
- name: Upload coverage
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: coverage
45+
path: coverage.out
46+
47+
build:
48+
name: Build
49+
runs-on: ${{ matrix.os }}
50+
strategy:
51+
matrix:
52+
os: [ubuntu-latest, macos-latest, windows-latest]
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- uses: actions/setup-go@v5
57+
with:
58+
go-version-file: go.mod
59+
60+
- name: Build
61+
run: go build -v ./...

.golangci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
run:
2+
timeout: 5m
3+
4+
linters:
5+
enable:
6+
- errcheck
7+
- govet
8+
- staticcheck
9+
- unused
10+
- gosimple
11+
- ineffassign
12+
- typecheck
13+
- gofmt
14+
- goimports
15+
- misspell
16+
- gosec
17+
18+
linters-settings:
19+
errcheck:
20+
check-type-assertions: true
21+
check-blank: true
22+
govet:
23+
enable:
24+
- shadow
25+
gosec:
26+
excludes:
27+
- G204 # Subprocess launched with variable - we intentionally shell out to git/gh
28+
29+
issues:
30+
exclude-use-default: false
31+
max-issues-per-linter: 0
32+
max-same-issues: 0

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build test install clean
1+
.PHONY: build test lint install clean
22

33
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
44
LDFLAGS := -ldflags "-X github.com/boneskull/gh-stack/cmd.version=$(VERSION)"
@@ -9,6 +9,12 @@ build:
99
test:
1010
go test ./... -v
1111

12+
lint:
13+
golangci-lint run ./...
14+
15+
# Run all checks (what CI does)
16+
ci: lint test build
17+
1218
install:
1319
go install $(LDFLAGS) .
1420

@@ -19,3 +25,7 @@ clean:
1925
gh-install: build
2026
mkdir -p ~/.local/share/gh/extensions/gh-stack
2127
cp gh-stack ~/.local/share/gh/extensions/gh-stack/
28+
29+
# Install development tools
30+
tools:
31+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

0 commit comments

Comments
 (0)