Skip to content

Commit 601aad0

Browse files
committed
ci: add Ignition deploy E2E workflow (Bash)
1 parent 3f9b558 commit 601aad0

File tree

2 files changed

+230
-0
lines changed

2 files changed

+230
-0
lines changed
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# ──────────────────────────────────────────────
5+
# Ignition Deploy E2E Harness
6+
# Exercises: link → build → deploy against live
7+
# Ignition infrastructure.
8+
# ──────────────────────────────────────────────
9+
10+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
11+
12+
# ── Logging helpers ──────────────────────────
13+
14+
log() {
15+
echo "[$(date -u '+%Y-%m-%dT%H:%M:%SZ')] $*"
16+
}
17+
18+
log_section() {
19+
echo ""
20+
echo "════════════════════════════════════════"
21+
echo " $*"
22+
echo "════════════════════════════════════════"
23+
echo ""
24+
}
25+
26+
run_step() {
27+
local label="$1"
28+
shift
29+
local logfile="/tmp/e2e-${label}.log"
30+
31+
log "▶ step=${label}"
32+
log " command: $*"
33+
log " cwd: $(pwd)"
34+
35+
if "$@" > >(tee "$logfile") 2>&1; then
36+
local rc=0
37+
else
38+
local rc=$?
39+
fi
40+
41+
log " exit_code=${rc}"
42+
43+
if [ "$rc" -ne 0 ]; then
44+
log " ✗ Step '${label}' failed — last 50 lines:"
45+
tail -n 50 "$logfile" || true
46+
exit "$rc"
47+
fi
48+
49+
log " ✓ Step '${label}' succeeded"
50+
}
51+
52+
# ── Preflight checks ────────────────────────
53+
54+
log_section "Preflight"
55+
56+
REQUIRED_VARS=(
57+
BIGCOMMERCE_STORE_HASH
58+
BIGCOMMERCE_ACCESS_TOKEN
59+
BIGCOMMERCE_STOREFRONT_TOKEN
60+
BIGCOMMERCE_CHANNEL_ID
61+
AUTH_SECRET
62+
BIGCOMMERCE_PROJECT_UUID
63+
)
64+
65+
for var in "${REQUIRED_VARS[@]}"; do
66+
val="${!var:-}"
67+
if [ -z "$val" ]; then
68+
log "✗ Missing required env var: ${var}"
69+
exit 1
70+
fi
71+
log " ${var} is set (${#val} chars)"
72+
done
73+
74+
log " node: $(node --version)"
75+
log " pnpm: $(pnpm --version)"
76+
log " HOME: ${HOME}"
77+
78+
mkdir -p "$HOME"
79+
80+
# ── Step 1: Link ─────────────────────────────
81+
82+
log_section "Step 1 — Link"
83+
84+
cd "${REPO_ROOT}/core"
85+
86+
run_step "link" pnpm catalyst link --project-uuid "$BIGCOMMERCE_PROJECT_UUID"
87+
88+
if [ ! -f .bigcommerce/project.json ]; then
89+
log "✗ .bigcommerce/project.json was not created"
90+
exit 1
91+
fi
92+
93+
log " project.json exists ✓"
94+
95+
# ── Step 2: Build ────────────────────────────
96+
97+
log_section "Step 2 — Build"
98+
99+
run_step "build" pnpm catalyst build --framework catalyst
100+
101+
if [ ! -d .bigcommerce/dist ] || [ -z "$(ls -A .bigcommerce/dist)" ]; then
102+
log "✗ .bigcommerce/dist/ is missing or empty"
103+
exit 1
104+
fi
105+
106+
log " dist/ is non-empty ✓"
107+
108+
# ── Step 3: Deploy ───────────────────────────
109+
110+
log_section "Step 3 — Deploy"
111+
112+
run_step "deploy" pnpm catalyst deploy \
113+
--project-uuid "$BIGCOMMERCE_PROJECT_UUID" \
114+
--secret "BIGCOMMERCE_STORE_HASH=$BIGCOMMERCE_STORE_HASH" \
115+
--secret "BIGCOMMERCE_STOREFRONT_TOKEN=$BIGCOMMERCE_STOREFRONT_TOKEN" \
116+
--secret "BIGCOMMERCE_CHANNEL_ID=$BIGCOMMERCE_CHANNEL_ID" \
117+
--secret "AUTH_SECRET=$AUTH_SECRET"
118+
119+
# ── Step 4: Extract deployment URL ───────────
120+
121+
log_section "Step 4 — Extract deployment URL"
122+
123+
DEPLOY_URL=""
124+
if [ -f /tmp/e2e-deploy.log ]; then
125+
DEPLOY_URL=$(grep -oP 'Deployment URL: \K\S+' /tmp/e2e-deploy.log || true)
126+
fi
127+
128+
if [ -z "$DEPLOY_URL" ]; then
129+
log "⚠ No deployment URL found in deploy output — skipping URL validation"
130+
log " (deploy succeeded; URL validation is additive)"
131+
exit 0
132+
fi
133+
134+
log " Deployment URL: ${DEPLOY_URL}"
135+
136+
# ── Step 5: Validate deployment URL ──────────
137+
138+
log_section "Step 5 — Validate deployment URL"
139+
140+
DELAY=15
141+
MAX_DELAY=120
142+
MAX_ATTEMPTS=10
143+
144+
for attempt in $(seq 1 "$MAX_ATTEMPTS"); do
145+
log " Attempt ${attempt}/${MAX_ATTEMPTS} (delay=${DELAY}s)"
146+
sleep "$DELAY"
147+
148+
HTTP_CODE=$(curl -s -o /tmp/e2e-url-response.txt -w '%{http_code}' "$DEPLOY_URL" || echo "000")
149+
BODY_SIZE=$(wc -c < /tmp/e2e-url-response.txt | tr -d ' ')
150+
151+
log " HTTP ${HTTP_CODE}, body size: ${BODY_SIZE} bytes"
152+
153+
if [ "$HTTP_CODE" = "200" ] && grep -qi '<html' /tmp/e2e-url-response.txt; then
154+
log " ✓ Deployment is live — HTTP 200 with <html marker"
155+
log " First 500 chars of response:"
156+
head -c 500 /tmp/e2e-url-response.txt
157+
echo ""
158+
exit 0
159+
fi
160+
161+
# Exponential backoff
162+
DELAY=$((DELAY * 2))
163+
if [ "$DELAY" -gt "$MAX_DELAY" ]; then
164+
DELAY=$MAX_DELAY
165+
fi
166+
done
167+
168+
log "✗ Deployment URL validation failed after ${MAX_ATTEMPTS} attempts"
169+
log " Last response (full body):"
170+
cat /tmp/e2e-url-response.txt || true
171+
exit 1

