-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
275 lines (243 loc) · 9.4 KB
/
justfile
File metadata and controls
275 lines (243 loc) · 9.4 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
# ===============================================================================
# vigOS Devcontainer - Just Recipes
# Build automation for devcontainer image development
# ===============================================================================
# ===============================================================================
# VARIABLES
# ===============================================================================
# Allow TEST_REGISTRY to override REPO for testing (e.g., localhost:5000/test/)
repo := env("TEST_REGISTRY", "ghcr.io/vig-os/devcontainer")
# ===============================================================================
# INFO
# ===============================================================================
# Show available commands (default)
[group('info')]
default:
@just --list --unsorted
# Show available commands
[group('info')]
help:
@just --list
# ===============================================================================
# CODE QUALITY
# ===============================================================================
# Run all linters
[group('quality')]
lint:
uv run ruff check .
# Format code
[group('quality')]
format:
uv run ruff format .
# Run pre-commit hooks on all files
[group('quality')]
precommit:
uv run pre-commit run --all-files
# Show image information
[group('info')]
info:
#!/usr/bin/env bash
ARCH=$(uname -m)
if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
NATIVE_ARCH="linux/arm64"
else
NATIVE_ARCH="linux/amd64"
fi
echo "Image: {{ repo }}"
echo "Containerfile: Containerfile"
echo "Native arch: $NATIVE_ARCH"
# Install system dependencies and setup development environment
[group('info')]
init *args:
./scripts/init.sh {{ args }}
# Generate documentation from templates
[group('info')]
docs:
uv run python docs/generate.py
# Sync workspace templates from repo root to assets/workspace/
[group('info')]
sync-workspace:
uv run python scripts/sync_manifest.py sync assets/workspace/
# Test login to GHCR
[group('info')]
login:
#!/usr/bin/env bash
echo "Logging in to GitHub Container Registry..."
podman login ghcr.io
# ===============================================================================
# BUILD
# ===============================================================================
# Build local development image
[group('build')]
build no_cache="":
#!/usr/bin/env bash
ARCH=$(uname -m)
if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
NATIVE_ARCH="linux/arm64"
else
NATIVE_ARCH="linux/amd64"
fi
if [ -n "{{ no_cache }}" ]; then
./scripts/build.sh --no-cache dev "{{ repo }}" "$NATIVE_ARCH"
else
./scripts/build.sh dev "{{ repo }}" "$NATIVE_ARCH"
fi
# ===============================================================================
# TEST
# ===============================================================================
# Helper to ensure dev image exists before running image/integration tests
[private]
_ensure-dev-image version="dev":
#!/usr/bin/env bash
if ! podman image exists "{{ repo }}:{{ version }}"; then
if [ "{{ version }}" = "dev" ]; then
echo "Building dev image..."
just build
else
echo "[ERROR] Image {{ repo }}:{{ version }} not found. Please build it first."
exit 1
fi
fi
# Run image tests only
[group('test')]
test-image version="dev":
@just _ensure-dev-image {{ version }}
#!/usr/bin/env bash
TEST_CONTAINER_TAG={{ version }} uv run pytest tests/test_image.py -v --tb=short
# Run integration tests only
[group('test')]
test-integration version="dev":
@just _ensure-dev-image {{ version }}
#!/usr/bin/env bash
TEST_CONTAINER_TAG={{ version }} uv run pytest tests/test_integration.py -v --tb=short
# Run utils tests only
[group('test')]
test-utils:
#!/usr/bin/env bash
uv run pytest tests/test_utils.py -v -s --tb=short
# Run install script tests only
[group('test')]
test-install:
#!/usr/bin/env bash
uv run pytest tests/test_install_script.py -v -s --tb=short
# Run validate commit msg tests only
[group('test')]
test-validate-commit-msg:
#!/usr/bin/env bash
uv run pytest tests/test_validate_commit_msg.py -v -s --tb=short
# Run check action pins tests only
[group('test')]
test-vig-utils:
#!/usr/bin/env bash
uv run pytest packages/vig-utils/tests -v -s --tb=short
# Run BATS shell script tests
[group('test')]
test-bats:
#!/usr/bin/env bash
# Use GNU parallel if available for faster test execution
if command -v parallel >/dev/null 2>&1; then
echo "Running BATS tests in parallel..."
find tests/bats -name '*.bats' -print0 | parallel -0 -j+0 npx bats {}
else
echo "Running BATS tests sequentially (install 'parallel' for faster execution)..."
npx bats tests/bats/
fi
# Validate tracked Renovate configs with renovate-config-validator --strict
[group('test')]
test-renovate:
#!/usr/bin/env bash
set -euo pipefail
# Mirror .github/workflows/renovate-validate.yml: skip
# assets/workspace/renovate.json because its preset is templated with the
# repository name and only resolves after init copies it into a real repo.
mapfile -t files < <(git ls-files 'renovate*.json' '**/renovate*.json' \
| grep -vx 'assets/workspace/renovate.json' || true)
if [ ${#files[@]} -eq 0 ]; then
echo "No Renovate configs found."
exit 0
fi
printf '%s\n' "${files[@]}"
npx --yes --package renovate@latest -c "renovate-config-validator --strict ${files[*]}"
# Clean up lingering containers before running tests
[private]
_test-cleanup-check:
#!/usr/bin/env bash
if podman ps -a --filter "name=workspace-devcontainer" -q 2>/dev/null | grep -q .; then
echo "[!] Lingering test containers found, cleaning up..."
just clean-test-containers
fi
# Run all test suites
[group('test')]
test version="dev":
@just _test-cleanup-check
@just _ensure-dev-image {{ version }}
#!/usr/bin/env bash
TEST_CONTAINER_TAG={{ version }} uv run pytest tests -v -s --tb=short
@just test-bats
@just test-renovate
# ===============================================================================
# RELEASE MANAGEMENT
# ===============================================================================
# Unified release via GitHub Actions (.github/workflows/release.yml, promote-release.yml)
#
# Process:
# 1. just prepare-release X.Y.Z - Create release/X.Y.Z branch, draft PR
# 2. Test release branch, fix bugs as needed via PRs to release branch
# 3. Mark PR ready for review (gh pr ready PR_NUMBER)
# 4. Get PR approval from reviewer
# 5. just finalize-release X.Y.Z - Triggers release.yml (final) that:
# - Validates PR status and all prerequisites
# - Sets release date in CHANGELOG, syncs PR docs
# - Builds and tests container images; creates X.Y.Z tag; pushes versioned GHCR images
# - Creates draft GitHub Release; dispatches smoke-test (not :latest yet)
# - On failure: automatic rollback and issue creation
# 6. Wait for devcontainer-smoke-test to publish its final release for X.Y.Z
# 7. just promote-release X.Y.Z - Triggers promote-release.yml that:
# - Updates GHCR :latest, publishes the draft GitHub Release, merges release PR to main
# - Merging to main triggers sync-main-to-dev.yml (PR main -> dev, auto-merge if clean)
# ===============================================================================
# ===============================================================================
# BUILD / CLEAN
# ===============================================================================
# Remove image (default: dev)
[group('build')]
clean version="dev":
#!/usr/bin/env bash
# Use TEST_REGISTRY from environment if set, otherwise use repo variable
# This allows tests to override the repo via TEST_REGISTRY at runtime
export TEST_REGISTRY
REPO="${TEST_REGISTRY:-{{ repo }}}"
# If TEST_REGISTRY was used and doesn't contain a path, append /test
# This handles cases where TEST_REGISTRY=localhost:PORT instead of localhost:PORT/test
if [[ -n "$TEST_REGISTRY" && "$REPO" == "$TEST_REGISTRY" && "$REPO" != *"/"* ]]; then
REPO="${REPO}/test"
fi
./scripts/clean.sh "{{ version }}" "$REPO"
# Clean up lingering test containers
[group('build')]
clean-test-containers:
#!/usr/bin/env bash
echo "Cleaning Cleaning up lingering test containers..."
FMT=$(printf '\x7b\x7b.ID\x7d\x7d')
DEVCONTAINERS=$(podman ps -a --filter "name=workspace-devcontainer" --format "$FMT" 2>/dev/null)
SIDECARS=$(podman ps -a --filter "name=test-sidecar" --format "$FMT" 2>/dev/null)
if [ -n "$DEVCONTAINERS" ] || [ -n "$SIDECARS" ]; then
if [ -n "$DEVCONTAINERS" ]; then
echo " Removing workspace devcontainers..."
echo "$DEVCONTAINERS" | xargs -r podman rm -f
fi
if [ -n "$SIDECARS" ]; then
echo " Removing test sidecars..."
echo "$SIDECARS" | xargs -r podman rm -f
fi
echo "[OK] Cleanup complete"
else
echo "[*] No lingering test containers found"
fi
# ===============================================================================
# PODMAN
# ===============================================================================
# Podman container & image management recipes
import 'justfile.podman'
import 'justfile.gh'
import 'justfile.worktree'