Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
179 lines (151 loc) · 4.72 KB
/
Copy pathTaskfile.yml
File metadata and controls
179 lines (151 loc) · 4.72 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
version: '3'
vars:
BINARY_NAME: hctf
MAIN_PATH: main.go
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo "dev"
BUILD_FLAGS: -ldflags="-s -w -X main.version={{.VERSION}}"
tasks:
default:
desc: Show available tasks
cmds:
- task --list
build:
desc: Build the application (incremental, uses cache if sources unchanged)
cmds:
- CGO_ENABLED=0 go build {{.BUILD_FLAGS}} -o {{.BINARY_NAME}} {{.MAIN_PATH}}
sources:
- '**/*.go'
- 'internal/views/templates/**/*.html'
- 'internal/database/migrations/**/*.sql'
generates:
- '{{.BINARY_NAME}}'
run:
desc: Run the application with admin setup
cmds:
- go run {{.MAIN_PATH}} serve --port 8090 --admin-email admin@hctf.local --admin-password changeme --dev
run-dev:
desc: Run the application without admin setup
cmds:
- go run {{.MAIN_PATH}} serve --port 8090 --dev
clean:
desc: Clean build artifacts (preserves database)
cmds:
- rm -f {{.BINARY_NAME}} {{.BINARY_NAME}}-*
clean-all:
desc: Clean build artifacts AND database (destructive)
cmds:
- rm -f {{.BINARY_NAME}} {{.BINARY_NAME}}-* *.db *.db-shm *.db-wal
rebuild:
desc: Force rebuild by removing binary first (ensures fresh build)
cmds:
- rm -f {{.BINARY_NAME}}
- task: build
test:
desc: Run all tests (unit + integration) with verbose output
cmds:
- go test -timeout 120s ./... -v
test-unit:
desc: Run unit tests only (excludes CLI integration tests)
cmds:
- go test -timeout 30s ./internal/... -v
test-integration:
desc: Run CLI integration tests (builds binary, starts real server)
cmds:
- go test -timeout 120s -run TestCLI -v .
deps:
desc: Install dependencies
cmds:
- go mod download
- go mod tidy
fmt:
desc: Format code
cmds:
- go fmt ./...
build-prod:
desc: Create a production build for Linux AMD64
cmds:
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build {{.BUILD_FLAGS}} -o {{.BINARY_NAME}}-linux-amd64 {{.MAIN_PATH}}
build-all:
desc: Build for all platforms
cmds:
- task: build-linux
- task: build-darwin
- task: build-windows
build-linux:
desc: Build for Linux AMD64
cmds:
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build {{.BUILD_FLAGS}} -o {{.BINARY_NAME}}-linux-amd64 {{.MAIN_PATH}}
build-darwin:
desc: Build for macOS AMD64
cmds:
- CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build {{.BUILD_FLAGS}} -o {{.BINARY_NAME}}-darwin-amd64 {{.MAIN_PATH}}
build-windows:
desc: Build for Windows AMD64
cmds:
- CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build {{.BUILD_FLAGS}} -o {{.BINARY_NAME}}-windows-amd64.exe {{.MAIN_PATH}}
lint:
desc: Run linters
cmds:
- golangci-lint run ./...
preconditions:
- sh: command -v golangci-lint
msg: "golangci-lint not installed. Install from https://golangci-lint.run/usage/install/"
watch:
desc: Watch for changes and rebuild
cmds:
- task: build
- task: run-dev
watch: true
db-reset:
desc: Reset the database
cmds:
- rm -f hctf.db hctf.db-shm hctf.db-wal
- echo "Database reset. Run 'task run' to recreate."
install:
desc: Install the binary to /usr/local/bin
cmds:
- task: build
- sudo cp {{.BINARY_NAME}} /usr/local/bin/
- echo "Installed to /usr/local/bin/{{.BINARY_NAME}}"
preconditions:
- sh: '[ -f {{.BINARY_NAME}} ]'
msg: "Binary not found. Run 'task build' first."
uninstall:
desc: Uninstall the binary from /usr/local/bin
cmds:
- sudo rm -f /usr/local/bin/{{.BINARY_NAME}}
- echo "Uninstalled from /usr/local/bin/{{.BINARY_NAME}}"
setup-sql:
desc: Download DuckDB WASM for local SQL Playground support
cmds:
- sh scripts/setup-duckdb-local.sh
preconditions:
- sh: test -f scripts/setup-duckdb-local.sh
msg: "Setup script not found"
generate-openapi:
desc: Generate OpenAPI/Swagger spec from code annotations
cmds:
- swag init -g main.go -o docs/ --outputTypes yaml
- mv docs/swagger.yaml docs/openapi.yaml
- echo "OpenAPI spec generated at docs/openapi.yaml"
preconditions:
- sh: command -v swag
msg: "swag not installed. Run: go install github.com/swaggo/swag/cmd/swag@v1.16.4"
build-css:
desc: Build Tailwind CSS from source
cmds:
- npm install
- npm run build:css
watch-css:
desc: Watch and rebuild Tailwind CSS during development
cmds:
- npm install
- npm run watch:css
help:
desc: Show help information
cmds:
- echo "hCTF - Modern CTF Platform"
- echo ""
- echo "Available tasks:"
- task --list