-
Notifications
You must be signed in to change notification settings - Fork 1
258 lines (227 loc) · 9.02 KB
/
Copy pathmigration-test.yml
File metadata and controls
258 lines (227 loc) · 9.02 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
name: "Langflow Migration Test: Latest → Nightly"
on:
schedule:
- cron: "0 7 * * *" # 04:00 BRT (UTC-3)
workflow_dispatch:
env:
LANGFLOW_PORT: 7860
LANGFLOW_URL: http://localhost:7860
PG_USER: langflow
PG_PASSWORD: langflow_test_pw
PG_DB: langflow
STATE_FILE: /tmp/migration-test-state.json
REPORT_FILE: /tmp/migration-report.md
LANGFLOW_DATABASE_URL: "postgresql://langflow:langflow_test_pw@localhost:5432/langflow"
LANGFLOW_AUTO_LOGIN: "true"
LANGFLOW_SKIP_AUTH_AUTO_LOGIN: "true"
LANGFLOW_SUPERUSER: "langflow"
LANGFLOW_SUPERUSER_PASSWORD: "langflow123"
LANGFLOW_STORE: "false"
permissions:
contents: read
issues: write
jobs:
migration-test:
runs-on: ubuntu-latest
timeout-minutes: 30
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: langflow
POSTGRES_PASSWORD: langflow_test_pw
POSTGRES_DB: langflow
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Install test dependencies
run: |
pip install requests playwright pytest pytest-playwright
playwright install chromium --with-deps
- name: Create virtual environment
run: uv venv .venv
- name: Generate ephemeral secret key for this run
run: |
python - <<'PY'
import base64, os
key = base64.urlsafe_b64encode(os.urandom(32)).decode()
with open(os.environ["GITHUB_ENV"], "a") as f:
f.write(f"LANGFLOW_SECRET_KEY={key}\n")
PY
# ── Phase 1: Langflow Latest ──────────────────────────────
- name: Install Langflow latest
run: |
uv pip install "langflow[postgresql]"
LATEST_VERSION=$(uv pip show langflow | grep ^Version | awk '{print $2}')
echo "LATEST_VERSION=$LATEST_VERSION" >> "$GITHUB_ENV"
echo "langflow==$LATEST_VERSION" > /tmp/latest-digest.txt
echo "Installed Langflow $LATEST_VERSION (latest stable)"
- name: Start Langflow latest
run: |
uv run langflow run --host 0.0.0.0 --port "$LANGFLOW_PORT" \
> /tmp/langflow-latest.log 2>&1 &
echo $! > /tmp/langflow.pid
echo "Langflow PID: $(cat /tmp/langflow.pid)"
- name: Wait for Langflow latest
run: python tests/github-workflows/migration/wait_for_langflow.py
- name: Create flow, configure and execute on latest
run: python tests/github-workflows/migration/setup_latest.py
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: Stop Langflow latest
run: |
kill "$(cat /tmp/langflow.pid)" 2>/dev/null || true
sleep 3
# ── Phase 2: Upgrade to Nightly ───────────────────────────
- name: Resolve nightly version from PyPI
run: |
NIGHTLY_VERSION=$(python - <<'PY'
import urllib.request, json
data = json.loads(urllib.request.urlopen("https://pypi.org/pypi/langflow/json").read())
pre = [
v for v in data["releases"]
if data["releases"][v] and any(c in v for c in ("dev", "a", "b", "rc"))
]
pre.sort(key=lambda v: data["releases"][v][0]["upload_time"])
print(pre[-1] if pre else "")
PY
)
if [ -z "$NIGHTLY_VERSION" ]; then
echo "ERROR: Could not determine nightly version from PyPI"
exit 1
fi
echo "NIGHTLY_VERSION=$NIGHTLY_VERSION" >> "$GITHUB_ENV"
echo "langflow==$NIGHTLY_VERSION" > /tmp/nightly-digest.txt
echo "Nightly version: $NIGHTLY_VERSION"
- name: Install Langflow nightly
run: |
uv pip install "langflow[postgresql]==$NIGHTLY_VERSION"
echo "Installed Langflow $NIGHTLY_VERSION (nightly)"
- name: Start Langflow nightly (same database)
run: |
uv run langflow run --host 0.0.0.0 --port "$LANGFLOW_PORT" \
> /tmp/langflow-nightly.log 2>&1 &
echo $! > /tmp/langflow.pid
echo "Langflow PID: $(cat /tmp/langflow.pid)"
- name: Wait for Langflow nightly (includes migration)
id: nightly_start
run: python tests/github-workflows/migration/wait_for_langflow.py --timeout 180
# ── Phase 3: Verify Migration ─────────────────────────────
- name: Verify migration via API
run: python tests/github-workflows/migration/verify_migration_api.py
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: Verify migration via UI (Playwright)
run: pytest tests/github-workflows/migration/test_ui_migration.py -v --tracing=retain-on-failure --output=test-results
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# ── Phase 4: Report ───────────────────────────────────────
- name: Stop Langflow nightly
if: always()
run: kill "$(cat /tmp/langflow.pid)" 2>/dev/null || true
- name: Generate report
if: always()
run: python tests/github-workflows/migration/generate_report.py
- name: Print report
if: always()
run: cat /tmp/migration-report.md
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: migration-test-${{ github.run_number }}
path: |
test-results/
/tmp/migration-report.md
/tmp/langflow-latest.log
/tmp/langflow-nightly.log
/tmp/migration-test-state.json
/tmp/latest-digest.txt
/tmp/nightly-digest.txt
- name: Close issue on success
if: success()
uses: actions/github-script@v7
with:
script: |
const { data: existing } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: 'migration-test',
state: 'open',
});
if (existing.length > 0) {
const issue = existing[0];
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: [
`## ✅ Run #${context.runNumber} — ${new Date().toISOString().split('T')[0]}`,
'',
'Migration test passed. Closing this issue.',
'',
`[Workflow Run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`,
].join('\n'),
});
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed',
});
}
- name: Create or update issue on failure
if: failure()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
let report = 'Migration test failed. See workflow artifacts for details.';
try {
report = fs.readFileSync('/tmp/migration-report.md', 'utf8');
} catch (e) {
console.log('Report not available:', e.message);
}
const { data: existing } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: 'migration-test',
state: 'open',
});
const body = [
`## Run #${context.runNumber} — ${new Date().toISOString().split('T')[0]}`,
'',
report,
'',
`[Workflow Run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`,
'',
'/cc @lice-reis',
].join('\n');
if (existing.length > 0) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existing[0].number,
body,
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Langflow Migration Test Failed (latest → nightly)`,
body,
labels: ['migration-test', 'automated'],
});
}