forked from Excoriate/daggerverse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
315 lines (261 loc) Β· 13.3 KB
/
Copy pathjustfile
File metadata and controls
315 lines (261 loc) Β· 13.3 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
export NIXPKGS_ALLOW_UNFREE := "1"
export NOTHANKS := "1"
default:
@just --list
# --------------------------------------------------
# Section: Nix Development Environment
# --------------------------------------------------
# This section contains recipes for setting up and managing
# the Nix development environment, including entering the environment,
# cleaning caches, and initializing the project.
# --------------------------------------------------
# Recipe to enter the Nix development environment π§°
dev:
@echo "Entering Nix development environment π§° ..."
@nix develop
# Recipe to clean Go cache, Go modules cache, and Nix/DevEnv/DirEnv cache π§Ή
clean-all:
@echo "Cleaning Go cache π§Ή ..."
@go clean -cache
@echo "Cleaning Go modules cache π§Ή ..."
@go clean -modcache
@echo "Cleaning Nix/DevEnv/DirEnv cache π§Ή ..."
@nix-collect-garbage -d
fmt:
@echo "Formatting code π ..."
@nix develop --command treefmt
# Recipe to run pre-commit hooks π
run-hooks:
@echo "Running pre-commit hooks π ..."
@pre-commit autoupdate
@pre-commit run --all-files
@echo "Pre-commit hooks passed β
"
# Recipe to bump version of a module π
bump-version mod bump='minor':
#!/usr/bin/env bash
set -euo pipefail
echo "π Bumping version for {{mod}} module"
# Verify that the module directory exists and contains a dagger.json file
if [ ! -d "{{mod}}" ] || [ ! -f "{{mod}}/dagger.json" ]; then
echo "β Module {{mod}} not found or dagger.json missing"
exit 1
fi
# Get the latest tag for this module
latest_tag=$(git describe --tags --abbrev=0 --match "{{mod}}/*" 2>/dev/null || echo "{{mod}}/v0.0.0")
current_version=$(echo $latest_tag | sed 's/{{mod}}\/v//')
# Calculate the new version
new_version="v$(semver bump {{bump}} "v$current_version")"
echo "π’ Current version: v$current_version"
echo "π New version: $new_version"
read -p "Proceed with version bump? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "β Aborting"
exit 1
fi
# Create and push the new tag
new_tag="{{mod}}/$new_version"
git tag -a "$new_tag" -m "Bump {{mod}} to $new_version"
git push origin "$new_tag"
echo "β
Version bumped to $new_version and tag $new_tag created"
echo "π Tag has been pushed to the remote repository"
# --------------------------------------------------
# Section: Recipes for running tests, examples, and linting
# ------------------------------------------------------------------------------
# This section contains recipes for running tests, examples, and linting in a certain module.
# cleaning caches, and initializing the project.
# --------------------------------------------------
# Recipe to run all the tests in the target module π§ͺ
test mod *args: (reloadmod mod) (reloadtest mod)
@echo "π Running Dagger module tests in module [{{mod}}]..."
@echo "π¦ Currently in {{mod}} module π§ͺ, path=`pwd`/{{mod}}/tests"
@cd {{mod}}/tests && dagger functions
@cd {{mod}}/tests && dagger call test-all {{args}}
# Recipe to run all the examples in the target module π
examplesgo mod *args: (reloadmod mod) (reloadexamples mod)
@echo "π Running Dagger module examples (Go SDK)..."
@echo "π¦ Currently in {{mod}} module examples/go π, path=`pwd`/{{mod}}/examples/go"
@cd {{mod}}/examples/go && dagger call all-recipes {{args}}
# Recipe to run GolangCI Lint in top-level moduleπ§Ή
lintmod mod *args: (reloadmod mod)
@echo "Running Go (GolangCI)... π§Ή in module [{{mod}}] π¦"
@nix develop .# --command bash -c "cd {{mod}} && golangci-lint run --config ../.golangci.yml --verbose {{args}}"
# Recipe to run GolangCI Lint in tests module π§Ή
linttests mod *args: (reloadtest mod)
@echo "Running Go (GolangCI)... π§Ή in module [{{mod}}/tests] π§ͺ"
@nix develop .# --command bash -c "cd {{mod}}/tests && golangci-lint run --config ../../.golangci.yml --verbose {{args}}"
# Recipe to run GolangCI Lint in examples/go module π§Ή
lintexamples mod *args: (reloadexamples mod)
@echo "Running Go (GolangCI)... π§Ή in module [{{mod}}/examples/go] π"
@nix develop .# --command bash -c "cd {{mod}}/examples/go && golangci-lint run --config ../../../.golangci.yml --verbose {{args}}"
# Recipe to run GolangCI Lint in all modules π§Ή
lintall mod: (lintmod mod) (linttests mod) (lintexamples mod)
@echo "β
All Go (GolangCI) lint checks passed β
"
# Recipe to run the whole CI locally π
ci mod: (reloadall mod) (lintall mod) (test mod) (examplesgo mod) (ci-mod-docs mod)
@echo "π All checks passed! π"
# Recipe to validate if the dagger module has the README.md file and the LICENSE file π
ci-mod-docs mod:
@echo "π Validating the module documentation..."
@test -f {{mod}}/README.md || (echo "β README.md file not found" && exit 1)
@test -f {{mod}}/LICENSE || (echo "β LICENSE file not found" && exit 1)
@echo "β
Module documentation is valid"
# --------------------------------------------------
# Section: Dagger Functions
# --------------------------------------------------
# This section contains recipes for calling functions
# in a certain module.
# --------------------------------------------------
# Recipe to call an specific function from the examples/go project in a certain module π
callfnexample mod *args: (check-dagger-pre-requisites mod) (reloadexamples mod)
@echo "π§ Calling a function in the π examples/go module [{{mod}}/examples/go]..."
@echo "π¦ Currently in [{{mod}}/examples/go] module, path=`pwd`"
@cd {{mod}}/examples/go && dagger call {{args}}
# Recipe for dagger call tests in a certain module π§ͺ
callfntest mod *args: (check-dagger-pre-requisites mod) (reloadtest mod)
@echo "π¨ Calling a function {{args}} in the π§ͺ test module [{{mod}}/tests]..."
@echo "π¦ Currently in [{{mod}}/tests] module, path=`pwd`/{{mod}}/tests"
@cd {{mod}}/tests && dagger functions
@cd {{mod}}/tests && dagger call {{args}}
# Recipe to call a certain function by a module's name, passing extra arguments optionally π
callfn mod *args: (check-dagger-pre-requisites mod) (reloadmod mod)
@echo "π¨ Calling a function {{args}} in the module [{{mod}}]..."
@echo "π Currently in [{{mod}}] module, path=`pwd`/{{mod}}"
@cd {{mod}} && dagger functions
@cd {{mod}} && dagger call {{args}}
# Recipe to list functions in a certain module π
listfns mod *args: (check-dagger-pre-requisites mod) (reloadmod mod)
@echo "π Retrieving available functions for the module..."
@echo "π¦ Currently in [{{mod}}] module, path=`pwd`/{{mod}}"
@cd {{mod}} && dagger functions
# Recipe to list functions in a test π§ͺ module
listfnstest mod *args: (check-dagger-pre-requisites mod) (reloadtest mod)
@echo "π Retrieving available functions for the module..."
@echo "π¦ Currently in [{{mod}}/tests] module, path=`pwd`/{{mod}}/tests"
@cd {{mod}}/tests && dagger functions {{args}}
# Recipe to list functions in a examples/go π module
listfnsexamples mod *args: (check-dagger-pre-requisites mod) (reloadexamples mod)
@echo "π Retrieving available functions for the module..."
@echo "π¦ Currently in [{{mod}}/examples/go] module, path=`pwd`"
@cd {{mod}}/examples/go && dagger functions {{args}}
# --------------------------------------------------
# Section: Dagger Maintenance
# --------------------------------------------------
# This section contains recipes for various maintenance
# operations related to Dagger modules.
# --------------------------------------------------
# Recipe that wraps the dagger CLI in a certain module π¦
dagcli mod *args: (check-dagger-pre-requisites mod)
@echo "π Running Dagger CLI in a certain module..."
@echo "π¦ Currently in [{{mod}}] module, path=`pwd`/{{mod}}"
@cd {{mod}} && dagger {{args}}
# Recipe to run dagger develop and if the engine gots updated, update the modules π
update-all: (daggy-compile) (check-docker-or-podman)
@echo "π Developing (or upgrading) all Dagger modules..."
@.daggerx/daggy/target/release/daggy --task=develop
# --------------------------------------------------
# Section: Creating new modules
# --------------------------------------------------
# This section contains recipes for various operations
# related to Dagger modules, such as calling functions,
# listing functions, and running tests.
# --------------------------------------------------
# Recipe to create a new module using Daggy (a rust CLI tool) π οΈ
create mod with-ci='false' type='full': (daggy-compile) (check-docker-or-podman)
@echo "π Creating a new {{type}} module of type {{type}}..."
@.daggerx/daggy/target/release/daggy --task=create --module={{mod}} --module-type={{type}}
@if [ "{{with-ci}}" = "true" ]; then just cilocal {{mod}}; fi
# Recipe to create a new light module using Daggy π οΈ
createlight mod with-ci='false' type='light': (daggy-compile) (check-docker-or-podman)
@echo "π Creating a new {{type}} module of type {{type}}..."
@./.daggerx/daggy/target/release/daggy --task=create --module={{mod}} --module-type={{type}}
@if [ "{{with-ci}}" = "true" ]; then just cilocal {{mod}}; fi
# --------------------------------------------------
# Section: Daggy Operations
# --------------------------------------------------
# This section contains recipes for compiling and testing
# the Daggy tool.
# --------------------------------------------------
# Recipe to run Daggy tests π§ͺ
daggy-tests: (daggy-compile)
@echo "Running Daggy tests π§ͺ ..."
@cd .daggerx/daggy && cargo test
# Recipe to compile Daggy π
daggy-compile:
@echo "Compiling Daggy π ..."
@cd .daggerx/daggy && cargo build --release
@echo "Daggy compiled successfully π"
# --------------------------------------------------
# Section: Reloading Dagger Modules
# --------------------------------------------------
# This section contains recipes for reloading Dagger
# modules and their tests.
# --------------------------------------------------
# Recipe to reload Dagger module (Dagger Develop) π
reloadmod mod *args: (check-dagger-pre-requisites mod)
@echo "π Running Dagger development in a given module..."
@echo "π¦ Currently in [{{mod}}] module, path=`pwd`/{{mod}}"
@cd {{mod}} && dagger develop {{args}}
@echo "β
Module reloaded successfully"
# Recipe to reload a Dagger module's tests (Dagger Develop) π
reloadtest mod *args: (check-dagger-pre-requisites mod)
@echo "π Running Dagger development in a given module's tests..."
@echo "π¦ Currently in [{{mod}}/tests] module, path=`pwd`/{{mod}}/tests"
@cd {{mod}}/tests && dagger develop {{args}}
@echo "β
Module Tests reloaded successfully"
# Recipe to reload the Dagger module's examples (examples/go) π
reloadexamples mod *args: (check-dagger-pre-requisites mod)
@echo "π Reloading the module's examples..."
@echo "π¦ Currently in {{mod}}/examples/go module, path=`pwd`"
@test -d {{mod}}/examples/go || (echo "β Module examples not found" && exit 1)
@cd {{mod}}/examples/go && dagger develop {{args}}
@echo "π Module's examples reloaded successfully"
# Recipe to reload Dagger module and its underlying tests (Dagger Develop & Dagger Call/Functions) π
reloadall mod *args: (reloadmod mod) (reloadtest mod) (reloadexamples mod)
@echo "π Reloading all the module, tests and examples... [{{mod}}]"
@echo "π Module reloaded successfully"
# --------------------------------------------------
# Section: Utilities
# --------------------------------------------------
# This section contains recipes for utilities that
# are used to validate if Docker or Podman is running
# and to validate if a given directory is a Dagger module.
# --------------------------------------------------
# Recipe to check if Docker or Podman is running π
check-docker-or-podman:
#!/usr/bin/env sh
set -e
if command -v docker > /dev/null 2>&1; then
if ! docker info > /dev/null 2>&1; then
echo "β Docker is installed but not running. Please start Docker and try again."
exit 1
else
echo "β
Docker is running."
fi
elif command -v podman > /dev/null 2>&1; then
if ! podman info > /dev/null 2>&1; then
echo "β Podman is installed but not running. Please start Podman and try again."
exit 1
else
echo "β
Podman is running."
fi
else
echo "β Neither Docker nor Podman is installed. Please install one of them and try again."
exit 1
fi
# Recipe that validate if it's an actual Dagger module
is-dagger-module mod:
@echo "π Validating if [{{mod}}] is a Dagger module..."
@test -d {{mod}} || (echo "β Module not found at path=`pwd`/{{mod}}" && exit 1)
@test -f {{mod}}/dagger.json || (echo "β dagger.json not found in module at path=`pwd`/{{mod}}. Not a Dagger module." && exit 1)
@echo "β
[{{mod}}] is a Dagger module"
# Recipe that check Dagger pre-requisites
check-dagger-pre-requisites mod: (check-docker-or-podman) (is-dagger-module mod)
# Recipe to sync module-template (light) changes that require sync in the Go templates. π
syncmodlight: (daggy-compile)
@echo "π Syncing the module..."
@./.daggerx/daggy/target/release/daggy --task=sync --inspect-type=light --detailed=false
# Recipe to sync module-template (full) changes that require sync in the Go templates. π
syncmodfull: (daggy-compile)
@echo "π Syncing the module..."
@./.daggerx/daggy/target/release/daggy --task=sync --inspect-type=full --detailed=false