-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
147 lines (117 loc) · 3.99 KB
/
justfile
File metadata and controls
147 lines (117 loc) · 3.99 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
# Default recipe - runs all checks
default: check
# Run all checks: format, lint, and test
check: fmt lint test
# Run linter
lint:
golangci-lint run
# Format code
fmt:
gofmt -w .
goimports -w -local github.com/jmgilman/headjack .
# Run tests
test:
go test ./...
# Run tests with verbose output
test-verbose:
go test -v ./...
# Run tests with coverage
test-coverage:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# =============================================================================
# Container Images
# =============================================================================
# Build base image locally
build-base:
docker build -t headjack:base images/base
# Build all container images
build-images: build-base
# Lint all Dockerfiles
lint-dockerfiles:
hadolint images/base/Dockerfile
# =============================================================================
# Integration Tests
# =============================================================================
# Run integration tests (auto-detect container runtime)
integration-test runtime="auto":
#!/usr/bin/env bash
set -euo pipefail
# Build the binary first
go build -o hjk .
# Determine runtime
if [ "{{runtime}}" = "auto" ]; then
if command -v docker &>/dev/null; then
RUNTIME=docker
elif command -v podman &>/dev/null; then
RUNTIME=podman
else
echo "No container runtime found"
exit 1
fi
else
RUNTIME="{{runtime}}"
fi
echo "Running integration tests with runtime: $RUNTIME"
HEADJACK_TEST_RUNTIME=$RUNTIME \
HJK_BINARY=$(pwd)/hjk \
go test -v -tags=integration -timeout=30m ./integration/...
# Run integration tests with Docker
integration-test-docker:
just integration-test docker
# Run integration tests with Podman
integration-test-podman:
just integration-test podman
# Run a specific integration test script by name
integration-test-one script runtime="auto":
#!/usr/bin/env bash
set -euo pipefail
go build -o hjk .
if [ "{{runtime}}" = "auto" ]; then
if command -v docker &>/dev/null; then
RUNTIME=docker
elif command -v podman &>/dev/null; then
RUNTIME=podman
else
RUNTIME=docker
fi
else
RUNTIME="{{runtime}}"
fi
HEADJACK_TEST_RUNTIME=$RUNTIME \
HJK_BINARY=$(pwd)/hjk \
go test -v -tags=integration -run="TestScripts/{{script}}" ./integration/...
# Run integration tests in Lima VM (Linux ARM64 testing on macOS)
integration-test-lima:
#!/usr/bin/env bash
set -euo pipefail
LIMA_INSTANCE="hjk-integration-$$"
cleanup() {
echo "Cleaning up Lima instance $LIMA_INSTANCE..."
limactl stop "$LIMA_INSTANCE" 2>/dev/null || true
limactl delete "$LIMA_INSTANCE" --force 2>/dev/null || true
}
trap cleanup EXIT
echo "Creating Lima instance $LIMA_INSTANCE with Docker..."
limactl create --name="$LIMA_INSTANCE" template://docker --tty=false
echo "Starting Lima instance..."
limactl start "$LIMA_INSTANCE"
echo "Syncing project to Lima instance..."
limactl copy -r . "$LIMA_INSTANCE":/tmp/headjack-test
echo "Installing Go..."
limactl shell "$LIMA_INSTANCE" -- bash -c '
curl -fsSL https://go.dev/dl/go1.23.4.linux-arm64.tar.gz | sudo tar -C /usr/local -xzf -
echo "export PATH=\$PATH:/usr/local/go/bin" | sudo tee /etc/profile.d/go.sh
'
echo "Pulling container image..."
limactl shell "$LIMA_INSTANCE" -- docker pull ghcr.io/gilmanlab/headjack:base
echo "Running tests in Lima..."
limactl shell "$LIMA_INSTANCE" -- bash -c '
export PATH=$PATH:/usr/local/go/bin
export DOCKER_HOST=unix:///run/user/$(id -u)/docker.sock
cd /tmp/headjack-test
go build -o hjk .
HEADJACK_TEST_RUNTIME=docker \
HJK_BINARY=$(pwd)/hjk \
go test -v -tags=integration -timeout=30m ./integration/...
'