-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathjustfile
More file actions
363 lines (302 loc) · 14.8 KB
/
justfile
File metadata and controls
363 lines (302 loc) · 14.8 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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# Justfile for Morphir .NET build orchestration
# See https://github.com/casey/just for documentation
# Restore .NET dependencies
restore:
dotnet restore
# Build the solution
# Usage: just build [CONFIGURATION=Release]
build:
#!/usr/bin/env bash
dotnet build --no-restore --configuration ${CONFIGURATION:-Release}
# Run linting/formatting checks (verifies without making changes)
lint:
dotnet format --verify-no-changes
# Format code (applies formatting changes)
format:
dotnet format
# Run tests
# Usage: just test [CONFIGURATION=Release]
# Uses C# script for cross-platform compatibility
test:
#!/usr/bin/env bash
CONFIG="${CONFIGURATION:-Release}"
dotnet run scripts/run-tests.cs "$CONFIG"
# Check task that runs lint
check:
just lint
# Pre-commit hook task (runs lint)
precommit:
just lint
# Full CI pipeline: restore, build, test, and check
# Usage: just ci [CONFIGURATION=Release]
ci: restore build test check
@echo "CI pipeline completed successfully"
# Pack library projects as NuGet packages
# Usage: just pack-libs [CONFIGURATION=Release] [VERSION=] [OUTPUT_DIR=./artifacts/packages]
pack-libs:
#!/usr/bin/env bash
CONFIG="${CONFIGURATION:-Release}"
VERSION="${VERSION:-}"
OUTPUT_DIR="${OUTPUT_DIR:-./artifacts/packages}"
mkdir -p "$OUTPUT_DIR"
PACK_ARGS=("--configuration" "$CONFIG" "--output" "$OUTPUT_DIR")
if [ -n "$VERSION" ]; then
PACK_ARGS+=("/p:Version=$VERSION")
fi
echo "Packing Morphir.Core..."
dotnet pack src/Morphir.Core/Morphir.Core.csproj "${PACK_ARGS[@]}"
echo "Packing Morphir.Tooling..."
dotnet pack src/Morphir.Tooling/Morphir.Tooling.csproj "${PACK_ARGS[@]}"
# Pack the Morphir CLI as a dotnet tool (standard managed tool)
# Usage: just pack-tool [CONFIGURATION=Release] [VERSION=] [OUTPUT_DIR=./artifacts/packages]
pack-tool:
#!/usr/bin/env bash
CONFIG="${CONFIGURATION:-Release}"
VERSION="${VERSION:-}"
OUTPUT_DIR="${OUTPUT_DIR:-./artifacts/packages}"
mkdir -p "$OUTPUT_DIR"
PACK_ARGS=("--configuration" "$CONFIG" "--output" "$OUTPUT_DIR")
if [ -n "$VERSION" ]; then
PACK_ARGS+=("/p:Version=$VERSION")
fi
echo "Packing Morphir CLI as dotnet tool..."
dotnet pack src/Morphir/Morphir.csproj "${PACK_ARGS[@]}" /p:PackAsTool=true /p:ToolCommandName=morphir
# Build managed DLL for tool entry point (without AOT)
# Usage: just build-tool-dll [CONFIGURATION=Release] [OUTPUT_DIR=./artifacts/tool-dll]
build-tool-dll:
#!/usr/bin/env bash
dotnet run scripts/build-tool-dll.cs "${CONFIGURATION:-Release}" "${OUTPUT_DIR:-./artifacts/tool-dll}"
# Pack the Morphir CLI as a dotnet tool (managed DLL only)
# Usage: just pack-tool-platform [CONFIGURATION=Release] [VERSION=] [OUTPUT_DIR=./artifacts/packages]
# This packages the managed DLL as a dotnet tool named 'dotnet-morphir'
# The managed DLL will run on any platform with .NET installed (no platform-specific executables needed)
pack-tool-platform:
#!/usr/bin/env bash
dotnet run scripts/pack-tool-platform.cs "${CONFIGURATION:-Release}" "${VERSION:-}" "${OUTPUT_DIR:-./artifacts/packages}"
# Pack all projects (libraries and tool)
# Usage: just pack-all [CONFIGURATION=Release] [VERSION=] [OUTPUT_DIR=./artifacts/packages]
pack-all: pack-libs pack-tool
@echo "All packages created successfully"
# Publish single-file executable for a specific platform
# Usage: just publish-executable <RID> [CONFIGURATION=Release] [VERSION=] [OUTPUT_DIR=./artifacts/executables]
# This creates a self-contained executable that doesn't require .NET to be installed
# Common RIDs: linux-x64, linux-arm64, win-x64, osx-x64, osx-arm64
publish-executable RID:
#!/usr/bin/env bash
set -e
CONFIG="${CONFIGURATION:-Release}"
VERSION="${VERSION:-}"
OUTPUT_DIR="${OUTPUT_DIR:-./artifacts/executables}"
RID_OUTPUT_DIR="$OUTPUT_DIR/{{RID}}"
mkdir -p "$RID_OUTPUT_DIR"
PUBLISH_ARGS=("--configuration" "$CONFIG" "--self-contained" "true" "--property:PublishSingleFile=true" "--property:PublishTrimmed=true" "--property:PublishAot=true")
if [ -n "$VERSION" ]; then
PUBLISH_ARGS+=("--property:Version=$VERSION")
fi
echo "Publishing single-file executable for {{RID}}..."
dotnet publish src/Morphir/Morphir.csproj \
"${PUBLISH_ARGS[@]}" \
--runtime "{{RID}}" \
--output "$RID_OUTPUT_DIR"
# Find the executable (uses lowercase assembly name)
if [[ "{{RID}}" == win-* ]]; then
EXE_NAME="morphir.exe"
else
EXE_NAME="morphir"
fi
if [ -f "$RID_OUTPUT_DIR/$EXE_NAME" ]; then
echo "✓ Created: $RID_OUTPUT_DIR/$EXE_NAME"
ls -lh "$RID_OUTPUT_DIR/$EXE_NAME"
file "$RID_OUTPUT_DIR/$EXE_NAME"
else
echo "✗ Error: Executable not found at $RID_OUTPUT_DIR/$EXE_NAME"
echo "Contents of $RID_OUTPUT_DIR:"
ls -la "$RID_OUTPUT_DIR" 2>/dev/null || echo "Directory does not exist"
exit 1
fi
# Publish single-file executables for all platforms
# Usage: just publish-executables [CONFIGURATION=Release] [VERSION=] [OUTPUT_DIR=./artifacts/executables]
# This creates self-contained executables that don't require .NET to be installed
# Note: Cross-compilation may not work on all systems. Use publish-executable for a specific platform.
publish-executables:
#!/usr/bin/env bash
set -e
CONFIG="${CONFIGURATION:-Release}"
VERSION="${VERSION:-}"
OUTPUT_DIR="${OUTPUT_DIR:-./artifacts/executables}"
# Runtime Identifiers for different platforms
RIDS=("linux-x64" "linux-arm64" "win-x64" "osx-x64" "osx-arm64")
for RID in "${RIDS[@]}"; do
echo ""
echo "=== Publishing for $RID ==="
OUTPUT_DIR="$OUTPUT_DIR" CONFIGURATION="$CONFIG" VERSION="$VERSION" just publish-executable "$RID" || {
echo "⚠ Warning: Failed to publish for $RID (cross-compilation may not be supported)"
continue
}
done
echo ""
echo "All single-file executables published to $OUTPUT_DIR"
# Publish single-file executable without AOT (managed .NET runtime) with trimming
# Usage: just publish-single-file <RID> [CONFIGURATION=Release] [VERSION=] [OUTPUT_DIR=./artifacts/single-file]
# This creates a self-contained single-file executable that runs as a managed .NET application
# Trimming is enabled for size optimization (TrimMode=partial for safety)
# Compatible with dependencies that aren't AOT-compatible (e.g., Wolverine)
publish-single-file RID:
#!/usr/bin/env bash
dotnet run scripts/publish-single-file.cs "{{RID}}" "${CONFIGURATION:-Release}" "${VERSION:-}" "${OUTPUT_DIR:-./artifacts/single-file}"
# Publish single-file executable without AOT and without trimming (baseline)
# Usage: just publish-single-file-untrimmed <RID> [CONFIGURATION=Release] [VERSION=] [OUTPUT_DIR=./artifacts/single-file-untrimmed]
# This creates a baseline for size comparison
publish-single-file-untrimmed RID:
#!/usr/bin/env bash
dotnet run scripts/publish-single-file-untrimmed.cs "{{RID}}" "${CONFIGURATION:-Release}" "${VERSION:-}" "${OUTPUT_DIR:-./artifacts/single-file-untrimmed}"
# Build the E2E test project
# Usage: just build-e2e-tests [CONFIGURATION=Release]
# This restores and builds the E2E test project
build-e2e-tests:
#!/usr/bin/env bash
CONFIG="${CONFIGURATION:-Release}"
dotnet restore tests/Morphir.E2E.Tests/Morphir.E2E.Tests.csproj
dotnet build tests/Morphir.E2E.Tests/Morphir.E2E.Tests.csproj \
--configuration "$CONFIG" \
--no-restore
# Run end-to-end tests against Morphir executables (BDD/Gherkin)
# Usage: just test-e2e [EXECUTABLE_TYPE=all] [CONFIGURATION=Release]
# EXECUTABLE_TYPE: aot, trimmed, untrimmed, or all (default)
# CONFIGURATION: Build configuration (default: Release)
# This builds executables if needed and runs E2E tests
# Dependencies: build-e2e-tests ensures the test project is built
test-e2e EXECUTABLE_TYPE="all": build-e2e-tests
#!/usr/bin/env bash
dotnet run scripts/run-e2e-tests.cs "${EXECUTABLE_TYPE}" "${CONFIGURATION:-Release}"
# Build and test a single-file executable for a specific platform
# Usage: just build-and-test <RID> [CONFIGURATION=Release] [VERSION=] [OUTPUT_DIR=./artifacts/single-file]
# RID: Runtime Identifier (e.g., linux-x64, win-x64, osx-arm64)
# CONFIGURATION: Build configuration (default: Release)
# VERSION: Version string for the executable (optional)
# OUTPUT_DIR: Output directory for the executable (default: ./artifacts/single-file)
# This builds the executable and then runs E2E tests against it
# Dependencies: publish-single-file builds the executable, build-e2e-tests ensures tests are ready
build-and-test RID: build-e2e-tests
#!/usr/bin/env bash
CONFIG="${CONFIGURATION:-Release}"
VERSION="${VERSION:-}"
OUTPUT_DIR="${OUTPUT_DIR:-./artifacts/single-file}"
echo "================================================"
echo "Building and testing executable for {{RID}}"
echo "================================================"
echo ""
# Build the executable
echo "Building executable for {{RID}}..."
just publish-single-file "{{RID}}"
# Set executable permissions for Unix platforms
if [[ "{{RID}}" != win-* ]]; then
EXE_PATH="$OUTPUT_DIR/{{RID}}/morphir"
if [ -f "$EXE_PATH" ]; then
chmod +x "$EXE_PATH"
echo "✓ Executable permissions set for {{RID}}/morphir"
fi
fi
# Run E2E tests against the trimmed executable
echo "Running E2E tests for {{RID}}..."
dotnet run scripts/run-e2e-tests.cs "trimmed" "$CONFIG"
echo ""
echo "✓ Build and test completed successfully for {{RID}}"
# Publish library NuGet packages to NuGet.org
# Usage: just publish-libs [NUGET_SOURCE=https://api.nuget.org/v3/index.json] [API_KEY=] [OUTPUT_DIR=./artifacts/packages]
publish-libs:
#!/usr/bin/env bash
set -e
NUGET_SOURCE="${NUGET_SOURCE:-https://api.nuget.org/v3/index.json}"
API_KEY="${API_KEY:-}"
OUTPUT_DIR="${OUTPUT_DIR:-./artifacts/packages}"
if [ -z "$API_KEY" ]; then
echo "Error: API_KEY environment variable is required for publishing"
exit 1
fi
# Use find to locate packages (more reliable than glob patterns)
CORE_PACKAGE=$(find "$OUTPUT_DIR" -name "Morphir.Core.*.nupkg" -type f | head -1)
if [ -z "$CORE_PACKAGE" ]; then
echo "Error: Morphir.Core package not found in $OUTPUT_DIR"
echo "Contents of $OUTPUT_DIR:"
ls -la "$OUTPUT_DIR" 2>/dev/null || echo "Directory does not exist"
exit 1
fi
echo "Publishing Morphir.Core: $CORE_PACKAGE"
dotnet nuget push "$CORE_PACKAGE" --source "$NUGET_SOURCE" --api-key "$API_KEY" --skip-duplicate
TOOLING_PACKAGE=$(find "$OUTPUT_DIR" -name "Morphir.Tooling.*.nupkg" -type f | head -1)
if [ -z "$TOOLING_PACKAGE" ]; then
echo "Error: Morphir.Tooling package not found in $OUTPUT_DIR"
echo "Contents of $OUTPUT_DIR:"
ls -la "$OUTPUT_DIR" 2>/dev/null || echo "Directory does not exist"
exit 1
fi
echo "Publishing Morphir.Tooling: $TOOLING_PACKAGE"
dotnet nuget push "$TOOLING_PACKAGE" --source "$NUGET_SOURCE" --api-key "$API_KEY" --skip-duplicate
# Publish the Morphir CLI tool package to NuGet.org
# Usage: just publish-tool [NUGET_SOURCE=https://api.nuget.org/v3/index.json] [API_KEY=] [OUTPUT_DIR=./artifacts/packages]
publish-tool:
#!/usr/bin/env bash
NUGET_SOURCE="${NUGET_SOURCE:-https://api.nuget.org/v3/index.json}"
API_KEY="${API_KEY:-}"
OUTPUT_DIR="${OUTPUT_DIR:-./artifacts/packages}"
if [ -z "$API_KEY" ]; then
echo "Error: API_KEY environment variable is required for publishing"
exit 1
fi
# Find the Morphir tool package (exclude .Core and .Tooling packages)
TOOL_PACKAGE=$(find "$OUTPUT_DIR" -name "Morphir.*.nupkg" ! -name "*Morphir.Core*" ! -name "*Morphir.Tooling*" | head -1)
if [ -z "$TOOL_PACKAGE" ]; then
echo "Error: Morphir tool package not found in $OUTPUT_DIR"
exit 1
fi
echo "Publishing Morphir CLI tool: $TOOL_PACKAGE"
dotnet nuget push "$TOOL_PACKAGE" --source "$NUGET_SOURCE" --api-key "$API_KEY" --skip-duplicate
# Publish all packages (libraries and tool)
# Usage: just publish-all [NUGET_SOURCE=https://api.nuget.org/v3/index.json] [API_KEY=] [OUTPUT_DIR=./artifacts/packages]
publish-all: publish-libs publish-tool
@echo "All packages published successfully"
# Publish library packages to a local NuGet source
# Usage: just publish-local-libs [LOCAL_SOURCE=./artifacts/local-feed] [OUTPUT_DIR=./artifacts/packages]
publish-local-libs:
#!/usr/bin/env bash
LOCAL_SOURCE="${LOCAL_SOURCE:-./artifacts/local-feed}"
OUTPUT_DIR="${OUTPUT_DIR:-./artifacts/packages}"
mkdir -p "$LOCAL_SOURCE"
# Check if source already exists, if not add it
if ! dotnet nuget list source | grep -q "$LOCAL_SOURCE"; then
echo "Adding local NuGet source: $LOCAL_SOURCE"
dotnet nuget add source "$LOCAL_SOURCE" --name local-feed || true
fi
echo "Publishing Morphir.Core to local feed..."
dotnet nuget push "$OUTPUT_DIR"/*.Morphir.Core.*.nupkg --source "$LOCAL_SOURCE" --skip-duplicate || true
echo "Publishing Morphir.Tooling to local feed..."
dotnet nuget push "$OUTPUT_DIR"/*.Morphir.Tooling.*.nupkg --source "$LOCAL_SOURCE" --skip-duplicate || true
echo "Libraries published to local feed: $LOCAL_SOURCE"
# Install the Morphir CLI tool locally from the package
# Usage: just publish-local-tool [OUTPUT_DIR=./artifacts/packages] [GLOBAL=false]
publish-local-tool:
#!/usr/bin/env bash
OUTPUT_DIR="${OUTPUT_DIR:-./artifacts/packages}"
GLOBAL="${GLOBAL:-false}"
# Find the Morphir tool package (exclude .Core and .Tooling packages)
TOOL_PACKAGE=$(find "$OUTPUT_DIR" -name "Morphir.*.nupkg" ! -name "*Morphir.Core*" ! -name "*Morphir.Tooling*" | head -1)
if [ -z "$TOOL_PACKAGE" ]; then
echo "Error: Morphir tool package not found in $OUTPUT_DIR"
echo "Please run 'just pack-tool' first"
exit 1
fi
if [ "$GLOBAL" = "true" ]; then
echo "Installing Morphir CLI tool globally from: $TOOL_PACKAGE"
dotnet tool install --global --add-source "$OUTPUT_DIR" Morphir || \
dotnet tool update --global --add-source "$OUTPUT_DIR" Morphir
else
echo "Installing Morphir CLI tool locally from: $TOOL_PACKAGE"
dotnet tool install --add-source "$OUTPUT_DIR" Morphir || \
dotnet tool update --add-source "$OUTPUT_DIR" Morphir
fi
echo "Morphir CLI tool installed successfully"
# Publish all packages locally (libraries to local feed, tool installed locally)
# Usage: just publish-local-all [LOCAL_SOURCE=./artifacts/local-feed] [OUTPUT_DIR=./artifacts/packages] [GLOBAL=false]
publish-local-all: publish-local-libs publish-local-tool
@echo "All packages published locally successfully"