Skip to content

Bot Human Links

Bot Human Links #5722

name: Run Integration Tests (Playright)
on:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- 'main'
concurrency:
# Cancel previous job
group: integration_tests-${{ github.ref }}
cancel-in-progress: true
jobs:
integration-tests:
runs-on: ubuntu-latest
environment: testing_env
env:
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/test_metaculus"
AWS_STORAGE_BUCKET_NAME: ${{ vars.AWS_STORAGE_BUCKET_NAME }}
AWS_S3_REGION_NAME: ${{ vars.AWS_S3_REGION_NAME }}
PUBLIC_APP_URL: http://localhost:3000/
NODE_ENV: "production"
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.playwright
services:
db:
image: pgvector/pgvector:pg16
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: test_metaculus
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: "redis:8.2.1-alpine"
env:
ALLOW_EMPTY_PASSWORD: yes
ports:
- 6379:6379
steps:
- name: Check out repository
uses: actions/checkout@v4
- id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.12.3"
- name: Install poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Cache Python virtualenv
id: cache-poetry-venv
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
# - name: Load cached venv
# id: cached-poetry-dependencies
# uses: actions/cache@v4
# with:
# path: .venv
# key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cache-poetry-venv.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Cache Playwright browsers
id: cache-playwright
uses: actions/cache@v4
with:
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
key: playwright-${{ runner.os }}-${{ hashFiles('front_end/package-lock.json') }}
restore-keys: |
playwright-${{ runner.os }}
- name: Install Playwright deps
if: steps.cache-playwright.outputs.cache-hit != 'true'
run: poetry run python -m playwright install chromium --with-deps
- name: Restore the min DB for testing
run: |
wget https://github.com/Metaculus/metaculus/releases/download/v0.0.1-alpha/test_metaculus.sql.zip
unzip test_metaculus.sql.zip
psql $DATABASE_URL -c "CREATE EXTENSION vector;"
pg_restore --dbname=$DATABASE_URL \
--clean \
--no-privileges \
--no-owner \
--if-exists \
--schema=public \
test_metaculus.sql
- name: "Install Node"
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache-dependency-path: front_end/package-lock.json
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: front_end/node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('front_end/package-lock.json') }}
- name: Install node_modules
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: cd front_end && npm ci
- name: Build the frontend
run: cd front_end && npm run build
- name: Run the integration tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TURNSTILE_SECRET_KEY: ${{ secrets.TURNSTILE_SECRET_KEY }}
PUBLIC_TURNSTILE_SITE_KEY: ${{ secrets.PUBLIC_TURNSTILE_SITE_KEY }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: |
poetry run ./manage.py migrate
PLAYWRIGHT_BROWSERS_PATH=${PLAYWRIGHT_BROWSERS_PATH} scripts/tests/run_integration_tests.sh
- name: Create trace.zip
if: ${{ !cancelled() }}
run: |
mkdir -p trace && cd trace && unzip ../trace.zip && rm ../trace.zip
# Uncomment this to stop the job at this spot, and get a remote shell into the VM
# - name: Get tty-share
# if: always()
# run: |
# curl -L https://github.com/elisescu/tty-share/releases/download/v2.4.0/tty-share_linux-amd64 -o tty-share
# chmod u+x ./tty-share
# export TERM=xterm-256color
# ./tty-share -A --public --headless --headless-cols 255 --headless-rows 50 --no-wait --listen :8001
- name: "Upload trace.zip"
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
if-no-files-found: error
retention-days: 90
name: playwright-trace
path: trace/