.github/workflows/cli-e2e.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CLI Deploy E2E
2+
3+
on:
4+
pull_request:
5+
branches: [canary]
6+
7+
concurrency:
8+
group: cli-deploy-e2e
9+
cancel-in-progress: true
10+
11+
env:
12+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
13+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
14+
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
15+
16+
jobs:
17+
ignition-deploy:
18+
name: Ignition Deploy E2E
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 20
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 2
27+
28+
- uses: pnpm/action-setup@v3
29+
30+
- name: Use Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version-file: ".nvmrc"
34+
cache: "pnpm"
35+
36+
- name: Install dependencies
37+
run: pnpm install --frozen-lockfile
38+
39+
- name: Build workspace packages
40+
run: pnpm --filter "./packages/*" build
41+
42+
- name: Run Ignition deploy E2E
43+
run: bash .github/scripts/ignition-deploy-e2e.sh
44+
env:
45+
HOME: ${{ runner.temp }}/e2e-home
46+
BIGCOMMERCE_STORE_HASH: ${{ secrets.DEPLOY_E2E_STORE_HASH }}
47+
BIGCOMMERCE_ACCESS_TOKEN: ${{ secrets.DEPLOY_E2E_ACCESS_TOKEN }}
48+
BIGCOMMERCE_STOREFRONT_TOKEN: ${{ secrets.DEPLOY_E2E_STOREFRONT_TOKEN }}
49+
BIGCOMMERCE_CHANNEL_ID: ${{ secrets.DEPLOY_E2E_CHANNEL_ID }}
50+
AUTH_SECRET: ${{ secrets.DEPLOY_E2E_AUTH_SECRET }}
51+
BIGCOMMERCE_PROJECT_UUID: ${{ secrets.DEPLOY_E2E_PROJECT_UUID }}
52+
53+
- name: Upload E2E logs
54+
if: ${{ !cancelled() }}
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: cli-e2e-logs
58+
path: /tmp/e2e-*.log
59+
retention-days: 7

0 commit comments

Comments
 (0)