-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
180 lines (155 loc) · 4.38 KB
/
Taskfile.yml
File metadata and controls
180 lines (155 loc) · 4.38 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
# https://taskfile.dev
version: "3"
vars:
PROJECT_NAME: policy-zig
BUILD_DIR: zig-out
tasks:
default:
desc: "Build the project in debug mode"
aliases: [b]
cmds:
- zig build
build:
desc: "Build the project with specified optimization"
aliases: [build-opt]
cmds:
- zig build -Doptimize={{.OPTIMIZE | default "Debug"}}
build:protos:
desc: "Build the project with protos"
cmds:
- zig build -Dgen-proto=true gen-proto
build:release:
desc: "Build the project in release mode (ReleaseFast)"
aliases: [br, release]
cmds:
- zig build -Doptimize=ReleaseFast
build:safe:
desc: "Build the project in ReleaseSafe mode"
aliases: [bs]
cmds:
- zig build -Doptimize=ReleaseSafe
build:small:
desc: "Build the project in ReleaseSmall mode"
aliases: [bsm]
cmds:
- zig build -Doptimize=ReleaseSmall
test:
desc: "Run all tests"
aliases: [t]
cmds:
- zig build test -Doptimize=ReleaseSafe
test:file:
desc: "Run tests for a specific file"
aliases: [tf]
cmds:
- |
if [ -z "{{.FILE}}" ]; then
echo "Usage: task test:file FILE=<path>"
echo "Example: task test:file FILE=src/parser.zig"
exit 1
fi
zig test {{.FILE}}
test:summary:
desc: "Run tests with summary output"
aliases: [ts]
cmds:
- zig build test --summary all
format:
desc: "Format all Zig source files"
aliases: [fmt, f]
dir: "{{.TASKFILE_DIR}}"
cmds:
- zig fmt src/
- zig fmt build.zig
format:check:
desc: "Check if code is formatted correctly"
aliases: [fmt-check, fc]
dir: "{{.TASKFILE_DIR}}"
cmds:
- zig fmt --check src/
- zig fmt --check build.zig
lint:
desc: "Run linting checks"
aliases: [l]
cmds:
- task: format:check
clean:
desc: "Clean build artifacts"
aliases: [c]
cmds:
- rm -rf zig-out/
- rm -rf zig-cache/
- rm -rf .zig-cache/
check:
desc: "Check the project (build without running)"
cmds:
- zig build --summary failures
deps:
desc: "Check dependencies and Zig installation"
cmds:
- zig version
- zig env
do:
desc: "Run all pre-commit checks"
cmds:
- task: format
- task: lint
- task: test
signoff:
desc: "Sign off the codebase"
aliases: ["sign", "s"]
cmds:
- task: do
- task: build:safe
- gh signoff
info:
desc: "Show project information"
cmds:
- echo "Project {{.PROJECT_NAME}}"
- echo "Build directory {{.BUILD_DIR}}"
- zig version
- echo ""
- echo "Available build modes:"
- echo " - Debug (default)"
- echo " - ReleaseFast (task build:release)"
- echo " - ReleaseSafe (task build:safe)"
- echo " - ReleaseSmall (task build:small)"
update:protos:
desc: "Update proto files"
cmds:
- buf export buf.build/tero/policy -o proto
- buf export buf.build/opentelemetry/opentelemetry -o proto
- task: build:protos
# =============================================================================
# CI Setup
# =============================================================================
ci:setup:
desc: "Install CI/development dependencies (idempotent, safe to run locally)"
dir: "{{.TASKFILE_DIR}}"
cmds:
- |
echo "Checking for required dependencies..."
# Check for hyperscan/vectorscan
if ! pkg-config --exists libhs 2>/dev/null; then
echo "Installing hyperscan..."
if [ "$(uname)" = "Darwin" ]; then
if command -v brew >/dev/null 2>&1; then
brew install vectorscan pkg-config
else
echo "Homebrew not found. Install vectorscan manually or use Hermit."
fi
elif [ "$(uname)" = "Linux" ]; then
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update && sudo apt-get install -y libhyperscan-dev pkg-config
elif command -v yum >/dev/null 2>&1; then
sudo yum install -y hyperscan-devel pkg-config
else
echo "Unknown package manager. Install hyperscan manually."
fi
else
echo "Unknown platform: $(uname)"
fi
else
echo "Hyperscan already installed"
fi
echo "CI setup complete"