-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
271 lines (246 loc) · 7.49 KB
/
Copy pathJustfile
File metadata and controls
271 lines (246 loc) · 7.49 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
# Morphir Go - Build Orchestration with Just
# Default recipe
default:
@just --list
# Internal: Detect OS and return normalized value (windows, linux, darwin, unknown)
_os:
@./scripts/detect-os.sh
# Internal: Get binary extension based on OS
_bin-ext:
@OS=`./scripts/detect-os.sh`; \
if [ "$$OS" = "windows" ]; then \
echo ".exe"; \
else \
echo ""; \
fi
# Internal: Get script extension based on OS
_script-ext:
@OS=`./scripts/detect-os.sh`; \
if [ "$$OS" = "windows" ]; then \
echo ".ps1"; \
else \
echo ".sh"; \
fi
# Internal: Get PowerShell command (pwsh or powershell)
_powershell:
@sh -c ' \
if command -v pwsh >/dev/null 2>&1; then \
echo "pwsh"; \
elif command -v powershell >/dev/null 2>&1; then \
echo "powershell"; \
else \
echo ""; \
fi'
# Build the CLI application
build:
#!/usr/bin/env bash
set -euo pipefail
echo "Building morphir CLI..."
# Determine binary extension based on GOOS (for cross-compilation) or current OS
EXT=""
if [ "${GOOS:-}" = "windows" ]; then
EXT=".exe"
elif [ "${GOOS:-}" = "" ]; then
# GOOS not set, detect current OS
OS=$(./scripts/detect-os.sh)
if [ "$OS" = "windows" ]; then
EXT=".exe"
fi
fi
# Create bin directory if it doesn't exist
mkdir -p bin
# Build the binary
go build -o "bin/morphir${EXT}" ./cmd/morphir
# Build the development version of the CLI (morphir-dev)
build-dev:
#!/usr/bin/env bash
set -euo pipefail
echo "Building morphir-dev CLI..."
# Determine binary extension based on GOOS or current OS
EXT=""
if [ "${GOOS:-}" = "windows" ]; then
EXT=".exe"
elif [ "${GOOS:-}" = "" ]; then
OS=$(./scripts/detect-os.sh)
if [ "$OS" = "windows" ]; then
EXT=".exe"
fi
fi
mkdir -p bin
go build -o "bin/morphir-dev${EXT}" ./cmd/morphir
# Run tests across all modules
test:
#!/usr/bin/env bash
set -euo pipefail
echo "Running tests..."
for dir in cmd/morphir pkg/models pkg/tooling pkg/sdk pkg/pipeline; do
if [ -d "$dir" ]; then
echo "Testing $dir..."
(cd "$dir" && go test ./...)
fi
done
# Format all Go code
fmt:
@echo "Formatting Go code..."
go fmt ./...
# Check code formatting without modifying files
fmt-check:
#!/usr/bin/env bash
set -euo pipefail
echo "Checking code formatting..."
UNFORMATTED=$(gofmt -s -l .)
if [ -n "$UNFORMATTED" ]; then
echo "The following files are not formatted:"
echo "$UNFORMATTED"
echo ""
echo "Run 'just fmt' to fix formatting issues."
exit 1
else
echo "✓ All files are properly formatted"
fi
# Run linters (requires golangci-lint)
lint:
#!/usr/bin/env bash
set -euo pipefail
echo "Running linters..."
if ! command -v golangci-lint > /dev/null; then
echo "golangci-lint not found. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"
exit 1
fi
for dir in cmd/morphir pkg/models pkg/tooling pkg/sdk pkg/pipeline; do
echo "Linting $dir..."
(cd "$dir" && golangci-lint run --timeout=5m)
done
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@if [ -d bin ]; then rm -rf bin; fi
go clean ./...
# Download dependencies for all modules
deps:
@echo "Downloading dependencies..."
go work sync
go mod download ./...
# Run go mod tidy for all modules
mod-tidy:
#!/usr/bin/env bash
set -euo pipefail
OS=$(./scripts/detect-os.sh)
if [ "$OS" = "windows" ]; then
if command -v pwsh >/dev/null 2>&1; then
PS="pwsh"
else
PS="powershell"
fi
"$PS" -ExecutionPolicy Bypass -File scripts/mod-tidy.ps1
else
./scripts/mod-tidy.sh
fi
# Install the CLI using go install (installs to $GOPATH/bin or $GOBIN)
install:
@echo "Installing morphir CLI..."
go install ./cmd/morphir
@echo "Installed successfully!"
# Install the development version as morphir-dev
install-dev: build-dev
#!/usr/bin/env bash
set -euo pipefail
OS=$(./scripts/detect-os.sh)
if [ "$OS" = "windows" ]; then
if command -v pwsh >/dev/null 2>&1; then
PS="pwsh"
else
PS="powershell"
fi
"$PS" -ExecutionPolicy Bypass -File scripts/install-dev.ps1
else
./scripts/install-dev.sh
fi
# Run the CLI application
run: build
#!/usr/bin/env bash
set -euo pipefail
EXT=""
OS=$(./scripts/detect-os.sh)
if [ "$OS" = "windows" ]; then
EXT=".exe"
fi
"./bin/morphir${EXT}"
# Run the development version of the CLI
run-dev: build-dev
#!/usr/bin/env bash
set -euo pipefail
EXT=""
OS=$(./scripts/detect-os.sh)
if [ "$OS" = "windows" ]; then
EXT=".exe"
fi
"./bin/morphir-dev${EXT}"
# Verify all modules build successfully
verify:
#!/usr/bin/env bash
set -euo pipefail
OS=$(./scripts/detect-os.sh)
if [ "$OS" = "windows" ]; then
if command -v pwsh >/dev/null 2>&1; then
PS="pwsh"
else
PS="powershell"
fi
"$PS" -ExecutionPolicy Bypass -File scripts/verify.ps1
else
./scripts/verify.sh
fi
# Set up development environment (install dependencies, git hooks, etc.)
setup:
@echo "Setting up development environment..."
@echo "1. Syncing Go modules..."
@go work sync
@echo "2. Installing npm dependencies (for git hooks)..."
@if command -v npm > /dev/null; then \
npm install; \
else \
echo "Warning: npm not found. Git hooks will not be installed."; \
echo "Install Node.js from https://nodejs.org/ to enable git hooks."; \
fi
@echo "3. Verifying git hooks are installed..."
@if [ -f ".husky/pre-push" ]; then \
echo " ✓ Git hooks installed successfully"; \
else \
echo " ⚠ Git hooks not installed (npm install may have failed)"; \
fi
@echo ""
@echo "Development environment setup complete!"
@echo "Run 'just build-dev' to build the development version."
# Run CI checks (format, build, test, lint)
ci-check: fmt-check verify test lint
@echo "✓ All CI checks passed!"
# Validate GoReleaser configuration
goreleaser-check:
@echo "Validating GoReleaser configuration..."
@if command -v goreleaser > /dev/null; then \
goreleaser check; \
else \
echo "goreleaser not found. Install with: go install github.com/goreleaser/goreleaser@latest"; \
exit 1; \
fi
# Test release build locally (creates snapshot without publishing)
release-snapshot:
@echo "Building release snapshot..."
@if command -v goreleaser > /dev/null; then \
goreleaser release --snapshot --clean --skip=publish; \
else \
echo "goreleaser not found. Install with: go install github.com/goreleaser/goreleaser@latest"; \
exit 1; \
fi
# Full dry-run of release (validates everything without publishing)
release-test:
@echo "Testing release process..."
@if command -v goreleaser > /dev/null; then \
goreleaser release --skip=publish --clean; \
else \
echo "goreleaser not found. Install with: go install github.com/goreleaser/goreleaser@latest"; \
exit 1; \
fi
# Note: Actual releases are handled by GitHub Actions on tag push
# To release: git tag -a vX.Y.Z -m "Release X.Y.Z" && git push origin vX.Y.Z