-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
322 lines (289 loc) · 11 KB
/
Taskfile.yml
File metadata and controls
322 lines (289 loc) · 11 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
version: "3"
# ============================================================================
# Development Tasks
# ============================================================================
#
# This Taskfile automates common development tasks.
#
# Prerequisites:
# - clojure: Clojure CLI tools (https://clojure.org/guides/install_clojure)
# - java: Java 11+ runtime
# - docker: For building container images (optional)
# - task: Task runner (https://taskfile.dev)
#
# Quick Start:
# task test # Run tests
# task build:uber # Build uberjar
# task build:jar # Build JAR
#
# ============================================================================
# Suppress command echoing for cleaner output
silent: true
# ============================================================================
# Variables
# ============================================================================
vars:
# Project Configuration
PROJECT_GROUP: com.github.wdhowe
PROJECT_NAME: clj-project
PROJECT_VERSION:
sh: git describe --tags --match 'v*' --always 2>/dev/null | sed 's/^v//' || cat resources/VERSION
# Docker Configuration
DOCKER_IMAGE: "wdhowe/{{.PROJECT_NAME}}"
DOCKER_TAG: "{{.PROJECT_VERSION}}"
# ============================================================================
# Tasks
# ============================================================================
tasks:
# --------------------------------------------------------------------------
# Default Task
# --------------------------------------------------------------------------
default:
desc: Show available tasks
cmds:
- task --list
# --------------------------------------------------------------------------
# Development
# --------------------------------------------------------------------------
run:
desc: Run the app in development mode
cmds:
- echo "Starting in development mode..."
- echo ""
- clojure -M:run-m
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
repl:
desc: Start a development REPL
cmds:
- echo "Starting development REPL..."
- clj -M:dev
preconditions:
- sh: command -v clj
msg: "Clojure CLI (clj) is not installed. See: https://clojure.org/guides/install_clojure"
repl:nrepl:
desc: Start an nREPL server for Calva/VSCode to connect to
cmds:
- echo "Starting nREPL server for Calva..."
- echo ""
- echo "To connect from VSCode:"
- echo " 1. Press Ctrl+Option+C, Ctrl+Option+C (Calva connect shortcut)"
- 'echo " Or: Cmd+Shift+P > Calva: Connect to a Running REPL Server in the Project"'
- echo " 2. Select deps.edn, then connect to the port shown below"
- echo ""
- clj -M:dev -m nrepl.cmdline --middleware '[cider.nrepl/cider-middleware]'
preconditions:
- sh: command -v clj
msg: "Clojure CLI (clj) is not installed. See: https://clojure.org/guides/install_clojure"
# --------------------------------------------------------------------------
# Quality
# --------------------------------------------------------------------------
lint:
desc: Lint source code with clj-kondo
cmds:
- echo "Linting source code..."
- clojure -M:lint src/ test/ dev/
- echo ""
- echo "✓ Linting complete"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
fmt:
desc: Check code formatting without making changes
cmds:
- echo "Checking code formatting..."
- clojure -M:cljfmt check src/ test/ dev/
- echo ""
- echo "✓ Format check complete"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
fmt:fix:
desc: Format source code with cljfmt
cmds:
- echo "Formatting source code..."
- clojure -M:cljfmt fix src/ test/ dev/
- echo ""
- echo "✓ Formatting complete"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
test:
desc: Run all tests (excludes integration tests). Optional pattern filter with -- <pattern>
cmds:
- |
if [ -n "{{.CLI_ARGS}}" ]; then
echo "Running tests matching '{{.CLI_ARGS}}'..."
clojure -X:test-m :p {{.CLI_ARGS}}
else
echo "Running tests..."
clojure -M:test
fi
- echo ""
- echo "✓ Tests passed"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
test:reflection:
desc: Check for reflection warnings (prints warnings but passes)
cmds:
- echo "Checking for reflection warnings..."
- clojure -X:test :patterns '[".*reflection.*"]'
- echo ""
- echo "✓ Reflection check complete"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
test:reflection:strict:
desc: Strict reflection check (fails if any warnings exist)
cmds:
- echo "Running strict reflection check..."
- clojure -X:test :patterns '[".*reflection.*"]' :includes '[:strict]' :excludes '[:integration]'
- echo ""
- echo "✓ No reflection warnings found"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
test:integration:
desc: Run integration tests. Optional pattern filter with -- <pattern>
cmds:
- |
if [ -n "{{.CLI_ARGS}}" ]; then
echo "Running integration tests matching '{{.CLI_ARGS}}'..."
clojure -X:test-integration-m :p {{.CLI_ARGS}}
else
echo "Running integration tests..."
clojure -M:test-integration
fi
- echo ""
- echo "✓ Integration tests passed"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
# --------------------------------------------------------------------------
# Build
# --------------------------------------------------------------------------
clean:
desc: Clean build artifacts
cmds:
- echo "Cleaning build artifacts..."
- clojure -T:build clean
- echo ""
- echo "✓ Clean complete"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
build:uber:
desc: Build the production uberjar
cmds:
- echo "Building uberjar..."
- clojure -T:build uber
- echo ""
- 'echo "✓ Build complete: target/{{.PROJECT_GROUP}}/{{.PROJECT_NAME}}-{{.PROJECT_VERSION}}.jar"'
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
build:jar:
desc: Build the JAR
cmds:
- echo "Building JAR..."
- clojure -T:build jar
- echo ""
- 'echo "✓ Build complete: target/{{.PROJECT_GROUP}}/{{.PROJECT_NAME}}-{{.PROJECT_VERSION}}.jar"'
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
ci:jar:
desc: Run CI pipeline for JAR (test + pom + jar)
cmds:
- echo "Running CI pipeline (test + pom + jar)..."
- clojure -T:build ci-jar
- echo ""
- echo "✓ CI JAR pipeline complete"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
ci:uber:
desc: Run CI pipeline for uberjar (test + pom + uberjar)
cmds:
- echo "Running CI pipeline (test + pom + uberjar)..."
- clojure -T:build ci-uber
- echo ""
- echo "✓ CI uberjar pipeline complete"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
# --------------------------------------------------------------------------
# Docker
# --------------------------------------------------------------------------
docker:build:
desc: Build Docker image
cmds:
- echo "Building Docker image..."
- 'echo " Image: {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}}"'
- "echo"
- >-
docker build
--build-arg VERSION={{.PROJECT_VERSION}}
--build-arg COMMIT_SHA=$(git rev-parse HEAD)
--build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
--build-arg BUILD_NUMBER={{.PROJECT_VERSION}}
-t {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} .
- "docker tag {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} {{.DOCKER_IMAGE}}:latest"
- "echo"
- 'echo "✓ Docker image built: {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}}"'
preconditions:
- sh: command -v docker
msg: "Docker is not installed"
- sh: test -f Dockerfile
msg: "Dockerfile not found in current directory"
docker:run:
desc: Run the Docker container locally
cmds:
- echo "Starting My Clojure App container..."
- "echo"
#- "docker run --rm -p 8080:8080 {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}}"
- "docker run --rm {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} '{{.CLI_ARGS}}'"
preconditions:
- sh: command -v docker
msg: "Docker is not installed"
- sh: "docker image inspect {{.DOCKER_IMAGE}}:{{.DOCKER_TAG}} > /dev/null 2>&1"
msg: "Docker image '{{.DOCKER_IMAGE}}:{{.DOCKER_TAG}}' not found. Run 'task docker:build' first"
deploy:
desc: Deploy JAR to Clojars (requires CLOJARS_USERNAME and CLOJARS_PASSWORD)
cmds:
- echo "Deploying to Clojars..."
- clojure -T:build deploy
- echo ""
- echo "✓ Deploy complete"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
- sh: test -n "$CLOJARS_USERNAME"
msg: "CLOJARS_USERNAME is not set"
- sh: test -n "$CLOJARS_PASSWORD"
msg: "CLOJARS_PASSWORD is not set"
# --------------------------------------------------------------------------
# Maintenance
# --------------------------------------------------------------------------
outdated:
desc: Check for outdated dependencies
cmds:
- echo "Checking for outdated dependencies..."
- clojure -M:outdated
- echo ""
- echo "✓ Outdated check complete"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"
outdated:upgrade:
desc: Interactively upgrade outdated dependencies
cmds:
- echo "Upgrading outdated dependencies..."
- clojure -M:outdated --upgrade
- echo ""
- echo "✓ Upgrade complete"
preconditions:
- sh: command -v clojure
msg: "Clojure CLI is not installed. See: https://clojure.org/guides/install_clojure"