-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTaskfile.yml
More file actions
109 lines (91 loc) · 3.78 KB
/
Copy pathTaskfile.yml
File metadata and controls
109 lines (91 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Taskfile.yml — Task runner for NOX
# https://taskfile.dev
# Install: brew install go-task | go install github.com/go-task/task/v3/cmd/task@latest
version: "3"
vars:
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo "v0.0.1"
BINARY: nox
CMD: ./cmd/nox/
LDFLAGS: "-s -w -X main.Version={{.VERSION}}"
tasks:
# ── Default ────────────────────────────────────────────────────────────────
default:
desc: "Show available tasks"
cmds:
- task --list
silent: true
# ── Build ──────────────────────────────────────────────────────────────────
build:
desc: "Build the nox binary for the current platform"
cmds:
- CGO_ENABLED=1 go build -ldflags="{{.LDFLAGS}}" -o {{.BINARY}} {{.CMD}}
sources:
- "**/*.go"
- go.mod
- go.sum
generates:
- "{{.BINARY}}"
build:linux:
desc: "Cross-compile for Linux amd64"
cmds:
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="{{.LDFLAGS}}" -o {{.BINARY}}-linux-amd64 {{.CMD}}
build:darwin:
desc: "Cross-compile for macOS amd64"
cmds:
- CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="{{.LDFLAGS}}" -o {{.BINARY}}-darwin-amd64 {{.CMD}}
build:all:
desc: "Build for all supported platforms"
deps: [build:linux, build:darwin]
# ── Testing ────────────────────────────────────────────────────────────────
test:
desc: "Run the full test suite with race detection"
cmds:
- CGO_ENABLED=1 go test ./... -v -race -count=1
test:coverage:
desc: "Run tests and open an HTML coverage report"
cmds:
- CGO_ENABLED=1 go test ./... -coverprofile=coverage.out -covermode=atomic
- go tool cover -html=coverage.out
# ── Code Quality ──────────────────────────────────────────────────────────
lint:
desc: "Run golangci-lint"
cmds:
- golangci-lint run ./...
fmt:
desc: "Format all Go source files"
cmds:
- gofmt -w .
vet:
desc: "Run go vet"
cmds:
- go vet ./...
tidy:
desc: "Tidy and verify the module graph"
cmds:
- go mod tidy
- go mod verify
# ── Maintenance ───────────────────────────────────────────────────────────
clean:
desc: "Remove build artifacts"
cmds:
- rm -f {{.BINARY}} {{.BINARY}}-* coverage.out
silent: true
install:
desc: "Install the binary into GOPATH/bin"
cmds:
- go install -ldflags="{{.LDFLAGS}}" {{.CMD}}
# ── Docker ────────────────────────────────────────────────────────────────
docker:build:
desc: "Build the Docker image"
cmds:
- docker build -t nox:{{.VERSION}} -t nox:latest .
docker:run:
desc: "Run the Docker image interactively"
cmds:
- docker run --rm -it --env-file .env nox:{{.VERSION}}
# ── Release ───────────────────────────────────────────────────────────────
release:
desc: "Cut a release with GoReleaser"
cmds:
- goreleaser release --clean