-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
226 lines (196 loc) · 6.65 KB
/
Copy pathTaskfile.yml
File metadata and controls
226 lines (196 loc) · 6.65 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# ELMOS - Embedded Linux on MacOS
# Taskfile for building and installing the elmos CLI
# https://taskfile.dev
version: '3'
vars:
BUILD_DIR: build
BINARY: "{{.BUILD_DIR}}/elmos"
PREFIX: /usr/local
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo "dev"
COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo "unknown"
DATE:
sh: date -u +"%Y-%m-%dT%H:%M:%SZ"
LDFLAGS: >-
-X github.com/NguyenTrongPhuc552003/elmos/core/app/version.Version={{.VERSION}}
-X github.com/NguyenTrongPhuc552003/elmos/core/app/version.Commit={{.COMMIT}}
-X github.com/NguyenTrongPhuc552003/elmos/core/app/version.BuildDate={{.DATE}}
GOBIN:
sh: go env GOPATH 2>/dev/null || echo "$HOME/go"
tasks:
# ============================================================================
# Default & Core Build
# ============================================================================
default:
desc: Build the elmos binary
cmds:
- task: build
build:
desc: Build the elmos binary
cmds:
- echo "Building {{.BINARY}}..."
- mkdir -p {{.BUILD_DIR}}
- go build -ldflags "{{.LDFLAGS}}" -o {{.BINARY}} ./cmd/elmos
sources:
- "**/*.go"
- go.mod
- go.sum
generates:
- "{{.BINARY}}"
clean:
desc: Clean all build artifacts
cmds:
- rm -rf {{.BUILD_DIR}}
- rm -rf completions
- rm -f coverage.out coverage.html
- go clean
# ============================================================================
# Development Workflow (dev:*)
# ============================================================================
dev:deps:
desc: Download and tidy dependencies
cmds:
- go mod download
- go mod tidy
dev:fmt:
desc: Format Go code
cmds:
- go fmt ./...
dev:lint:
desc: Run linter (golangci-lint or go vet)
cmds:
- |
if command -v golangci-lint >/dev/null 2>&1; then
golangci-lint run
else
echo "golangci-lint not installed, running go vet..."
go vet ./...
fi
dev:check:
desc: Run fmt, lint, and test (pre-commit style)
cmds:
- task: dev:fmt
- task: dev:lint
dev:complexity:install:
desc: Install go-complexity-analysis tool for CC/MI analysis
cmds:
- echo "Installing go-complexity-analysis..."
- go install github.com/firepear/go-complexity-analysis/cmd/complexity@latest
- echo "Installed to $(go env GOPATH)/bin/complexity"
dev:complexity:
desc: Run cyclomatic complexity analysis (CC>10, MI<30)
vars:
CC_THRESHOLD: '{{.CC_THRESHOLD | default "10"}}'
MI_THRESHOLD: '{{.MI_THRESHOLD | default "30"}}'
cmds:
- |
if [ ! -f "$(go env GOPATH)/bin/complexity" ]; then
echo "Error: complexity tool not installed. Run 'task dev:complexity:install' first."
exit 1
fi
echo "Running complexity analysis (CC>{{.CC_THRESHOLD}}, MI<{{.MI_THRESHOLD}})..."
go vet -vettool=$(go env GOPATH)/bin/complexity --cycloover {{.CC_THRESHOLD}} --maintunder {{.MI_THRESHOLD}} ./... 2>&1 | grep -v "undefined" || echo "✓ No complexity warnings!"
dev:setup:
desc: Full dev setup (deps + build + init workspace + tools)
cmds:
- task: dev:deps
- task: dev:complexity:install
- task: build
- task: elmos:init
# ============================================================================
# Installation (install:*)
# ============================================================================
install:
desc: Install to GOPATH/bin
deps: [build]
cmds:
- echo "Installing to {{.GOBIN}}/bin..."
- mkdir -p {{.GOBIN}}/bin
- cp {{.BINARY}} {{.GOBIN}}/bin/
install:global:
desc: Install to /usr/local/bin (requires sudo)
deps: [build]
cmds:
- echo "Installing to {{.PREFIX}}/bin..."
- sudo cp {{.BINARY}} {{.PREFIX}}/bin/
uninstall:
desc: Remove from GOPATH/bin
cmds:
- rm -f {{.GOBIN}}/bin/elmos
# ============================================================================
# Release (release:*)
# ============================================================================
release:darwin:
desc: Build for macOS platforms (arm64 + amd64)
cmds:
- mkdir -p {{.BUILD_DIR}}
- echo "Building for darwin/arm64..."
- GOOS=darwin GOARCH=arm64 go build -ldflags "{{.LDFLAGS}}" -o {{.BINARY}}-darwin-arm64 .
- echo "Building for darwin/amd64..."
- GOOS=darwin GOARCH=amd64 go build -ldflags "{{.LDFLAGS}}" -o {{.BINARY}}-darwin-amd64 .
release:completions:
desc: Generate shell completions
deps: [build]
cmds:
- mkdir -p completions
- ./{{.BINARY}} completion bash > completions/elmos.bash
- ./{{.BINARY}} completion zsh > completions/_elmos
- ./{{.BINARY}} completion fish > completions/elmos.fish
- 'echo "Completions generated in completions/"'
release:all:
desc: Full release (all platforms + completions)
cmds:
- task: release:darwin
- task: release:completions
release:homebrew:
desc: Generate Homebrew formula
cmds:
- |
cat <<EOF
class Elmos < Formula
desc "Embedded Linux development on macOS - native kernel builds"
homepage "https://github.com/NguyenTrongPhuc552003/elmos"
version "{{.VERSION}}"
license "MIT"
depends_on "llvm"
depends_on "lld"
depends_on "gnu-sed"
depends_on "make"
depends_on "libelf"
depends_on "qemu"
depends_on "e2fsprogs"
depends_on "coreutils"
def install
bin.install "elmos"
end
test do
system "\#{bin}/elmos", "version"
end
end
EOF
# ============================================================================
# Documentation (docs:*)
# ============================================================================
docs:
desc: Build the documentation site
deps: [docs:install]
cmds:
- python3 -m mkdocs build
docs:install:
desc: Install documentation dependencies if missing
internal: true
cmds:
- python3 -m pip install mkdocs-material "mkdocstrings[python]" mkdocs_puml --break-system-packages
status:
# Only run if all packages are found in the python environment
- python3 -c "import material, mkdocstrings, mkdocs_puml" 2>/dev/null
docs:clean:
desc: Remove generated documentation build files
cmds:
- rm -rf build/site/
docs:serve:
desc: Serve the documentation site locally and open in browser
deps: [docs]
cmds:
- python3 -m mkdocs serve --open