-
Notifications
You must be signed in to change notification settings - Fork 118
fix(e2e): consolidate frontend E2E to Cypress and restore CI (#967) #984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
61281cc
cd56254
46e1801
dfe2345
56d4dad
07066de
1e0c4c1
48716d9
1239070
671ffd1
7330217
5e4908e
a6c0f62
7f8ae86
5c3d6ee
755449d
0348a19
14bdb00
6eed40a
823db92
1f66827
df51473
667752b
d2e8cc5
8f7d932
6ff3aa7
6cad190
68437f6
394e236
8f0b8e7
d80e9df
8a5602f
d4f6156
587617f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,51 @@ | ||
| # name: Test-e2e | ||
| # on: [push, pull_request] | ||
| # jobs: | ||
| # build: | ||
| # name: Test-e2e | ||
| # runs-on: ubuntu-latest | ||
| # timeout-minutes: 10 | ||
| # steps: | ||
| # - name: Check out code | ||
| # uses: actions/checkout@v4 | ||
| # - uses: actions/setup-python@v4 | ||
| # with: | ||
| # python-version: '3.11.4' | ||
| # cache: 'pip' | ||
| # - uses: actions/setup-node@v3 | ||
| # with: | ||
| # cache: 'yarn' | ||
| # node-version: 'v20.12.1' | ||
| # - name: Install dependencies | ||
| # run: | | ||
| # sudo apt-get update | ||
| # sudo apt-get install -y python3-setuptools python3-pip python3-virtualenv chromium-browser libgbm1 | ||
| # make install | ||
| # - name: DB setup | ||
| # run: | | ||
| # make migrate-upgrade | ||
| # python cre.py --upstream_sync | ||
| # # - name: Run app and e2e tests | ||
| # run: | | ||
| # make e2e | ||
| name: Test-e2e | ||
| on: [push, pull_request] | ||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Test-e2e | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12.3' | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20.12.1' | ||
| cache: 'yarn' | ||
| - name: Install system dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y \ | ||
| python3-setuptools \ | ||
| python3-virtualenv \ | ||
| python3-pip \ | ||
| libxml2-dev \ | ||
| libxslt-dev | ||
| - name: Create venv and install Python deps (no Playwright — Cypress ships its own browser) | ||
| run: | | ||
| pip install --upgrade pip setuptools virtualenv | ||
| virtualenv -p python3 venv | ||
| make install-deps-python | ||
| - name: Install Node deps (root for Cypress, frontend for build) | ||
| run: | | ||
| yarn install | ||
| make install-deps-typescript | ||
| - name: Seed e2e database (schema from models via create_all, data from checked-in fixture) | ||
| run: make e2e-db | ||
|
DevHusnainAi marked this conversation as resolved.
|
||
| - name: Run Cypress e2e | ||
| run: make e2e | ||
| - name: Upload Cypress screenshots on failure | ||
| if: failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cypress-screenshots | ||
| path: cypress/screenshots | ||
| if-no-files-found: ignore | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| .ONESHELL: | ||
|
|
||
| .PHONY: run test covers install-deps dev docker lint frontend clean all | ||
| .PHONY: run test covers install-deps dev docker lint frontend clean all e2e e2e-db | ||
|
|
||
| prod-run: | ||
| gunicorn cre:app --log-file=- | ||
|
|
@@ -85,17 +85,34 @@ dev-flask-docker: | |
| . ./venv/bin/activate && INSECURE_REQUESTS=1 FLASK_APP=`pwd`/cre.py FLASK_CONFIG=development flask run --host=0.0.0.0 --port $(PORT) | ||
|
|
||
| e2e: | ||
| set -euo pipefail | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocking on CI: Ubuntu’s Make uses Use |
||
| yarn build | ||
|
DevHusnainAi marked this conversation as resolved.
|
||
| if [ -d "./venv" ]; then . ./venv/bin/activate; fi | ||
| [ -f "$(CURDIR)/standards_cache.sqlite" ] || { echo "ERROR: standards_cache.sqlite not found — run 'make e2e-db' first"; exit 1; } | ||
| export FLASK_APP="$(CURDIR)/cre.py" | ||
| export FLASK_CONFIG=development | ||
| export INSECURE_REQUESTS=1 | ||
| flask run --host=127.0.0.1 --port=5000 > /tmp/opencre-e2e-flask.log 2>&1 & | ||
| FLASK_PID=$$! | ||
| trap 'kill $$FLASK_PID 2>/dev/null || true' EXIT INT TERM | ||
| for i in `seq 1 30`; do \ | ||
| curl -fsS http://127.0.0.1:5000 >/dev/null && break; \ | ||
| sleep 1; \ | ||
| done | ||
| curl -fsS http://127.0.0.1:5000 >/dev/null || { echo "ERROR: Flask did not become ready on http://127.0.0.1:5000 after 30s; see /tmp/opencre-e2e-flask.log"; exit 1; } | ||
| env -u ELECTRON_RUN_AS_NODE yarn test:e2e | ||
|
coderabbitai[bot] marked this conversation as resolved.
DevHusnainAi marked this conversation as resolved.
|
||
|
|
||
| # Build the e2e SQLite schema from the ORM models (create_all), then load a | ||
| # small checked-in fixture graph. Local/CI e2e uses create_all, NOT | ||
| # migrate-upgrade: migrations are the Postgres path and omit columns the | ||
| # models added without a migration (e.g. cre.document_metadata, see | ||
| # application/database/db.py), so a migrate-built SQLite cache is incomplete. | ||
| # create_all always matches the models. | ||
| e2e-db: | ||
| [ -d "./venv" ] && . ./venv/bin/activate &&\ | ||
| export FLASK_APP="$(CURDIR)/cre.py" &&\ | ||
| export FLASK_CONFIG=development &&\ | ||
| export INSECURE_REQUESTS=1 &&\ | ||
| flask run & | ||
| sleep 5 | ||
| yarn test:e2e | ||
| sleep 20 | ||
| killall yarn | ||
| killall flask | ||
| rm -f "$(CURDIR)/standards_cache.sqlite" &&\ | ||
| NO_LOAD_GRAPH_DB=1 FLASK_CONFIG=development python -c "from application import create_app, sqla; app=create_app(mode='development'); app.app_context().push(); sqla.create_all()" &&\ | ||
| NO_LOAD_GRAPH_DB=1 FLASK_CONFIG=development python scripts/seed_e2e_fixtures.py | ||
|
|
||
| test: | ||
| [ -d "./venv" ] && . ./venv/bin/activate &&\ | ||
|
|
@@ -116,11 +133,11 @@ install-deps-typescript: | |
| install-deps: install-deps-python install-deps-typescript | ||
|
|
||
| install-python: | ||
| virtualenv -p python3 venv | ||
| virtualenv -p python3 venv | ||
| . ./venv/bin/activate &&\ | ||
| make install-deps-python &&\ | ||
| playwright install | ||
| playwright install # Python embeddings/scraping (prompt_client); NOT frontend e2e — keep when migrating to Cypress | ||
|
DevHusnainAi marked this conversation as resolved.
|
||
|
|
||
| install-typescript: | ||
| yarn add webpack && cd application/frontend && yarn build | ||
|
|
||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| const { defineConfig } = require('cypress'); | ||
|
|
||
| module.exports = defineConfig({ | ||
| video: false, | ||
|
DevHusnainAi marked this conversation as resolved.
|
||
| e2e: { | ||
| baseUrl: 'http://127.0.0.1:5000', | ||
| specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}', | ||
| supportFile: false, | ||
| }, | ||
| }); | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.