-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
192 lines (166 loc) · 4.43 KB
/
Taskfile.yml
File metadata and controls
192 lines (166 loc) · 4.43 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
version: '3'
vars:
SERVER_BINARY: homeguard
CLIENT_BINARY: wolctl
INSTALL_PATH: /usr/local/bin
LDFLAGS: -s -w
tasks:
default:
desc: Build the application (server and client)
cmds:
- task: build
build:
desc: Build both server and client
deps:
- build:server
- build:client
build:server:
desc: Build the server binary
sources:
- "**/*.go"
- go.mod
- go.sum
generates:
- "{{.SERVER_BINARY}}"
cmds:
- echo "Building {{.SERVER_BINARY}}..."
- go build -ldflags="{{.LDFLAGS}}" -o {{.SERVER_BINARY}} .
- echo '✓ Server build complete!'
build:client:
desc: Build the client tool
sources:
- "cmd/wolctl/**/*.go"
- go.mod
- go.sum
generates:
- "{{.CLIENT_BINARY}}"
cmds:
- echo "Building {{.CLIENT_BINARY}}..."
- go build -ldflags="{{.LDFLAGS}}" -o {{.CLIENT_BINARY}} ./cmd/wolctl/
- echo '✓ Client build complete!'
run:
desc: Run the server application
cmds:
- echo "Running {{.SERVER_BINARY}}..."
- go run main.go
clean:
desc: Clean build files and artifacts
cmds:
- echo "Cleaning build artifacts..."
- go clean
- rm -f {{.SERVER_BINARY}} {{.CLIENT_BINARY}}
- rm -rf dist/ build/
- echo '✓ Clean complete!'
test:
desc: Run tests
cmds:
- echo "Running tests..."
- go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
- echo '✓ Tests complete!'
test:short:
desc: Run tests without race detector
cmds:
- go test -v ./...
test:coverage:
desc: Run tests and show coverage
cmds:
- go test -v -coverprofile=coverage.txt -covermode=atomic ./...
- go tool cover -html=coverage.txt -o coverage.html
- echo "✓ Coverage report generated -> coverage.html"
lint:
desc: Run linter
cmds:
- echo "Running linter..."
- golangci-lint run
- echo '✓ Lint complete!'
fmt:
desc: Format code
cmds:
- echo "Formatting code..."
- go fmt ./...
- goimports -w .
- echo '✓ Format complete!'
tidy:
desc: Tidy go.mod
cmds:
- echo "Tidying go.mod..."
- go mod tidy
- echo '✓ Tidy complete!'
install:
desc: Install binaries to system
deps:
- build
cmds:
- echo "Installing {{.SERVER_BINARY}} and {{.CLIENT_BINARY}} to {{.INSTALL_PATH}}..."
- cp {{.SERVER_BINARY}} {{.INSTALL_PATH}}/
- cp {{.CLIENT_BINARY}} {{.INSTALL_PATH}}/
- echo '✓ Install complete!'
uninstall:
desc: Uninstall binaries from system
cmds:
- echo "Uninstalling {{.SERVER_BINARY}} and {{.CLIENT_BINARY}}..."
- rm -f {{.INSTALL_PATH}}/{{.SERVER_BINARY}}
- rm -f {{.INSTALL_PATH}}/{{.CLIENT_BINARY}}
- echo '✓ Uninstall complete!'
config:
desc: Create config from example
cmds:
- |
if [ ! -f config.yaml ]; then
cp config.example.yaml config.yaml
echo '✓ Created config.yaml from example'
else
echo '⚠ config.yaml already exists'
fi
dev:
desc: Run in development mode with auto-reload
cmds:
- echo "Starting development server..."
- air
docker:build:
desc: Build Docker image
cmds:
- echo "Building Docker image..."
- docker build -t homeguard:latest .
- echo '✓ Docker image built!'
docker:run:
desc: Run Docker container
cmds:
- docker run --rm --network host -v $(pwd)/config.yaml:/app/config.yaml:ro homeguard:latest
docker:up:
desc: Start Docker Compose services
cmds:
- docker-compose up -d
- echo '✓ Services started!'
docker:down:
desc: Stop Docker Compose services
cmds:
- docker-compose down
- echo '✓ Services stopped!'
release:
desc: Create a release build
cmds:
- echo "Creating release build..."
- goreleaser release --clean
- echo '✓ Release complete!'
release:snapshot:
desc: Create a snapshot release (no push)
cmds:
- echo "Creating snapshot release..."
- goreleaser release --snapshot --clean
- echo '✓ Snapshot release complete!'
all:
desc: Run all checks (fmt, lint, test, build)
cmds:
- task: fmt
- task: lint
- task: test
- task: build
ci:
desc: Run CI checks
cmds:
- task: tidy
- task: fmt
- task: lint
- task: test
- task: build