-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (121 loc) · 4.55 KB
/
Copy pathexternal-results-smoke.yml
File metadata and controls
145 lines (121 loc) · 4.55 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
name: External Results Smoke
on:
pull_request:
paths:
- 'backend/app/api/external_results.py'
- 'backend/app/schemas/external_*.py'
- 'backend/app/models/external_*.py'
- 'backend/app/crud/external_*.py'
- 'backend/alembic/versions/**'
- 'docs/specs/external_results_v1.md'
- '.github/workflows/external-results-smoke.yml'
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
concurrency:
group: external-results-smoke-${{ github.ref }}
cancel-in-progress: true
jobs:
smoke:
name: External Results contract smoke
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout BGSTM
uses: actions/checkout@v4
with:
path: bgstm
- name: Checkout bgstm-playwright-frameworks (pinned)
uses: actions/checkout@v4
with:
repository: bg-playground/bgstm-playwright-frameworks
ref: 98027ad2126cde2a87392564828f10709612142e
path: frameworks
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set up pnpm 9
uses: pnpm/action-setup@v4
with:
version: 9
- name: Install smoke script dependencies
run: python -m pip install --quiet httpx
- name: Start BGSTM backend + Postgres
run: docker compose -f bgstm/docker-compose.test.yml up -d db backend
- name: Wait for BGSTM health
run: |
echo "Waiting for backend health check..."
for i in $(seq 1 30); do
if curl -sf http://localhost:8001/health > /dev/null; then
echo "Backend is healthy"
exit 0
fi
echo "Attempt $i/30 -- backend not ready yet, waiting 5s..."
sleep 5
done
echo "Backend failed to become healthy"
docker compose -f bgstm/docker-compose.test.yml logs backend || true
exit 1
- name: Normalize runner token scopes column type for smoke
run: |
docker compose -f bgstm/docker-compose.test.yml exec -T db psql \
-U bgstm_test \
-d bgstm_test \
-v ON_ERROR_STOP=1 \
-c "DO \$\$
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_name = 'runner_tokens'
AND column_name = 'scopes'
AND udt_name IN ('json', 'jsonb')
) THEN
CREATE OR REPLACE FUNCTION _bgstm_json_to_text_array(j json)
RETURNS text[]
LANGUAGE sql
IMMUTABLE
AS \$fn\$
SELECT COALESCE(array_agg(value), ARRAY[]::text[])
FROM json_array_elements_text(j) AS t(value);
\$fn\$;
ALTER TABLE runner_tokens
ALTER COLUMN scopes TYPE text[]
USING _bgstm_json_to_text_array(scopes);
DROP FUNCTION _bgstm_json_to_text_array(json);
END IF;
END
\$\$;"
- name: Bootstrap project and runner token
id: bootstrap
run: python bgstm/scripts/smoke/bootstrap.py
- name: Dump backend logs on bootstrap failure
if: failure() && steps.bootstrap.outcome == 'failure'
run: docker compose -f bgstm/docker-compose.test.yml logs backend
- name: Install frameworks dependencies
run: pnpm -C frameworks install --frozen-lockfile
- name: Build frameworks workspace
run: pnpm -C frameworks build
- name: Install Chromium for crm-example
run: pnpm -C frameworks/examples/crm-example exec playwright install --with-deps chromium
- name: Run crm-example smoke fixture
run: |
# Playwright fails-by-design (smoke fixture has 1 intentional failure). The real pass/fail signal is the assertion step below.
pnpm --filter crm-example -C frameworks smoke || true
- name: Assert BGSTM persisted expected smoke results
id: assert_results
run: python bgstm/scripts/smoke/assert.py
- name: Dump backend logs on assertion failure
if: failure() && steps.assert_results.outcome == 'failure'
run: docker compose -f bgstm/docker-compose.test.yml logs backend
- name: Tear down BGSTM stack
if: always()
run: docker compose -f bgstm/docker-compose.test.yml down -v