-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
238 lines (185 loc) · 6.07 KB
/
justfile
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
# Royal Game of Ur - Justfile
# List all available commands
default:
@just --list
# ======================
# Project Initialization
# ======================
# Initialize the entire project
init: setup-scripts setup-asdf install-tools setup-hooks
yarn install
@echo "Project initialized successfully!"
# Set up script permissions
setup-scripts:
chmod +x scripts/*.sh
@echo "Scripts are now executable."
# Set up asdf version manager
setup-asdf:
asdf plugin add clojure nodejs yarn awscli || true
asdf install
# Install additional tools
install-tools: install-nbb install-graphviz install-graalvm verify-graalvm
# Set up Git hooks
setup-hooks:
mkdir -p .git/hooks
cp scripts/pre_commit.sh .git/hooks/pre_commit
chmod +x .git/hooks/pre_commit
@echo "Git hooks have been set up successfully."
# =================
# Tool Installation
# =================
# Install the latest version of nbb
install-nbb:
yarn global add nbb
# Install Graphviz for generating state diagrams
install-graphviz:
brew install graphviz
# Install and set up GraalVM
install-graalvm:
./scripts/install_graalvm.sh
# Verify GraalVM installation
verify-graalvm:
./scripts/verify_graalvm.sh
# Uninstall GraalVM and native-image
uninstall-graalvm:
./scripts/uninstall_graalvm.sh
# =================
# Development Tasks
# =================
# Format Clojure files
fmt:
@echo "Formatting Clojure files..."
clojure -M:dev:cljfmt fix
# Generate a state diagram
state-diagram:
dot -Tpng -Gdpi=300 ./docs/rgou-fsm.dot -o ./docs/rgou-fsm.png
# Concatenate all relevant files (for an LLM to read)
concat:
./scripts/concat_files.sh . justfile Dockerfile .cljc .cljs .clj .md .dot .edn .json -- node_modules/ .clj-kondo/ reflect-config.json resource-config.json build.clj .cljfmt.edn
# Concatenate all important files clojure
cci:
./scripts/concat_files.sh . justfile Dockerfile .cljc .cljs .clj .edn -- node_modules/ ./test/ .clj-kondo/ reflect-config.json resource-config.json .cljfmt.edn nbb.edn
# Concatenate just the program (for an LLM to read)
cc:
./scripts/concat_files.sh . README.md .cljc .cljs .clj -- build.clj ./test/
# ==================
# Update and Upgrade
# ==================
# Show out-dated Clojure dependencies
ancient:
clojure -Sdeps '{:deps {com.github.liquidz/antq {:mvn/version "RELEASE"}}}' \
-m antq.core
# Update all dependencies and tools
update: update-deps update-tools ancient
# Update the node dependencies
update-deps:
yarn upgrade
# Update all tools to their latest versions
update-tools:
./scripts/update_tools.sh
# =======
# Testing
# =======
# Run all unit tests (nbb)
test:
yarn test
# Run unit tests and watch for changes (nbb)
watch:
yarn test:watch
# Run all unit tests (Clojure)
test-clj:
clojure -M:test
# =================
# Build and Execute
# =================
# Build the project
build:
./scripts/build_project.sh
# Run a simulation with custom parameters (nbb)
nbb *ARGS:
yarn cli {{ARGS}}
# Run a simulation with custom parameters (Clojure)
clj *ARGS:
clojure -M:clj {{ARGS}}
# =================
# Utility Commands
# =================
# Run a REPL (Clojure)
repl:
clojure -M:dev
# Clean the project (remove build artifacts)
clean:
rm -rf target
rm -rf .cpcache
# =================
# ECR Commands
# =================
ECR_PUBLIC_REGISTRY := "public.ecr.aws/n1r2w5d4"
ECR_PRIVATE_REGISTRY := "250357559699.dkr.ecr.eu-west-1.amazonaws.com"
ECR_REPOSITORY := "rgou"
REGION := "eu-west-1"
LAMBDA_FUNCTION := "ur-test"
# Authenticate Docker to Amazon ECR public registry
ecr-login-public:
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin {{ECR_PUBLIC_REGISTRY}}
# Authenticate Docker to Amazon ECR private registry
ecr-login-private:
aws ecr get-login-password --region {{REGION}} | docker login --username AWS --password-stdin {{ECR_PRIVATE_REGISTRY}}
# Tag Docker image for public ECR
ecr-tag-public:
docker tag royal-game-of-ur:latest {{ECR_PUBLIC_REGISTRY}}/{{ECR_REPOSITORY}}:latest
# Tag Docker image for private ECR
ecr-tag-private:
#!/usr/bin/env bash
set -e
VERSION=$(cat version.txt)
docker tag royal-game-of-ur:latest {{ECR_PRIVATE_REGISTRY}}/{{ECR_REPOSITORY}}:v${VERSION}
# Push Docker image to public ECR
ecr-push-public:
docker push {{ECR_PUBLIC_REGISTRY}}/{{ECR_REPOSITORY}}:latest
# Push Docker image to private ECR
ecr-push-private:
#!/usr/bin/env bash
set -e
VERSION=$(cat version.txt)
docker push {{ECR_PRIVATE_REGISTRY}}/{{ECR_REPOSITORY}}:v${VERSION}
# Increment version
increment-version:
#!/usr/bin/env bash
set -e
VERSION=$(cat version.txt)
NEW_VERSION=$((VERSION + 1))
echo $NEW_VERSION > version.txt
echo "Version incremented to $NEW_VERSION"
# Update Lambda function
update-lambda:
#!/usr/bin/env bash
set -e
VERSION=$(cat version.txt)
aws lambda update-function-code \
--function-name {{LAMBDA_FUNCTION}} \
--image-uri {{ECR_PRIVATE_REGISTRY}}/{{ECR_REPOSITORY}}:v${VERSION} \
--region {{REGION}} \
--profile tre \
--no-cli-pager
# Login, tag, push Docker image to public ECR
ecr-deploy-public: ecr-login-public ecr-tag-public ecr-push-public
@echo "Image successfully pushed to public ECR"
# Login, tag, push Docker image to private ECR, and update Lambda
deploy: ecr-login-private ecr-tag-private ecr-push-private update-lambda increment-version
@echo "Image successfully pushed to private ECR, Lambda updated, and version incremented"
# =================
# Docker Commands
# =================
# Build Docker image
docker-build:
docker build --platform linux/arm64 -t royal-game-of-ur .
# Run the application in a Docker container with passed arguments
docker *ARGS:
docker run --platform linux/arm64 -it --rm royal-game-of-ur {{ARGS}} icons=simple
# Build and run in Docker with passed arguments
docker-build-run *ARGS: ecr-login-public docker-build
just docker play {{ARGS}}
# Build and deploy
docker-build-deploy *ARGS: ecr-login-private docker-build deploy
@echo "Image successfully built and deployed"