Skip to content

Modern Docker Management, Designed for Everyone

chore: restructure justfile

Kyle Mendell32e615ab8e3e
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4e640c263..e045265f2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -122,20 +122,29 @@ Press `Ctrl/Cmd+Shift+B` to run the default build task (Start Environment).
### Justfile Shortcuts
-We provide a `Justfile` for common workflows. Run `just --list` to see everything.
+We provide a categorized `Justfile` for common workflows. Run `just --list` to see every category and target.
```bash
-# Dev environment
+# Development
just dev docker
+just dev logs
+
+# Build
+just build single frontend
+just build single backend
# Tests
just test all
+just test backend
-# Linting
+# Quality checks
just lint frontend
-
-# Formatting
just format frontend
+just format all --check
+
+# Dependencies and Go modules
+just deps install all
+just gomod tidy all
```
### Environment Management
diff --git a/Justfile b/Justfile
index 66bdaf2e5..23ea143cd 100644
--- a/Justfile
+++ b/Justfile
@@ -1,3 +1,7 @@
+# -----------------------------------------------------------------------------
+# Project settings
+# -----------------------------------------------------------------------------
+
set working-directory := './'
edge_proto_dir := 'backend/pkg/libarcane/edge/proto'
@@ -5,6 +9,10 @@ edge_proto_dir := 'backend/pkg/libarcane/edge/proto'
_default:
@just --list
+# -----------------------------------------------------------------------------
+# Development
+# -----------------------------------------------------------------------------
+
# Run frontend dev server on port 3000
[group('dev')]
_dev-frontend:
@@ -118,189 +126,326 @@ dev-tls force="false":
echo ""
echo "The local edge agent recipe already pins this cert via EDGE_MTLS_CA_FILE."
-# --- Deploy ---
-# Deploy a local swarm worker plus a locally built Arcane edge agent into DinD.
-#
-# Usage:
+# -----------------------------------------------------------------------------
+# Build
+# -----------------------------------------------------------------------------
-# just deploy swarm agent [agent_token] [manager_url] [node_name] [agent_name] [dind_image] [local_image]
-[group('deploy')]
-_deploy-swarm-agent agent_token="" manager_url="http://host.docker.internal:3552" node_name="swarm-worker-1" agent_name="arcane-edge-agent" dind_image="docker:29-dind" local_image="arcane-headless:swarm-local":
- #!/usr/bin/env bash
- set -euo pipefail
+# Build the frontend
+[group('build')]
+_build-frontend:
+ pnpm -C frontend build
- if ! command -v docker >/dev/null 2>&1; then
- echo "docker is required"
- exit 1
- fi
+# Build the backend
+[group('build')]
+_build-backend:
+ cd backend && go build ./...
- if ! docker info >/dev/null 2>&1; then
- echo "docker daemon is not running"
- exit 1
- fi
+# Build both frontend and backend
+[group('build')]
+_build-all:
+ @just _build-frontend
+ @just _build-backend
- swarm_state="$(docker info 2>/dev/null | awk -F': ' '/Swarm:/{print tolower($2); exit}')"
- swarm_control="$(docker info 2>/dev/null | awk -F': ' '/Is Manager:/{print tolower($2); exit}')"
- if [ "$swarm_state" != "active" ] || [ "$swarm_control" != "true" ]; then
- echo "host docker must already be an active swarm manager"
- exit 1
- fi
+# Build manager container image
+[group('build')]
+_build-image-manager tag="ghcr.io/getarcaneapp/arcane:development" flag='':
+ docker buildx build {{ if flag == "--push" { "--push" } else { "" } }} --platform linux/arm64,linux/amd64,linux/arm/v7 -f 'docker/Dockerfile' --build-arg ENABLED_FEATURES="{{ env('ENABLED_FEATURES', env('BUILD_FEATURES', '')) }}" -t "{{ tag }}" .
- echo "Building local agent image {{ local_image }}..."
- docker build -f docker/Dockerfile-agent -t "{{ local_image }}" .
+# Build agent container image
+[group('build')]
+_build-image-agent tag="ghcr.io/getarcaneapp/arcane-headless:development" flag='':
+ docker buildx build {{ if flag == "--push" { "--push" } else { "" } }} --platform linux/arm64,linux/amd64,linux/arm/v7 -f 'docker/Dockerfile-agent' --build-arg ENABLED_FEATURES="{{ env('ENABLED_FEATURES', env('BUILD_FEATURES', '')) }}" -t "{{ tag }}" .
- if docker inspect "{{ node_name }}" >/dev/null 2>&1; then
- echo "Reusing existing DinD worker {{ node_name }}..."
- docker start "{{ node_name }}" >/dev/null 2>&1 || true
- else
- echo "Starting DinD worker {{ node_name }} from {{ dind_image }}..."
- docker run -d \
- --privileged \
- --name "{{ node_name }}" \
- --hostname "{{ node_name }}" \
- --restart unless-stopped \
- --add-host=host.docker.internal:host-gateway \
- -e DOCKER_TLS_CERTDIR= \
- "{{ dind_image }}"
- fi
+# Build targets. Valid: "single frontend", "single backend", "single all", "image manager [tag] [--push]", "image agent [tag] [--push]"
+[group('build')]
+build buildtype type tag="" flag="":
+ @if [ "{{ buildtype }}" = "single" ]; then just _build-{{ type }}; elif [ "{{ buildtype }}" = "image" ]; then just _build-image-{{ type }} "{{ if tag != "" { tag } else if type == "manager" { "arcane:latest" } else { "arcane-agent:latest" } }}" "{{ flag }}"; fi
- echo "Waiting for inner Docker daemon..."
- for _ in $(seq 1 30); do
- if docker exec "{{ node_name }}" docker info >/dev/null 2>&1; then
- break
- fi
- sleep 1
- done
+# -----------------------------------------------------------------------------
+# Test
+# -----------------------------------------------------------------------------
- if ! docker exec "{{ node_name }}" docker info >/dev/null 2>&1; then
- echo "inner docker daemon did not become ready"
- exit 1
- fi
+# Run Playwright E2E tests
+[group('test')]
+_test-e2e:
+ pnpm -C tests test
- local_node_state="$(docker exec "{{ node_name }}" docker info --format '{{ "{{.Swarm.LocalNodeState}}" }}')"
- if [ "$local_node_state" != "active" ]; then
- join_token="$(docker swarm join-token -q worker)"
- echo "Joining {{ node_name }} to host swarm..."
- docker exec "{{ node_name }}" docker swarm join --token "$join_token" host.docker.internal:2377
- else
- echo "{{ node_name }} is already part of the swarm."
- fi
+# Run backend Go tests
+[group('test')]
+_test-backend:
+ cd backend && go test -tags=exclude_frontend,buildables -ldflags "-X github.com/getarcaneapp/arcane/backend/buildables.EnabledFeatures=autologin" ./... -race -coverprofile=coverage.txt -covermode=atomic -v
- current_node_id="$(docker exec "{{ node_name }}" docker info --format '{{ "{{.Swarm.NodeID}}" }}')"
- echo "Current swarm node ID: $current_node_id"
+# Run CLI tests
+[group('test')]
+_test-cli:
+ cd cli && go test ./... -race -coverprofile=coverage.txt -covermode=atomic -v
- if [ -n "{{ agent_token }}" ] && command -v sqlite3 >/dev/null 2>&1 && [ -f backend/data/arcane.db ]; then
- expected_node_id="$(sqlite3 backend/data/arcane.db "SELECT COALESCE(swarm_node_id, '') FROM environments WHERE access_token = '{{ agent_token }}' LIMIT 1;")"
- if [ -n "$expected_node_id" ] && [ "$expected_node_id" != "$current_node_id" ]; then
- echo "agent token belongs to swarm node $expected_node_id, but {{ node_name }} is $current_node_id"
- echo "Generate a fresh Arcane agent token from the Deploy Agent dialog for node {{ node_name }}, then rerun this command."
- exit 1
- fi
- fi
+# Run shared types Go tests
+[group('test')]
+_test-types:
+ cd types && go test ./... -race -coverprofile=coverage.txt -covermode=atomic -v
- if [ -z "{{ agent_token }}" ]; then
- echo ""
- echo "Swarm worker {{ node_name }} is ready, but no Arcane agent token was provided."
- echo "Open Arcane, click Deploy Agent for node {{ node_name }} (node ID: $current_node_id), copy the generated token, and rerun:"
- echo " just deploy swarm agent <arcane_agent_token> {{ manager_url }} {{ node_name }} {{ agent_name }} {{ dind_image }} {{ local_image }}"
- exit 0
- fi
+[group('test')]
+_test-all:
+ @just _test-e2e
+ @just _test-backend
+ @just _test-cli
+ @just _test-types
- echo "Loading local agent image into {{ node_name }}..."
- docker save "{{ local_image }}" | docker exec -i "{{ node_name }}" docker load >/dev/null
+# Run tests. Valid targets: "e2e", "backend", "cli", "types", "all".
+[group('test')]
+test target="all":
+ @just "_test-{{ target }}"
- echo "Starting agent container {{ agent_name }} inside {{ node_name }}..."
- docker exec "{{ node_name }}" sh -lc '
- docker rm -f "{{ agent_name }}" >/dev/null 2>&1 || true
- docker run -d \
- --name "{{ agent_name }}" \
- --restart unless-stopped \
- -e EDGE_AGENT=true \
- -e EDGE_TRANSPORT=poll \
- -e AGENT_TOKEN="{{ agent_token }}" \
- -e MANAGER_API_URL="{{ manager_url }}" \
- -v /var/run/docker.sock:/var/run/docker.sock \
- -v arcane-data:/app/data \
- "{{ local_image }}"
- '
+# -----------------------------------------------------------------------------
+# Quality: format, lint, and fixes
+# -----------------------------------------------------------------------------
- echo ""
- echo "Swarm worker {{ node_name }} and local agent {{ agent_name }} are up."
- echo "Verify:"
- echo " docker node ls"
- echo " docker exec {{ node_name }} docker ps"
- echo " docker exec {{ node_name }} docker logs {{ agent_name }}"
+# Format frontend (Prettier), test/email TypeScript (oxfmt), and Go modules (gofmt)
+[group('quality')]
+_format-frontend:
+ pnpm -C frontend format
-# Remove a local swarm worker plus its Arcane edge agent from DinD.
-#
-# Usage:
-#
+[group('quality')]
+_format-js:
+ pnpm -C tests exec oxfmt "**/*.{ts,tsx,js,jsx,mts,cts}"
+ pnpm -C email-templates exec oxfmt "**/*.{ts,tsx,js,jsx,mts,cts}"
-# just remove swarm agent [node_name] [agent_name]
-[group('deploy')]
-_remove-swarm-agent node_name="swarm-worker-1" agent_name="arcane-edge-agent":
+[group('quality')]
+_format-go:
+ cd backend && gofmt -s -w .
+ cd cli && gofmt -s -w .
+ cd types && gofmt -s -w .
+
+[group('quality')]
+_format-just:
+ just --fmt --unstable
+
+[group('quality')]
+_format-check-frontend:
+ pnpm -C frontend format:check
+
+[group('quality')]
+_format-check-js:
+ pnpm -C tests exec oxfmt --check "**/*.{ts,tsx,js,jsx,mts,cts}"
+ pnpm -C email-templates exec oxfmt --check "**/*.{ts,tsx,js,jsx,mts,cts}"
+
+[group('quality')]
+_format-check-go:
#!/usr/bin/env bash
set -euo pipefail
- if ! command -v docker >/dev/null 2>&1; then
- echo "docker is required"
+ unformatted=$(gofmt -l backend cli types)
+ if [ -n "$unformatted" ]; then
+ echo "Unformatted Go files:"
+ echo "$unformatted"
exit 1
fi
- if ! docker info >/dev/null 2>&1; then
- echo "docker daemon is not running"
- exit 1
- fi
+[group('quality')]
+_format-all:
+ @just _format-frontend
+ @just _format-js
+ @just _format-go
+ @just _format-just
- if ! docker inspect "{{ node_name }}" >/dev/null 2>&1; then
- echo "container {{ node_name }} does not exist"
- exit 1
- fi
+[group('quality')]
+_format-check-all:
+ @just _format-check-frontend
+ @just _format-check-js
+ @just _format-check-go
- echo "Stopping inner agent container {{ agent_name }} inside {{ node_name }}..."
- docker exec "{{ node_name }}" sh -lc 'docker rm -f "{{ agent_name }}" >/dev/null 2>&1 || true'
+# Format targets. Valid: "frontend", "js", "go", "just", "all". Use --check to verify formatting.
+[group('quality')]
+format target="all" check="":
+ @if [ "{{ check }}" = "--check" ]; then just "_format-check-{{ target }}"; else just "_format-{{ target }}"; fi
- node_id=""
- if docker exec "{{ node_name }}" docker info >/dev/null 2>&1; then
- local_node_state="$(docker exec "{{ node_name }}" docker info --format '{{ "{{.Swarm.LocalNodeState}}" }}' 2>/dev/null || true)"
- if [ "$local_node_state" = "active" ]; then
- node_id="$(docker exec "{{ node_name }}" docker info --format '{{ "{{.Swarm.NodeID}}" }}' 2>/dev/null || true)"
- echo "Leaving swarm from {{ node_name }}..."
- docker exec "{{ node_name }}" docker swarm leave -f >/dev/null 2>&1 || true
- fi
- fi
+# Type check/Lint frontend
+[group('quality')]
+_lint-frontend:
+ pnpm -C frontend check
- if [ -n "$node_id" ]; then
- echo "Removing swarm node $node_id from host manager..."
- docker node rm -f "$node_id" >/dev/null 2>&1 || true
- fi
+# Lint Go backend
+[group('quality')]
+_lint-backend:
+ cd backend && golangci-lint run -c ../.github/.golangci.yml ./...
- echo "Removing DinD worker container {{ node_name }} from host..."
- docker rm -f "{{ node_name }}" >/dev/null
+# Lint Go CLI
+[group('quality')]
+_lint-cli:
+ cd cli && golangci-lint run -c ../.github/.golangci.yml ./...
- echo ""
- echo "Removed swarm worker {{ node_name }} and inner agent {{ agent_name }}."
+# Lint Types
+[group('quality')]
+_lint-types:
+ cd types && golangci-lint run -c ../.github/.golangci.yml ./...
-# Deploy targets. Example: just deploy swarm agent [agent_token]
-[group('deploy')]
-deploy scope kind *args:
- @just "_deploy-{{ scope }}-{{ kind }}" {{ args }}
+# Lint all Go code
+[group('quality')]
+_lint-go: _lint-backend _lint-cli _lint-types
-# Generate edge tunnel protobuf/gRPC code.
-[group('proto')]
-proto-backend:
- cd {{ edge_proto_dir }} && go run github.com/bufbuild/buf/cmd/[email protected] generate
+[group('quality')]
+_lint-all:
+ @just _lint-frontend
+ @just _lint-go
-# Generate the docs config schema JSON.
-[group('docs')]
-_docs-config output="" source_root=".":
- #!/usr/bin/env bash
- set -euo pipefail
+# Lint targets. Valid: "backend", "frontend", "cli", "types" "all".
+[group('quality')]
+lint target="all":
+ @just "_lint-{{ target }}"
- cmd=(go run -tags exclude_frontend ./backend/cmd config-schema --source-root "{{ source_root }}")
- if [ -n "{{ output }}" ]; then
- cmd+=(--output "{{ output }}")
- fi
+# Fix Go backend
+[group('quality')]
+_fix-backend:
+ cd backend && go fix ./...
+
+# Fix Go CLI
+[group('quality')]
+_fix-cli:
+ cd cli && go fix ./...
+
+# Fix Types
+[group('quality')]
+_fix-types:
+ cd types && go fix ./...
+
+# Fix all Go code
+[group('quality')]
+_fix-go: _fix-backend _fix-cli _fix-types
+
+[group('quality')]
+_fix-all:
+ @just _fix-go
+
+# Fix targets. Valid: "backend", "cli", "types", "go", "all".
+[group('quality')]
+fix target="all":
+ @just "_fix-{{ target }}"
+
+# -----------------------------------------------------------------------------
+# Dependencies
+# -----------------------------------------------------------------------------
+
+# Install frontend dependencies
+[group('deps')]
+_deps-install-frontend:
+ pnpm install
+
+# Install tests dependencies
+[group('deps')]
+_deps-install-tests:
+ pnpm -C tests install
+ pnpm -C tests exec playwright install --with-deps chromium
+
+# Install backend Go dependencies
+[group('deps')]
+_deps-install-backend:
+ cd backend && go mod download
+ go work sync
+
+# Install CLI Go dependencies
+[group('deps')]
+_deps-install-cli:
+ cd cli && go mod download
+ go work sync
+
+# Install types Go dependencies
+[group('deps')]
+_deps-install-types:
+ cd types && go mod download
+ go work sync
+
+# Install all Go dependencies
+[group('deps')]
+_deps-install-go: _deps-install-backend _deps-install-cli _deps-install-types
+
+# Install all Node.js dependencies
+[group('deps')]
+_deps-install-node: _deps-install-frontend _deps-install-tests
+
+# Install all dependencies
+[group('deps')]
+_deps-install-all: _deps-install-node _deps-install-go
+
+# Update frontend dependencies
+[group('deps')]
+_deps-update-frontend:
+ pnpm update
+
+# Update backend Go dependencies
+[group('deps')]
+_deps-update-backend:
+ cd backend && go get -u ./... && go mod tidy
+
+# Update pnpm version via corepack
+[group('deps')]
+_deps-update-pnpm:
+ npx corepack up
+
+[group('deps')]
+_deps-update-all: _deps-update-frontend _deps-update-backend _deps-update-pnpm
+
+# Deps targets. Valid: "install [frontend|tests|backend|cli|types|go|node|all]", "update [frontend|backend|pnpm|all]"
+[group('deps')]
+deps action="update" target="all":
+ @just "_deps-{{ action }}-{{ target }}"
+
+# -----------------------------------------------------------------------------
+# Go modules
+# -----------------------------------------------------------------------------
+
+# Run go mod tidy in backend module
+[group('go-modules')]
+_gomod-tidy-backend:
+ cd backend && go mod tidy
+
+# Run go mod tidy in CLI module
+[group('go-modules')]
+_gomod-tidy-cli:
+ cd cli && go mod tidy
+
+# Run go mod tidy in types module
+[group('go-modules')]
+_gomod-tidy-types:
+ cd types && go mod tidy
+
+# Run go mod tidy in all Go modules
+[group('go-modules')]
+_gomod-tidy-go: _gomod-tidy-backend _gomod-tidy-cli _gomod-tidy-types
+
+[group('go-modules')]
+_gomod-tidy-all:
+ @just _gomod-tidy-go
+ go work sync
+
+[group('go-modules')]
+_gomod-sync-all:
+ go work sync
+
+# Go module targets. Valid: "tidy [backend|cli|types|go|all]", "sync all".
+[group('go-modules')]
+gomod action="tidy" target="all":
+ @just "_gomod-{{ action }}-{{ target }}"
+
+# -----------------------------------------------------------------------------
+# Code generation and docs
+# -----------------------------------------------------------------------------
+
+# Generate edge tunnel protobuf/gRPC code.
+[group('codegen')]
+proto-backend:
+ cd {{ edge_proto_dir }} && go run github.com/bufbuild/buf/cmd/[email protected] generate
+
+# Generate the docs config schema JSON.
+[group('docs')]
+_docs-config output="" source_root=".":
+ #!/usr/bin/env bash
+ set -euo pipefail
+
+ cmd=(go run -tags exclude_frontend ./backend/cmd config-schema --source-root "{{ source_root }}")
+ if [ -n "{{ output }}" ]; then
+ cmd+=(--output "{{ output }}")
+ fi
"${cmd[@]}"
@@ -309,19 +454,9 @@ _docs-config output="" source_root=".":
docs target *args:
@just "_docs-{{ target }}" {{ args }}
-# Benchmark edge tunnel transport performance (gRPC vs WebSocket) with allocations.
-
-# Usage: just bench-edge-tunnel [count] [benchtime]
-[group('bench')]
-bench-edge-tunnel count="3" benchtime="2s":
- cd backend && go test -run '^$' -bench '^BenchmarkEdgeTunnelProxyRequest$' -benchmem -count={{ count }} -benchtime={{ benchtime }} ./pkg/libarcane/edge
-
-# Benchmark edge tunnel transport and write memory profile.
-
-# Usage: just bench-edge-tunnel-mem [profile] [benchtime]
-[group('bench')]
-bench-edge-tunnel-mem profile="edge_tunnel.mem.out" benchtime="5s":
- cd backend && go test -run '^$' -bench '^BenchmarkEdgeTunnelProxyRequest$' -benchmem -benchtime={{ benchtime }} -memprofile={{ profile }} ./pkg/libarcane/edge
+# -----------------------------------------------------------------------------
+# Localization
+# -----------------------------------------------------------------------------
# Add a new i18n locale. Example:
@@ -446,98 +581,217 @@ i18n-add locale native_name settings="frontend/project.inlang/settings.json" pic
echo "Created messages file: $target_file"
fi
-# --- Utils ---
+# -----------------------------------------------------------------------------
+# Benchmarks
+# -----------------------------------------------------------------------------
-[group('utils')]
-_utils-list-fixes:
+# Benchmark edge tunnel transport performance (gRPC vs WebSocket) with allocations.
+
+# Usage: just bench-edge-tunnel [count] [benchtime]
+[group('bench')]
+bench-edge-tunnel count="3" benchtime="2s":
+ cd backend && go test -run '^$' -bench '^BenchmarkEdgeTunnelProxyRequest$' -benchmem -count={{ count }} -benchtime={{ benchtime }} ./pkg/libarcane/edge
+
+# Benchmark edge tunnel transport and write memory profile.
+
+# Usage: just bench-edge-tunnel-mem [profile] [benchtime]
+[group('bench')]
+bench-edge-tunnel-mem profile="edge_tunnel.mem.out" benchtime="5s":
+ cd backend && go test -run '^$' -bench '^BenchmarkEdgeTunnelProxyRequest$' -benchmem -benchtime={{ benchtime }} -memprofile={{ profile }} ./pkg/libarcane/edge
+
+# -----------------------------------------------------------------------------
+# Deploy
+# -----------------------------------------------------------------------------
+
+# Deploy a local swarm worker plus a locally built Arcane edge agent into DinD.
+#
+# Usage:
+
+# just deploy swarm agent [agent_token] [manager_url] [node_name] [agent_name] [dind_image] [local_image]
+[group('deploy')]
+_deploy-swarm-agent agent_token="" manager_url="http://host.docker.internal:3552" node_name="swarm-worker-1" agent_name="arcane-edge-agent" dind_image="docker:29-dind" local_image="arcane-headless:swarm-local":
#!/usr/bin/env bash
set -euo pipefail
- TEST=false
- VERBOSE=false
- for arg in "$@"; do
- case "$arg" in
- --test)
- TEST=true
- ;;
- --verbose)
- VERBOSE=true
- ;;
- *)
- ;;
- esac
- done
+ if ! command -v docker >/dev/null 2>&1; then
+ echo "docker is required"
+ exit 1
+ fi
- if [ "$VERBOSE" == true ]; then
- set -x
+ if ! docker info >/dev/null 2>&1; then
+ echo "docker daemon is not running"
+ exit 1
fi
- # Colors for output
- GREEN='\033[0;32m'
- YELLOW='\033[1;33m'
- BLUE='\033[0;34m'
- NC='\033[0m' # No Color
+ swarm_state="$(docker info 2>/dev/null | awk -F': ' '/Swarm:/{print tolower($2); exit}')"
+ swarm_control="$(docker info 2>/dev/null | awk -F': ' '/Is Manager:/{print tolower($2); exit}')"
+ if [ "$swarm_state" != "active" ] || [ "$swarm_control" != "true" ]; then
+ echo "host docker must already be an active swarm manager"
+ exit 1
+ fi
- # Get the latest release tag
- LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
+ echo "Building local agent image {{ local_image }}..."
+ docker build -f docker/Dockerfile-agent -t "{{ local_image }}" .
- if [ -z "$LATEST_TAG" ]; then
- echo -e "${YELLOW}No previous release tag found. Showing all fix commits:${NC}"
- RANGE="HEAD"
+ if docker inspect "{{ node_name }}" >/dev/null 2>&1; then
+ echo "Reusing existing DinD worker {{ node_name }}..."
+ docker start "{{ node_name }}" >/dev/null 2>&1 || true
else
- echo -e "${GREEN}Latest release: ${LATEST_TAG}${NC}"
- RANGE="${LATEST_TAG}..HEAD"
+ echo "Starting DinD worker {{ node_name }} from {{ dind_image }}..."
+ docker run -d \
+ --privileged \
+ --name "{{ node_name }}" \
+ --hostname "{{ node_name }}" \
+ --restart unless-stopped \
+ --add-host=host.docker.internal:host-gateway \
+ -e DOCKER_TLS_CERTDIR= \
+ "{{ dind_image }}"
fi
- echo ""
- echo -e "${BLUE}=== Fix commits on main branch since ${LATEST_TAG:-beginning} ===${NC}"
- echo ""
+ echo "Waiting for inner Docker daemon..."
+ for _ in $(seq 1 30); do
+ if docker exec "{{ node_name }}" docker info >/dev/null 2>&1; then
+ break
+ fi
+ sleep 1
+ done
- # List all fix commits
- FIX_COMMITS=$(git log "$RANGE" \
- --oneline \
- --no-merges \
- --grep="^fix:" \
- --grep="^hotfix:" \
- --regexp-ignore-case \
- --pretty=format:"%C(yellow)%h%Creset %C(green)%ai%Creset %s %C(dim)(%an)%Creset" || echo "")
+ if ! docker exec "{{ node_name }}" docker info >/dev/null 2>&1; then
+ echo "inner docker daemon did not become ready"
+ exit 1
+ fi
- if [ -z "$FIX_COMMITS" ]; then
- echo "No fix commits found."
+ local_node_state="$(docker exec "{{ node_name }}" docker info --format '{{ "{{.Swarm.LocalNodeState}}" }}')"
+ if [ "$local_node_state" != "active" ]; then
+ join_token="$(docker swarm join-token -q worker)"
+ echo "Joining {{ node_name }} to host swarm..."
+ docker exec "{{ node_name }}" docker swarm join --token "$join_token" host.docker.internal:2377
else
- echo "$FIX_COMMITS"
+ echo "{{ node_name }} is already part of the swarm."
fi
+ current_node_id="$(docker exec "{{ node_name }}" docker info --format '{{ "{{.Swarm.NodeID}}" }}')"
+ echo "Current swarm node ID: $current_node_id"
+
+ if [ -n "{{ agent_token }}" ] && command -v sqlite3 >/dev/null 2>&1 && [ -f backend/data/arcane.db ]; then
+ expected_node_id="$(sqlite3 backend/data/arcane.db "SELECT COALESCE(swarm_node_id, '') FROM environments WHERE access_token = '{{ agent_token }}' LIMIT 1;")"
+ if [ -n "$expected_node_id" ] && [ "$expected_node_id" != "$current_node_id" ]; then
+ echo "agent token belongs to swarm node $expected_node_id, but {{ node_name }} is $current_node_id"
+ echo "Generate a fresh Arcane agent token from the Deploy Agent dialog for node {{ node_name }}, then rerun this command."
+ exit 1
+ fi
+ fi
+
+ if [ -z "{{ agent_token }}" ]; then
+ echo ""
+ echo "Swarm worker {{ node_name }} is ready, but no Arcane agent token was provided."
+ echo "Open Arcane, click Deploy Agent for node {{ node_name }} (node ID: $current_node_id), copy the generated token, and rerun:"
+ echo " just deploy swarm agent <arcane_agent_token> {{ manager_url }} {{ node_name }} {{ agent_name }} {{ dind_image }} {{ local_image }}"
+ exit 0
+ fi
+
+ echo "Loading local agent image into {{ node_name }}..."
+ docker save "{{ local_image }}" | docker exec -i "{{ node_name }}" docker load >/dev/null
+
+ echo "Starting agent container {{ agent_name }} inside {{ node_name }}..."
+ docker exec "{{ node_name }}" sh -lc '
+ docker rm -f "{{ agent_name }}" >/dev/null 2>&1 || true
+ docker run -d \
+ --name "{{ agent_name }}" \
+ --restart unless-stopped \
+ -e EDGE_AGENT=true \
+ -e EDGE_TRANSPORT=poll \
+ -e AGENT_TOKEN="{{ agent_token }}" \
+ -e MANAGER_API_URL="{{ manager_url }}" \
+ -v /var/run/docker.sock:/var/run/docker.sock \
+ -v arcane-data:/app/data \
+ "{{ local_image }}"
+ '
+
echo ""
- echo ""
- echo -e "${BLUE}=== How to create a hotfix release ===${NC}"
- echo ""
- echo "1. Start the hotfix release process:"
- echo -e " ${GREEN}just utils hotfix${NC}"
- echo ""
- echo "2. Cherry-pick the fixes you want:"
- echo -e " ${GREEN}git cherry-pick <commit-hash>${NC}"
- echo ""
- echo "3. Finalize the release:"
- echo -e " ${GREEN}just utils hotfix${NC}"
- echo ""
+ echo "Swarm worker {{ node_name }} and local agent {{ agent_name }} are up."
+ echo "Verify:"
+ echo " docker node ls"
+ echo " docker exec {{ node_name }} docker ps"
+ echo " docker exec {{ node_name }} docker logs {{ agent_name }}"
- if [ "$TEST" == true ]; then
- echo "Test mode: no changes were made."
+# Remove a local swarm worker plus its Arcane edge agent from DinD.
+#
+# Usage:
+#
+
+# just remove swarm agent [node_name] [agent_name]
+[group('deploy')]
+_remove-swarm-agent node_name="swarm-worker-1" agent_name="arcane-edge-agent":
+ #!/usr/bin/env bash
+ set -euo pipefail
+
+ if ! command -v docker >/dev/null 2>&1; then
+ echo "docker is required"
+ exit 1
fi
-[group('utils')]
-_utils-hotfix:
+ if ! docker info >/dev/null 2>&1; then
+ echo "docker daemon is not running"
+ exit 1
+ fi
+
+ if ! docker inspect "{{ node_name }}" >/dev/null 2>&1; then
+ echo "container {{ node_name }} does not exist"
+ exit 1
+ fi
+
+ echo "Stopping inner agent container {{ agent_name }} inside {{ node_name }}..."
+ docker exec "{{ node_name }}" sh -lc 'docker rm -f "{{ agent_name }}" >/dev/null 2>&1 || true'
+
+ node_id=""
+ if docker exec "{{ node_name }}" docker info >/dev/null 2>&1; then
+ local_node_state="$(docker exec "{{ node_name }}" docker info --format '{{ "{{.Swarm.LocalNodeState}}" }}' 2>/dev/null || true)"
+ if [ "$local_node_state" = "active" ]; then
+ node_id="$(docker exec "{{ node_name }}" docker info --format '{{ "{{.Swarm.NodeID}}" }}' 2>/dev/null || true)"
+ echo "Leaving swarm from {{ node_name }}..."
+ docker exec "{{ node_name }}" docker swarm leave -f >/dev/null 2>&1 || true
+ fi
+ fi
+
+ if [ -n "$node_id" ]; then
+ echo "Removing swarm node $node_id from host manager..."
+ docker node rm -f "$node_id" >/dev/null 2>&1 || true
+ fi
+
+ echo "Removing DinD worker container {{ node_name }} from host..."
+ docker rm -f "{{ node_name }}" >/dev/null
+
+ echo ""
+ echo "Removed swarm worker {{ node_name }} and inner agent {{ agent_name }}."
+
+# Deploy targets. Example: just deploy swarm agent [agent_token]
+[group('deploy')]
+deploy scope kind *args:
+ @just "_deploy-{{ scope }}-{{ kind }}" {{ args }}
+
+# -----------------------------------------------------------------------------
+# Release
+# -----------------------------------------------------------------------------
+
+# Create a new release (use --test to dry-run without writing anything)
+[group('release')]
+release *args:
#!/usr/bin/env bash
set -euo pipefail
TEST=false
+ FORCE_MAJOR=false
VERBOSE=false
+ set -- {{ args }}
for arg in "$@"; do
case "$arg" in
--test)
TEST=true
;;
+ --major)
+ FORCE_MAJOR=true
+ ;;
--verbose)
VERBOSE=true
;;
@@ -548,93 +802,376 @@ _utils-hotfix:
CLIFF_VERBOSE=""
if [ "$VERBOSE" == true ]; then
- set -x
CLIFF_VERBOSE="-vv"
fi
- # Colors for output
- RED='\033[0;31m'
- GREEN='\033[0;32m'
- YELLOW='\033[1;33m'
- BLUE='\033[0;34m'
- NC='\033[0m' # No Color
-
# Check if the script is being run from the root of the project
if [ ! -f .arcane.json ] || [ ! -f frontend/package.json ] || [ ! -f CHANGELOG.md ]; then
- echo -e "${RED}Error: This command must be run from the root of the project.${NC}"
+ echo "Error: This command must be run from the root of the project."
exit 1
fi
- CLIFF_CMD=""
- if command -v git-cliff &>/dev/null; then
- CLIFF_CMD="git-cliff"
- elif git cliff --version &>/dev/null; then
- CLIFF_CMD="git cliff"
- else
+ # Check if git cliff is installed
+ if ! command -v git cliff &>/dev/null; then
echo "Error: git cliff is not installed. Please install it from https://git-cliff.org/docs/installation."
exit 1
fi
# Check if GitHub CLI is installed
if ! command -v gh &>/dev/null; then
- echo -e "${RED}Error: GitHub CLI (gh) is not installed. Please install it and authenticate using 'gh auth login'.${NC}"
+ echo "Error: GitHub CLI (gh) is not installed. Please install it and authenticate using 'gh auth login'."
exit 1
fi
- # Ensure local tags are up to date
+ # Ensure local tags are up to date (don't fail if no remote)
git fetch --tags --quiet || true
- # Get the latest repo-wide release tag (ignore module tags like cli/v* or types/v*)
- get_latest_repo_tag() {
- local ref="${1:-HEAD}"
- git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname --merged "$ref" | head -n1
- }
+ # Check if we're on the main branch (skip in test mode)
+ if [ "$TEST" == false ] && [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
+ echo "Error: This command must be run on the main branch."
+ exit 1
+ fi
- cherry_pick_in_progress() {
- git rev-parse -q --verify CHERRY_PICK_HEAD >/dev/null 2>&1
- }
+ # Read the current version from .arcane.json
+ VERSION=$(jq -r '.version' .arcane.json)
- has_unmerged_conflicts() {
- [ -n "$(git diff --name-only --diff-filter=U)" ]
- }
+ # Function to increment the version
+ increment_version() {
+ local version=$1
+ local part=$2
- working_tree_dirty() {
- [ -n "$(git status --porcelain)" ]
+ IFS='.' read -r -a parts <<<"$version"
+ if [ "$part" == "major" ]; then
+ parts[0]=$((parts[0] + 1))
+ parts[1]=0
+ parts[2]=0
+ elif [ "$part" == "minor" ]; then
+ parts[1]=$((parts[1] + 1))
+ parts[2]=0
+ elif [ "$part" == "patch" ]; then
+ parts[2]=$((parts[2] + 1))
+ fi
+ echo "${parts[0]}.${parts[1]}.${parts[2]}"
}
- LATEST_TAG=$(get_latest_repo_tag "main")
- if [ -z "$LATEST_TAG" ]; then
- LATEST_TAG=$(get_latest_repo_tag "HEAD")
+ # Determine the release type
+ if [ "$FORCE_MAJOR" == true ]; then
+ RELEASE_TYPE="major"
+ else
+ # Get the latest version tag (v*), ignoring non-version tags like 'next'
+ LATEST_TAG=$(git tag -l 'v*' --sort=-v:refname | head -n1 || echo "")
+ if [ -z "$LATEST_TAG" ]; then
+ RELEASE_TYPE="minor"
+ else
+ # Look only at commit subjects since the last tag (exclude merges)
+ SUBJECTS=$(git log --no-merges --format=%s "${LATEST_TAG}..HEAD")
+
+ if echo "$SUBJECTS" | grep -Eiq '^feat(\([^)]+\))?: '; then
+ RELEASE_TYPE="minor"
+ elif echo "$SUBJECTS" | grep -Eiq '^fix(\([^)]+\))?: '; then
+ RELEASE_TYPE="patch"
+ else
+ echo "No 'fix' or 'feat' commits found since the latest release (${LATEST_TAG}). No new release will be created."
+ echo "Commits since ${LATEST_TAG}:"
+ git log --oneline --no-merges "${LATEST_TAG}..HEAD" || true
+ exit 0
+ fi
+ fi
fi
- if [ -z "$LATEST_TAG" ]; then
- echo -e "${RED}Error: No previous release tag found.${NC}"
+
+ # Increment the version based on the release type
+ if [ "$RELEASE_TYPE" == "major" ]; then
+ echo "Performing major release..."
+ NEW_VERSION=$(increment_version "$VERSION" major)
+ elif [ "$RELEASE_TYPE" == "minor" ]; then
+ echo "Performing minor release..."
+ NEW_VERSION=$(increment_version "$VERSION" minor)
+ elif [ "$RELEASE_TYPE" == "patch" ]; then
+ echo "Performing patch release..."
+ NEW_VERSION=$(increment_version "$VERSION" patch)
+ else
+ echo "Invalid release type. Please enter either 'major', 'minor', or 'patch'."
exit 1
fi
- echo -e "${GREEN}Latest release tag: ${LATEST_TAG}${NC}"
+ if [ "$TEST" == true ]; then
+ echo "Test mode enabled: no files will be modified, no commits/tags/pushes/releases will be created."
+ else
+ # Confirm release creation
+ read -p "This will create a new $RELEASE_TYPE release with version $NEW_VERSION. Do you want to proceed? (y/n) " CONFIRM
+ if [[ "$CONFIRM" != "y" ]]; then
+ echo "Release process canceled."
+ exit 1
+ fi
+ fi
- # Extract version components from tag (format: v1.2.3)
- VERSION=${LATEST_TAG#v}
- IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
+ LATEST_REVISION=$(git rev-parse HEAD)
- # Increment patch version for hotfix
- NEW_PATCH=$((PATCH + 1))
- NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
- NEW_TAG="v${NEW_VERSION}"
+ if [ "$TEST" == false ]; then
+ # Update .arcane.json file with the new version, revision, and build time
+ echo "Updating .arcane.json file..."
+ BUILD_TIME=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
+ jq --arg version "$NEW_VERSION" --arg revision "$LATEST_REVISION" --arg build_time "$BUILD_TIME" \
+ '.version = $version | .revision = $revision | .buildTime = $build_time' .arcane.json > .arcane_tmp.json && mv .arcane_tmp.json .arcane.json
+ git add .arcane.json
- echo -e "${YELLOW}Proposed hotfix version: ${NEW_TAG}${NC}"
+ # Update version in frontend/package.json
+ jq --arg new_version "$NEW_VERSION" '.version = $new_version' frontend/package.json > frontend/package_tmp.json && mv frontend/package_tmp.json frontend/package.json
+ git add frontend/package.json
- # Create release branch name
- RELEASE_BRANCH="release/v${MAJOR}.${MINOR}"
+ # Generate changelog
+ echo "Generating changelog..."
+ git cliff $CLIFF_VERBOSE --github-token=$(gh auth token) --prepend CHANGELOG.md --tag "v$NEW_VERSION" --unreleased
+ git add CHANGELOG.md
- echo ""
- echo -e "${YELLOW}=== Available fix commits since ${LATEST_TAG} ===${NC}"
- echo ""
+ # Commit the changes with the new version
+ git commit -m "release: $NEW_VERSION"
- # List all fix commits since the last tag
- FIX_COMMITS=$(git log "${LATEST_TAG}..main" \
- --oneline \
- --no-merges \
+ # Create Git tags with the new version
+ TAG_MESSAGE="$NEW_VERSION"
+ git tag -a "v$NEW_VERSION" -m "$TAG_MESSAGE"
+ git tag -a "cli/v$NEW_VERSION" -m "$TAG_MESSAGE"
+ git tag -a "types/v$NEW_VERSION" -m "$TAG_MESSAGE"
+ git tag -a "backend/v$NEW_VERSION" -m "$TAG_MESSAGE"
+
+ # Push the commit and tags in two steps to ensure the release workflow triggers on v* tag push
+ git push
+ git push origin "v$NEW_VERSION"
+ git push origin "cli/v$NEW_VERSION" "types/v$NEW_VERSION" "backend/v$NEW_VERSION"
+
+ # Extract the changelog content for the latest release
+ echo "Extracting changelog content for version $NEW_VERSION..."
+ CHANGELOG=$(awk '/^## v[0-9]/ { if (found) exit; found=1; next } found' CHANGELOG.md)
+
+ if [ -z "$CHANGELOG" ]; then
+ echo "Error: Could not extract changelog for version $NEW_VERSION."
+ exit 1
+ fi
+
+ # Create the draft release on GitHub
+ echo "Creating GitHub draft release..."
+ gh release create "v$NEW_VERSION" --title "v$NEW_VERSION" --notes "$CHANGELOG" --draft
+
+ if [ $? -eq 0 ]; then
+ echo "GitHub draft release created successfully."
+ else
+ echo "Error: Failed to create GitHub release."
+ exit 1
+ fi
+
+ echo "Release process complete. New version: $NEW_VERSION"
+ else
+ echo "Test mode: skipping confirmation prompt and all write operations."
+ BUILD_TIME=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
+ echo "Would update .arcane.json to version $NEW_VERSION, revision $LATEST_REVISION, and buildTime $BUILD_TIME"
+ echo "Would update frontend/package.json to version $NEW_VERSION"
+ echo "Generating changelog preview (no file write)..."
+ CHANGELOG=$(git cliff $CLIFF_VERBOSE --github-token=$(gh auth token) --tag "v$NEW_VERSION" --unreleased)
+
+ if [ -z "$CHANGELOG" ]; then
+ echo "Error: Could not generate changelog preview for version $NEW_VERSION."
+ exit 1
+ fi
+
+ echo "----- BEGIN CHANGELOG PREVIEW -----"
+ echo "$CHANGELOG"
+ echo "----- END CHANGELOG PREVIEW -----"
+ echo "Would commit: release: $NEW_VERSION"
+ echo "Would tag: v$NEW_VERSION, cli/v$NEW_VERSION, types/v$NEW_VERSION, backend/v$NEW_VERSION"
+ echo "Would push commit"
+ echo "Would push tag: v$NEW_VERSION"
+ echo "Would push tags: cli/v$NEW_VERSION, types/v$NEW_VERSION, backend/v$NEW_VERSION"
+ echo "Would create GitHub draft release v$NEW_VERSION"
+ echo "Test mode complete. No changes were written."
+ fi
+
+[group('release')]
+_utils-list-fixes:
+ #!/usr/bin/env bash
+ set -euo pipefail
+
+ TEST=false
+ VERBOSE=false
+ for arg in "$@"; do
+ case "$arg" in
+ --test)
+ TEST=true
+ ;;
+ --verbose)
+ VERBOSE=true
+ ;;
+ *)
+ ;;
+ esac
+ done
+
+ if [ "$VERBOSE" == true ]; then
+ set -x
+ fi
+
+ # Colors for output
+ GREEN='\033[0;32m'
+ YELLOW='\033[1;33m'
+ BLUE='\033[0;34m'
+ NC='\033[0m' # No Color
+
+ # Get the latest release tag
+ LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
+
+ if [ -z "$LATEST_TAG" ]; then
+ echo -e "${YELLOW}No previous release tag found. Showing all fix commits:${NC}"
+ RANGE="HEAD"
+ else
+ echo -e "${GREEN}Latest release: ${LATEST_TAG}${NC}"
+ RANGE="${LATEST_TAG}..HEAD"
+ fi
+
+ echo ""
+ echo -e "${BLUE}=== Fix commits on main branch since ${LATEST_TAG:-beginning} ===${NC}"
+ echo ""
+
+ # List all fix commits
+ FIX_COMMITS=$(git log "$RANGE" \
+ --oneline \
+ --no-merges \
+ --grep="^fix:" \
+ --grep="^hotfix:" \
+ --regexp-ignore-case \
+ --pretty=format:"%C(yellow)%h%Creset %C(green)%ai%Creset %s %C(dim)(%an)%Creset" || echo "")
+
+ if [ -z "$FIX_COMMITS" ]; then
+ echo "No fix commits found."
+ else
+ echo "$FIX_COMMITS"
+ fi
+
+ echo ""
+ echo ""
+ echo -e "${BLUE}=== How to create a hotfix release ===${NC}"
+ echo ""
+ echo "1. Start the hotfix release process:"
+ echo -e " ${GREEN}just utils hotfix${NC}"
+ echo ""
+ echo "2. Cherry-pick the fixes you want:"
+ echo -e " ${GREEN}git cherry-pick <commit-hash>${NC}"
+ echo ""
+ echo "3. Finalize the release:"
+ echo -e " ${GREEN}just utils hotfix${NC}"
+ echo ""
+
+ if [ "$TEST" == true ]; then
+ echo "Test mode: no changes were made."
+ fi
+
+[group('release')]
+_utils-hotfix:
+ #!/usr/bin/env bash
+ set -euo pipefail
+
+ TEST=false
+ VERBOSE=false
+ for arg in "$@"; do
+ case "$arg" in
+ --test)
+ TEST=true
+ ;;
+ --verbose)
+ VERBOSE=true
+ ;;
+ *)
+ ;;
+ esac
+ done
+
+ CLIFF_VERBOSE=""
+ if [ "$VERBOSE" == true ]; then
+ set -x
+ CLIFF_VERBOSE="-vv"
+ fi
+
+ # Colors for output
+ RED='\033[0;31m'
+ GREEN='\033[0;32m'
+ YELLOW='\033[1;33m'
+ BLUE='\033[0;34m'
+ NC='\033[0m' # No Color
+
+ # Check if the script is being run from the root of the project
+ if [ ! -f .arcane.json ] || [ ! -f frontend/package.json ] || [ ! -f CHANGELOG.md ]; then
+ echo -e "${RED}Error: This command must be run from the root of the project.${NC}"
+ exit 1
+ fi
+
+ CLIFF_CMD=""
+ if command -v git-cliff &>/dev/null; then
+ CLIFF_CMD="git-cliff"
+ elif git cliff --version &>/dev/null; then
+ CLIFF_CMD="git cliff"
+ else
+ echo "Error: git cliff is not installed. Please install it from https://git-cliff.org/docs/installation."
+ exit 1
+ fi
+
+ # Check if GitHub CLI is installed
+ if ! command -v gh &>/dev/null; then
+ echo -e "${RED}Error: GitHub CLI (gh) is not installed. Please install it and authenticate using 'gh auth login'.${NC}"
+ exit 1
+ fi
+
+ # Ensure local tags are up to date
+ git fetch --tags --quiet || true
+
+ # Get the latest repo-wide release tag (ignore module tags like cli/v* or types/v*)
+ get_latest_repo_tag() {
+ local ref="${1:-HEAD}"
+ git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname --merged "$ref" | head -n1
+ }
+
+ cherry_pick_in_progress() {
+ git rev-parse -q --verify CHERRY_PICK_HEAD >/dev/null 2>&1
+ }
+
+ has_unmerged_conflicts() {
+ [ -n "$(git diff --name-only --diff-filter=U)" ]
+ }
+
+ working_tree_dirty() {
+ [ -n "$(git status --porcelain)" ]
+ }
+
+ LATEST_TAG=$(get_latest_repo_tag "main")
+ if [ -z "$LATEST_TAG" ]; then
+ LATEST_TAG=$(get_latest_repo_tag "HEAD")
+ fi
+ if [ -z "$LATEST_TAG" ]; then
+ echo -e "${RED}Error: No previous release tag found.${NC}"
+ exit 1
+ fi
+
+ echo -e "${GREEN}Latest release tag: ${LATEST_TAG}${NC}"
+
+ # Extract version components from tag (format: v1.2.3)
+ VERSION=${LATEST_TAG#v}
+ IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
+
+ # Increment patch version for hotfix
+ NEW_PATCH=$((PATCH + 1))
+ NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
+ NEW_TAG="v${NEW_VERSION}"
+
+ echo -e "${YELLOW}Proposed hotfix version: ${NEW_TAG}${NC}"
+
+ # Create release branch name
+ RELEASE_BRANCH="release/v${MAJOR}.${MINOR}"
+
+ echo ""
+ echo -e "${YELLOW}=== Available fix commits since ${LATEST_TAG} ===${NC}"
+ echo ""
+
+ # List all fix commits since the last tag
+ FIX_COMMITS=$(git log "${LATEST_TAG}..main" \
+ --oneline \
+ --no-merges \
--grep="^fix:" \
--grep="^hotfix:" \
--regexp-ignore-case \
@@ -891,515 +1428,21 @@ _utils-hotfix:
echo ""
# Utils targets. Valid: "list-fixes", "hotfix".
-[group('utils')]
+[group('release')]
utils target *args:
@just "_utils-{{ target }}" {{ args }}
-# Build the frontend
-[group('build')]
-_build-frontend:
- pnpm -C frontend build
-
-# Build the backend
-[group('build')]
-_build-backend:
- cd backend && go build ./...
-
-# Build manager container image
-[group('build')]
-_build-image-manager tag="ghcr.io/getarcaneapp/arcane:development" flag='':
- docker buildx build {{ if flag == "--push" { "--push" } else { "" } }} --platform linux/arm64,linux/amd64,linux/arm/v7 -f 'docker/Dockerfile' --build-arg ENABLED_FEATURES="{{ env('ENABLED_FEATURES', env('BUILD_FEATURES', '')) }}" -t "{{ tag }}" .
-
-# Build agent container image
-[group('build')]
-_build-image-agent tag="ghcr.io/getarcaneapp/arcane-headless:development" flag='':
- docker buildx build {{ if flag == "--push" { "--push" } else { "" } }} --platform linux/arm64,linux/amd64,linux/arm/v7 -f 'docker/Dockerfile-agent' --build-arg ENABLED_FEATURES="{{ env('ENABLED_FEATURES', env('BUILD_FEATURES', '')) }}" -t "{{ tag }}" .
-
-# Build both frontend and backend
-[group('build')]
-_build-all:
- @just _build-frontend
- @just _build-backend
-
-# Build targets. Valid: "single frontend", "single backend", "single all", "image manager [tag] [--push]", "image agent [tag] [--push]"
-[group('build')]
-build buildtype type tag="" flag="":
- @if [ "{{ buildtype }}" = "single" ]; then just _build-{{ type }}; elif [ "{{ buildtype }}" = "image" ]; then just _build-image-{{ type }} "{{ if tag != "" { tag } else if type == "manager" { "arcane:latest" } else { "arcane-agent:latest" } }}" "{{ flag }}"; fi
-
-# --- Release ---
-
-# Create a new release (use --test to dry-run without writing anything)
-[group('release')]
-release *args:
- #!/usr/bin/env bash
- set -euo pipefail
-
- TEST=false
- FORCE_MAJOR=false
- VERBOSE=false
- set -- {{ args }}
- for arg in "$@"; do
- case "$arg" in
- --test)
- TEST=true
- ;;
- --major)
- FORCE_MAJOR=true
- ;;
- --verbose)
- VERBOSE=true
- ;;
- *)
- ;;
- esac
- done
-
- CLIFF_VERBOSE=""
- if [ "$VERBOSE" == true ]; then
- CLIFF_VERBOSE="-vv"
- fi
-
- # Check if the script is being run from the root of the project
- if [ ! -f .arcane.json ] || [ ! -f frontend/package.json ] || [ ! -f CHANGELOG.md ]; then
- echo "Error: This command must be run from the root of the project."
- exit 1
- fi
-
- # Check if git cliff is installed
- if ! command -v git cliff &>/dev/null; then
- echo "Error: git cliff is not installed. Please install it from https://git-cliff.org/docs/installation."
- exit 1
- fi
-
- # Check if GitHub CLI is installed
- if ! command -v gh &>/dev/null; then
- echo "Error: GitHub CLI (gh) is not installed. Please install it and authenticate using 'gh auth login'."
- exit 1
- fi
-
- # Ensure local tags are up to date (don't fail if no remote)
- git fetch --tags --quiet || true
-
- # Check if we're on the main branch (skip in test mode)
- if [ "$TEST" == false ] && [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
- echo "Error: This command must be run on the main branch."
- exit 1
- fi
-
- # Read the current version from .arcane.json
- VERSION=$(jq -r '.version' .arcane.json)
-
- # Function to increment the version
- increment_version() {
- local version=$1
- local part=$2
-
- IFS='.' read -r -a parts <<<"$version"
- if [ "$part" == "major" ]; then
- parts[0]=$((parts[0] + 1))
- parts[1]=0
- parts[2]=0
- elif [ "$part" == "minor" ]; then
- parts[1]=$((parts[1] + 1))
- parts[2]=0
- elif [ "$part" == "patch" ]; then
- parts[2]=$((parts[2] + 1))
- fi
- echo "${parts[0]}.${parts[1]}.${parts[2]}"
- }
-
- # Determine the release type
- if [ "$FORCE_MAJOR" == true ]; then
- RELEASE_TYPE="major"
- else
- # Get the latest version tag (v*), ignoring non-version tags like 'next'
- LATEST_TAG=$(git tag -l 'v*' --sort=-v:refname | head -n1 || echo "")
- if [ -z "$LATEST_TAG" ]; then
- RELEASE_TYPE="minor"
- else
- # Look only at commit subjects since the last tag (exclude merges)
- SUBJECTS=$(git log --no-merges --format=%s "${LATEST_TAG}..HEAD")
-
- if echo "$SUBJECTS" | grep -Eiq '^feat(\([^)]+\))?: '; then
- RELEASE_TYPE="minor"
- elif echo "$SUBJECTS" | grep -Eiq '^fix(\([^)]+\))?: '; then
- RELEASE_TYPE="patch"
- else
- echo "No 'fix' or 'feat' commits found since the latest release (${LATEST_TAG}). No new release will be created."
- echo "Commits since ${LATEST_TAG}:"
- git log --oneline --no-merges "${LATEST_TAG}..HEAD" || true
- exit 0
- fi
- fi
- fi
-
- # Increment the version based on the release type
- if [ "$RELEASE_TYPE" == "major" ]; then
- echo "Performing major release..."
- NEW_VERSION=$(increment_version "$VERSION" major)
- elif [ "$RELEASE_TYPE" == "minor" ]; then
- echo "Performing minor release..."
- NEW_VERSION=$(increment_version "$VERSION" minor)
- elif [ "$RELEASE_TYPE" == "patch" ]; then
- echo "Performing patch release..."
- NEW_VERSION=$(increment_version "$VERSION" patch)
- else
- echo "Invalid release type. Please enter either 'major', 'minor', or 'patch'."
- exit 1
- fi
-
- if [ "$TEST" == true ]; then
- echo "Test mode enabled: no files will be modified, no commits/tags/pushes/releases will be created."
- else
- # Confirm release creation
- read -p "This will create a new $RELEASE_TYPE release with version $NEW_VERSION. Do you want to proceed? (y/n) " CONFIRM
- if [[ "$CONFIRM" != "y" ]]; then
- echo "Release process canceled."
- exit 1
- fi
- fi
-
- LATEST_REVISION=$(git rev-parse HEAD)
-
- if [ "$TEST" == false ]; then
- # Update .arcane.json file with the new version, revision, and build time
- echo "Updating .arcane.json file..."
- BUILD_TIME=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
- jq --arg version "$NEW_VERSION" --arg revision "$LATEST_REVISION" --arg build_time "$BUILD_TIME" \
- '.version = $version | .revision = $revision | .buildTime = $build_time' .arcane.json > .arcane_tmp.json && mv .arcane_tmp.json .arcane.json
- git add .arcane.json
-
- # Update version in frontend/package.json
- jq --arg new_version "$NEW_VERSION" '.version = $new_version' frontend/package.json > frontend/package_tmp.json && mv frontend/package_tmp.json frontend/package.json
- git add frontend/package.json
-
- # Generate changelog
- echo "Generating changelog..."
- git cliff $CLIFF_VERBOSE --github-token=$(gh auth token) --prepend CHANGELOG.md --tag "v$NEW_VERSION" --unreleased
- git add CHANGELOG.md
-
- # Commit the changes with the new version
- git commit -m "release: $NEW_VERSION"
-
- # Create Git tags with the new version
- TAG_MESSAGE="$NEW_VERSION"
- git tag -a "v$NEW_VERSION" -m "$TAG_MESSAGE"
- git tag -a "cli/v$NEW_VERSION" -m "$TAG_MESSAGE"
- git tag -a "types/v$NEW_VERSION" -m "$TAG_MESSAGE"
- git tag -a "backend/v$NEW_VERSION" -m "$TAG_MESSAGE"
-
- # Push the commit and tags in two steps to ensure the release workflow triggers on v* tag push
- git push
- git push origin "v$NEW_VERSION"
- git push origin "cli/v$NEW_VERSION" "types/v$NEW_VERSION" "backend/v$NEW_VERSION"
-
- # Extract the changelog content for the latest release
- echo "Extracting changelog content for version $NEW_VERSION..."
- CHANGELOG=$(awk '/^## v[0-9]/ { if (found) exit; found=1; next } found' CHANGELOG.md)
-
- if [ -z "$CHANGELOG" ]; then
- echo "Error: Could not extract changelog for version $NEW_VERSION."
- exit 1
- fi
-
- # Create the draft release on GitHub
- echo "Creating GitHub draft release..."
- gh release create "v$NEW_VERSION" --title "v$NEW_VERSION" --notes "$CHANGELOG" --draft
-
- if [ $? -eq 0 ]; then
- echo "GitHub draft release created successfully."
- else
- echo "Error: Failed to create GitHub release."
- exit 1
- fi
-
- echo "Release process complete. New version: $NEW_VERSION"
- else
- echo "Test mode: skipping confirmation prompt and all write operations."
- BUILD_TIME=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
- echo "Would update .arcane.json to version $NEW_VERSION, revision $LATEST_REVISION, and buildTime $BUILD_TIME"
- echo "Would update frontend/package.json to version $NEW_VERSION"
- echo "Generating changelog preview (no file write)..."
- CHANGELOG=$(git cliff $CLIFF_VERBOSE --github-token=$(gh auth token) --tag "v$NEW_VERSION" --unreleased)
-
- if [ -z "$CHANGELOG" ]; then
- echo "Error: Could not generate changelog preview for version $NEW_VERSION."
- exit 1
- fi
-
- echo "----- BEGIN CHANGELOG PREVIEW -----"
- echo "$CHANGELOG"
- echo "----- END CHANGELOG PREVIEW -----"
- echo "Would commit: release: $NEW_VERSION"
- echo "Would tag: v$NEW_VERSION, cli/v$NEW_VERSION, types/v$NEW_VERSION, backend/v$NEW_VERSION"
- echo "Would push commit"
- echo "Would push tag: v$NEW_VERSION"
- echo "Would push tags: cli/v$NEW_VERSION, types/v$NEW_VERSION, backend/v$NEW_VERSION"
- echo "Would create GitHub draft release v$NEW_VERSION"
- echo "Test mode complete. No changes were written."
- fi
-
-# --- Testing ---
-
-# Run Playwright E2E tests
-[group('tests')]
-_test-e2e:
- pnpm -C tests test
-
-# Run backend Go tests
-[group('tests')]
-_test-backend:
- cd backend && go test -tags=exclude_frontend,buildables -ldflags "-X github.com/getarcaneapp/arcane/backend/buildables.EnabledFeatures=autologin" ./... -race -coverprofile=coverage.txt -covermode=atomic -v
-
-# Run CLI tests
-[group('tests')]
-_test-cli:
- cd cli && go test ./... -race -coverprofile=coverage.txt -covermode=atomic -v
-
-# Run shared types Go tests
-[group('tests')]
-_test-types:
- cd types && go test ./... -race -coverprofile=coverage.txt -covermode=atomic -v
-
-[group('tests')]
-_test-all:
- @just _test-e2e
- @just _test-backend
- @just _test-cli
- @just _test-types
-
-# Run tests. Valid targets: "e2e", "backend", "cli", "types", "all".
-[group('tests')]
-test target="all":
- @just "_test-{{ target }}"
-
-# --- Dependency Management ---
-
-# Update frontend dependencies
-[group('deps')]
-_deps-update-frontend:
- pnpm update
-
-# Update backend Go dependencies
-[group('deps')]
-_deps-update-backend:
- cd backend && go get -u ./... && go mod tidy
-
-# Update pnpm version via corepack
-[group('deps')]
-_deps-update-pnpm:
- npx corepack up
-
-[group('deps')]
-_deps-update-all: _deps-update-frontend _deps-update-backend _deps-update-pnpm
-
-# Install frontend dependencies
-[group('deps')]
-_deps-install-frontend:
- pnpm install
-
-# Install tests dependencies
-[group('deps')]
-_deps-install-tests:
- pnpm -C tests install
- pnpm -C tests exec playwright install --with-deps chromium
-
-# Install backend Go dependencies
-[group('deps')]
-_deps-install-backend:
- cd backend && go mod download
- go work sync
-
-# Install CLI Go dependencies
-[group('deps')]
-_deps-install-cli:
- cd cli && go mod download
- go work sync
-
-# Install types Go dependencies
-[group('deps')]
-_deps-install-types:
- cd types && go mod download
- go work sync
-
-# Install all Go dependencies
-[group('deps')]
-_deps-install-go: _deps-install-backend _deps-install-cli _deps-install-types
-
-# Install all Node.js dependencies
-[group('deps')]
-_deps-install-node: _deps-install-frontend _deps-install-tests
-
-# Install all dependencies
-[group('deps')]
-_deps-install-all: _deps-install-node _deps-install-go
-
-# Deps targets. Valid: "install [frontend|tests|backend|cli|types|go|node|all]", "update [frontend|backend|pnpm|all]"
-[group('deps')]
-deps action="update" target="all":
- @just "_deps-{{ action }}-{{ target }}"
-
-# Type check/Lint frontend
-[group('lint')]
-_lint-frontend:
- pnpm -C frontend check
-
-[group('lint')]
-_lint-all:
- @just _lint-frontend
- @just _lint-go
-
-# Lint Go backend
-[group('lint')]
-_lint-backend:
- cd backend && golangci-lint run -c ../.github/.golangci.yml ./...
-
-# Lint Go CLI
-[group('lint')]
-_lint-cli:
- cd cli && golangci-lint run -c ../.github/.golangci.yml ./...
-
-# Lint Types
-[group('lint')]
-_lint-types:
- cd types && golangci-lint run -c ../.github/.golangci.yml ./...
-
-# Lint all Go code
-[group('lint')]
-_lint-go: _lint-backend _lint-cli _lint-types
-
-# Lint targets. Valid: "backend", "frontend", "cli", "types" "all".
-[group('lint')]
-lint target="all":
- @just "_lint-{{ target }}"
-
-# Fix Go backend
-[group('fix')]
-_fix-backend:
- cd backend && go fix ./...
-
-# Fix Go CLI
-[group('fix')]
-_fix-cli:
- cd cli && go fix ./...
-
-# Fix Types
-[group('fix')]
-_fix-types:
- cd types && go fix ./...
-
-# Fix all Go code
-[group('fix')]
-_fix-go: _fix-backend _fix-cli _fix-types
-
-[group('fix')]
-_fix-all:
- @just _fix-go
-
-# Fix targets. Valid: "backend", "cli", "types", "go", "all".
-[group('fix')]
-fix target="all":
- @just "_fix-{{ target }}"
-
-# Run go mod tidy in backend module
-[group('gomod')]
-_gomod-tidy-backend:
- cd backend && go mod tidy
-
-# Run go mod tidy in CLI module
-[group('gomod')]
-_gomod-tidy-cli:
- cd cli && go mod tidy
-
-# Run go mod tidy in types module
-[group('gomod')]
-_gomod-tidy-types:
- cd types && go mod tidy
-
-# Run go mod tidy in all Go modules
-[group('gomod')]
-_gomod-tidy-go: _gomod-tidy-backend _gomod-tidy-cli _gomod-tidy-types
-
-[group('gomod')]
-_gomod-tidy-all:
- @just _gomod-tidy-go
- go work sync
-
-[group('gomod')]
-_gomod-sync-all:
- go work sync
-
-# Go module targets. Valid: "tidy [backend|cli|types|go|all]", "sync all".
-[group('gomod')]
-gomod action="tidy" target="all":
- @just "_gomod-{{ action }}-{{ target }}"
-
-# Format frontend (Prettier), test/email TypeScript (oxfmt), and Go modules (gofmt)
-[group('format')]
-_format-frontend:
- pnpm -C frontend format
-
-[group('format')]
-_format-js:
- pnpm -C tests exec oxfmt "**/*.{ts,tsx,js,jsx,mts,cts}"
- pnpm -C email-templates exec oxfmt "**/*.{ts,tsx,js,jsx,mts,cts}"
-
-[group('format')]
-_format-go:
- cd backend && gofmt -s -w .
- cd cli && gofmt -s -w .
- cd types && gofmt -s -w .
-
-[group('format')]
-_format-just:
- just --fmt --unstable
-
-[group('format')]
-_format-check-frontend:
- pnpm -C frontend format:check
-
-[group('format')]
-_format-check-js:
- pnpm -C tests exec oxfmt --check "**/*.{ts,tsx,js,jsx,mts,cts}"
- pnpm -C email-templates exec oxfmt --check "**/*.{ts,tsx,js,jsx,mts,cts}"
-
-[group('format')]
-_format-check-go:
- #!/usr/bin/env bash
- set -euo pipefail
-
- unformatted=$(gofmt -l backend cli types)
- if [ -n "$unformatted" ]; then
- echo "Unformatted Go files:"
- echo "$unformatted"
- exit 1
- fi
-
-[group('format')]
-_format-all:
- @just _format-frontend
- @just _format-js
- @just _format-go
- @just _format-just
-
-[group('format')]
-_format-check-all:
- @just _format-check-frontend
- @just _format-check-js
- @just _format-check-go
-
-# Format targets. Valid: "frontend", "js", "go", "just", "all". Use --check to verify formatting.
-[group('format')]
-format target="all" check="":
- @if [ "{{ check }}" = "--check" ]; then just "_format-check-{{ target }}"; else just "_format-{{ target }}"; fi
+# -----------------------------------------------------------------------------
+# Repository maintenance
+# -----------------------------------------------------------------------------
# Clean build artifacts
-[group('repo')]
+[group('maintenance')]
_repo-clean:
rm -rf frontend/.svelte-kit frontend/build backend/.bin
find . -type d -name node_modules -prune -exec rm -rf {} \;
# Repo targets. Valid: "clean".
-[group('repo')]
+[group('maintenance')]
repo target="clean":
@just "_repo-{{ target }}"