-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile.toml
More file actions
183 lines (159 loc) · 4.78 KB
/
Makefile.toml
File metadata and controls
183 lines (159 loc) · 4.78 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
[config]
default_to_workspace = false
[tasks.default]
alias = "dev"
[tasks.dev]
description = "Build and run in development mode"
dependencies = [
"build-wasm-dev",
"build-api-dev",
"build-cli-dev",
"build-hugo-dev"
]
[tasks.release]
description = "Build and run in release mode"
dependencies = [
"build-wasm-release",
"build-api-release",
"build-cli-release",
"build-hugo-release"
]
[tasks.build-site]
description = "Build WebAssembly and Hugo site for deployment"
script = """
if [ -n "$GITHUB_ACTIONS" ]; then
if [ -d "hugo-site/static/wasm" ] && [ -n "$(ls -A hugo-site/static/wasm)" ]; then
echo "Using cached WebAssembly files"
else
echo "WebAssembly files not found in cache, rebuilding..."
cargo make build-wasm-release
fi
else
echo "Building WebAssembly files..."
cargo make build-wasm-release
fi
cd hugo-site
hugo --minify
echo "Contents of public/wasm after running hugo:"
ls -la public/wasm
"""
[tasks.build-wasm-dev]
description = "Build WebAssembly in development mode"
script = """
cd rust/gkwasm
wasm-pack build --dev --target web --out-dir ../../hugo-site/static/wasm --no-typescript
echo "Contents of hugo-site/static/wasm after wasm-pack build:"
ls -l ../../hugo-site/static/wasm
"""
[tasks.build-wasm-release]
description = "Build WebAssembly in release mode"
script = """
cd rust/gkwasm
mkdir -p ../../hugo-site/static/wasm
wasm-pack build --release --target web --out-dir ../../hugo-site/static/wasm --no-typescript
echo "Contents of hugo-site/static/wasm after wasm-pack build:"
ls -l ../../hugo-site/static/wasm
"""
[tasks.build-api-dev]
description = "Build API in development mode"
script = """
cd rust/api
cargo build
"""
[tasks.build-api-release]
description = "Build API in release mode"
script = """
cd rust/api
cargo build --release
"""
[tasks.build-cli-dev]
description = "Build CLI in development mode"
script = """
cd rust/cli
cargo build
"""
[tasks.build-cli-release]
description = "Build CLI in release mode"
script = """
cd rust/cli
cargo build --release
"""
[tasks.generate-notary-keys]
description = "Generate notary keys (see freenet/web#24 for the delegate → notary rename)"
script = """
./rust/cli/generate_notary_keys.sh --master-key ./path/to/master_signing_key.pem --notary-dir ./path/to/notary/dir
"""
[tasks.generate-delegate-keys]
description = "DEPRECATED — alias for generate-notary-keys"
dependencies = ["generate-notary-keys"]
[tasks.test-ghostkey]
description = "Run ghostkey tests"
script = """
./rust/cli/test_ghostkey.sh
"""
[tasks.build-hugo-dev]
description = "Build Hugo site in development mode"
dependencies = ["build-wasm-dev"]
script = """
cd hugo-site
hugo
"""
[tasks.build-hugo-release]
description = "Build Hugo site in release mode"
dependencies = ["build-wasm-release"]
script = """
cd hugo-site
hugo --minify
"""
# --- Freenet publishing tasks ---
# Build and publish freenet.org as a static website on Freenet.
# Contract key is determined by the signing keypair (fdev website init).
[tasks.build-freenet]
description = "Build Hugo site for Freenet publishing"
script = """
CONTRACT_KEY="${FREENET_CONTRACT_KEY:?Set FREENET_CONTRACT_KEY to the website contract key}"
OUT="target/freenet-site"
rm -rf "$OUT"
cd hugo-site && hugo --minify --baseURL "/v1/contract/web/${CONTRACT_KEY}/" -d "../${OUT}"
cd ..
# Strip content that requires server-side functionality
rm -rf "$OUT/slides" "$OUT/wasm" "$OUT/ghostkey" "$OUT/fontawesome"
rm -f "$OUT/freenet_in_context.svg"
rm -f "$OUT/images/Freenet Network.pdf"
rm -f "$OUT/img/ghost-key-illustration.webp"
rm -f "$OUT/js/cbor.min.js" "$OUT/js/elliptic.min.js" "$OUT/js/donation-success.js"
rm -f "$OUT/js/msgpack.min.js" "$OUT/js/nacl.min.js" "$OUT/js/nacl-util.min.js"
# Rewrite hardcoded absolute image paths in HTML content to use the contract baseURL.
# Templates use Hugo's relURL (handled automatically), but raw HTML in markdown
# (e.g., <img src="/img/foo.webp">) needs rewriting.
BASE="/v1/contract/web/${CONTRACT_KEY}"
python3 scripts/rewrite-paths.py "$OUT" "$BASE"
echo ""
du -sh "$OUT"
echo "Ready to publish: fdev website publish $OUT --key <name>"
"""
[tasks.publish-freenet]
description = "Build and publish site to Freenet"
dependencies = ["build-freenet"]
script = """
CONTRACT_KEY="${FREENET_CONTRACT_KEY:?Set FREENET_CONTRACT_KEY}"
FREENET_KEY_NAME="${FREENET_KEY_NAME:?Set FREENET_KEY_NAME to the fdev website key name}"
fdev website publish target/freenet-site --key "$FREENET_KEY_NAME"
"""
[tasks.integration-test]
description = "Run all tests"
dependencies = ["dev"]
script = """
# Run unit tests for each crate
cd rust/gklib && cargo test
cd ../gkwasm && cargo test
cd ../api && cargo test
cd ../cli && cargo test
cd ../..
# Run ghostkey CLI tests
cd rust/cli
./test_ghostkey.sh
cd ../..
# Run integration tests
cd rust/integration_test && cargo run
"""