Skip to content

Commit e59bb19

Browse files
Try out mise as a task runner
1 parent 08bbcc6 commit e59bb19

7 files changed

Lines changed: 103 additions & 127 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
# Task
2121
!Taskfile.yml
2222

23+
# mise
24+
!mise.toml
25+
2326
# Git
2427
!.gitattributes
2528
!.gitignore

Taskfile.yml

Lines changed: 0 additions & 127 deletions
This file was deleted.

docs/img/cancel.gif

76 Bytes
Loading

docs/img/namedargs.gif

999 Bytes
Loading

docs/img/quickstart.gif

-28 Bytes
Loading

docs/img/subcommands.gif

-859 Bytes
Loading

mise.toml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
[tools]
2+
go = "1.26"
3+
golangci-lint = "latest"
4+
typos = "latest"
5+
vhs = "latest"
6+
"aqua:charmbracelet/freeze" = "latest"
7+
fd = "latest"
8+
"go:go.uber.org/nilaway/cmd/nilaway" = "latest"
9+
"go:golang.org/x/pkgsite/cmd/pkgsite" = "latest"
10+
11+
[vars]
12+
COV_DATA = "coverage.out"
13+
14+
[tasks.tidy]
15+
description = "Tidy dependencies in go.mod and go.sum"
16+
run = "go mod tidy"
17+
sources = ["**/*.go", "go.mod", "go.sum"]
18+
19+
[tasks.fmt]
20+
description = "Run go fmt on all source files"
21+
run = "golangci-lint fmt ./..."
22+
sources = ["**/*.go", ".golangci.yml", "**/*.md"]
23+
24+
[tasks.test]
25+
description = "Run the test suite"
26+
usage = '''
27+
arg "[args]..." help="Extra args to pass to go test"
28+
'''
29+
# -race needs CGO (https://go.dev/doc/articles/race_detector#Requirements)
30+
env = { CGO_ENABLED = "1" }
31+
run = "go test -race ./... {{arg(name='args', default='')}}"
32+
sources = ["**/*.go", "**/testdata/**/*", "go.mod", "go.sum"]
33+
34+
[tasks.bench]
35+
description = "Run all project benchmarks"
36+
usage = '''
37+
arg "[args]..." help="Extra args to pass to go test"
38+
'''
39+
run = "go test ./... -run None -benchmem -bench . {{arg(name='args', default='')}}"
40+
sources = ["**/*.go"]
41+
42+
[tasks.lint]
43+
description = "Run the linters and auto-fix if possible"
44+
depends = ["fmt"]
45+
run = [
46+
"golangci-lint run --fix",
47+
"typos",
48+
"nilaway ./...",
49+
]
50+
sources = ["**/*.go", ".golangci.yml"]
51+
52+
[tasks.docs]
53+
description = "Render the pkg docs locally"
54+
raw = true
55+
run = "pkgsite -open"
56+
57+
[tasks.demo]
58+
description = "Render the demo gifs in parallel"
59+
run = [
60+
'for file in ./docs/src/*.tape; do vhs "$file" & done; wait',
61+
"freeze ./examples/cover/main.go --config ./docs/src/freeze.json --output ./docs/img/demo.png --show-line-numbers",
62+
]
63+
sources = ["./docs/src/*.tape", "**/*.go"]
64+
outputs = ["./docs/img/*.gif", "./docs/img/demo.png"]
65+
66+
[tasks.cov]
67+
description = "Calculate test coverage (pass --open to view as HTML in a browser)"
68+
usage = '''
69+
flag "--open" help="Open the coverage report in a browser"
70+
'''
71+
run = '''
72+
go test -race -cover -covermode atomic -coverprofile {{vars.COV_DATA}} ./...
73+
if [ "${usage_open:-false}" = "true" ]; then
74+
go tool cover -html {{vars.COV_DATA}}
75+
fi
76+
'''
77+
sources = ["**/*.go", "**/testdata/**/*", "go.mod", "go.sum"]
78+
outputs = ["{{vars.COV_DATA}}"]
79+
80+
[tasks.check]
81+
description = "Run tests and linting in one"
82+
depends = ["test", "lint"]
83+
84+
[tasks.sloc]
85+
description = "Print lines of code"
86+
run = "fd . -e go | xargs wc -l | sort -nr | head"
87+
88+
[tasks.clean]
89+
description = "Remove build artifacts and other clutter"
90+
run = [
91+
"go clean ./...",
92+
"rm -rf *.out",
93+
]
94+
95+
[tasks.update]
96+
description = "Updates dependencies in go.mod and go.sum"
97+
run = [
98+
"go get -u ./...",
99+
"go mod tidy",
100+
]

0 commit comments

Comments
 (0)