-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (129 loc) · 5.39 KB
/
docker.yml
File metadata and controls
134 lines (129 loc) · 5.39 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
---
name: Docker Build + Full Scale Test
on:
push:
tags:
- 'v*'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
docker-build:
name: Build + Full Scale Test (1000 Sessions)
runs-on: ubuntu-24.04
timeout-minutes: 45
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.meta.outputs.tags }}
digest: ${{ steps.build.outputs.digest }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Set up sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Run internal scale test (1000 sessions)
run: |
cargo test --package phantom-mcp --test scale_test scale_full_1000 \
-- --nocapture --test-threads=1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build image
id: build
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache_from: type=gha
cache_to: type=gha,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1
platforms: linux/amd64
- name: Resolve API key for compose + k6
env:
PHANTOM_API_KEY_SECRET: ${{ secrets.PHANTOM_API_KEY }}
run: |
if [ -n "${PHANTOM_API_KEY_SECRET}" ]; then
echo "PHANTOM_API_KEY=${PHANTOM_API_KEY_SECRET}" >> "$GITHUB_ENV"
else
echo "PHANTOM_API_KEY=phantom-ci-key" >> "$GITHUB_ENV"
fi
echo "PHANTOM_SESSION_LIMIT=2000" >> "$GITHUB_ENV"
echo "PHANTOM_RATE_LIMIT=1000000" >> "$GITHUB_ENV"
- name: Install k6
uses: grafana/setup-k6-action@v1
- name: Verify Docker Compose availability
run: docker compose version
- name: Start observability stack
env:
TAG: sha-${{ github.sha }}
run: |
docker compose -f docker-compose.yml up -d prometheus grafana node-exporter
timeout 60 bash -c 'until curl -sf http://localhost:9090/-/ready; do sleep 2; done'
echo "Prometheus ready"
- name: Start Phantom engine
env:
TAG: sha-${{ github.sha }}
run: |
docker compose -f docker-compose.yml up -d phantom
timeout 60 bash -c 'until curl -sf http://localhost:8080/health; do sleep 2; done'
echo "Phantom engine ready"
- name: Run k6 navigate load
run: k6 run --env PHANTOM_API_KEY="${PHANTOM_API_KEY}" --env PHANTOM_BASE_URL=http://localhost:8080 k6/navigate_load.js
- name: Run k6 scene graph load
run: k6 run --env PHANTOM_API_KEY="${PHANTOM_API_KEY}" --env PHANTOM_BASE_URL=http://localhost:8080 k6/scene_graph_load.js
- name: Run k6 click load
run: k6 run --env PHANTOM_API_KEY="${PHANTOM_API_KEY}" --env PHANTOM_BASE_URL=http://localhost:8080 k6/click_load.js
- name: Run k6 mixed load
run: k6 run --env PHANTOM_API_KEY="${PHANTOM_API_KEY}" --env PHANTOM_BASE_URL=http://localhost:8080 k6/mixed_load.js
- name: Verify Prometheus metrics are populated
run: |
echo "Checking direct engine metrics..."
curl -sf http://localhost:8080/metrics | grep sessions_created_total || echo "Warning: Metric not found"
echo "Querying Prometheus (with retries)..."
for i in {1..10}; do
# Query sessions_created_total which persists even after sessions close
response=$(curl -s -G 'http://localhost:9090/api/v1/query' --data-urlencode 'query=sessions_created_total')
echo "Prometheus response: $response"
result=$(echo "$response" | python3 -c "import json, sys; d=json.load(sys.stdin); print(sum(int(r['value'][1]) for r in d.get('data', {}).get('result', []))) if d.get('status') == 'success' else print(0)")
if [ "$result" -gt 0 ]; then
echo "Metrics confirmed! Total sessions created: $result"
exit 0
fi
echo "Metrics not populated yet, waiting... ($i/10)"
sleep 5
done
echo "Error: Metrics failed to populate in Prometheus after 50 seconds"
exit 1
- name: Print final metric snapshot
if: always()
run: curl -s http://localhost:8080/metrics | grep -E '^(sessions|phantom_sessions|js_|phantom_js|http_|phantom_http|dom_|phantom_dom|storage_|phantom_storage)'
- name: Print compose logs on failure
if: failure()
run: docker compose -f docker-compose.yml logs --tail=200
- name: Tear down compose stack
if: always()
run: docker compose -f docker-compose.yml down -v