feat: Add E2E testing workflow with Playwright and PostgreSQL service
This commit is contained in:
84
.gitea/workflows/test-e2e.yml
Normal file
84
.gitea/workflows/test-e2e.yml
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
name: Run E2E Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
e2e:
|
||||||
|
name: E2E Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: mcr.microsoft.com/playwright/python:v1.55.0-jammy
|
||||||
|
env:
|
||||||
|
DATABASE_DRIVER: postgresql
|
||||||
|
DATABASE_HOST: postgres
|
||||||
|
DATABASE_PORT: '5432'
|
||||||
|
DATABASE_NAME: calminer_ci
|
||||||
|
DATABASE_USER: calminer
|
||||||
|
DATABASE_PASSWORD: secret
|
||||||
|
DATABASE_SCHEMA: public
|
||||||
|
DATABASE_SUPERUSER: calminer
|
||||||
|
DATABASE_SUPERUSER_PASSWORD: secret
|
||||||
|
DATABASE_SUPERUSER_DB: calminer_ci
|
||||||
|
DATABASE_URL: postgresql+psycopg2://calminer:secret@postgres:5432/calminer_ci
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:16
|
||||||
|
env:
|
||||||
|
POSTGRES_DB: calminer_ci
|
||||||
|
POSTGRES_USER: calminer
|
||||||
|
POSTGRES_PASSWORD: secret
|
||||||
|
options: >-
|
||||||
|
--health-cmd "pg_isready -U calminer -d calminer_ci"
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 10
|
||||||
|
steps:
|
||||||
|
- name: Install Node.js runtime
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||||
|
apt-get install -y nodejs
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Export PYTHONPATH
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
echo "PYTHONPATH=${{ github.workspace }}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Prepare Python environment
|
||||||
|
uses: ./.gitea/actions/setup-python-env
|
||||||
|
with:
|
||||||
|
use-system-python: 'true'
|
||||||
|
install-playwright: 'true'
|
||||||
|
run-db-setup: 'true'
|
||||||
|
|
||||||
|
- name: Run e2e tests
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
mkdir -p artifacts/pytest
|
||||||
|
pytest tests/e2e --junitxml=artifacts/pytest/e2e-results.xml
|
||||||
|
|
||||||
|
- name: Upload pytest results
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: e2e-pytest-results
|
||||||
|
path: artifacts/pytest/
|
||||||
|
|
||||||
|
- name: Upload Playwright artifacts
|
||||||
|
if: failure()
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: playwright-artifacts
|
||||||
|
path: playwright-report
|
||||||
@@ -70,58 +70,3 @@ jobs:
|
|||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: pytest tests/unit
|
run: pytest tests/unit
|
||||||
|
|
||||||
e2e:
|
|
||||||
name: E2E Tests
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: mcr.microsoft.com/playwright/python:v1.55.0-jammy
|
|
||||||
env:
|
|
||||||
DATABASE_DRIVER: postgresql
|
|
||||||
DATABASE_HOST: postgres
|
|
||||||
DATABASE_PORT: '5432'
|
|
||||||
DATABASE_NAME: calminer_ci
|
|
||||||
DATABASE_USER: calminer
|
|
||||||
DATABASE_PASSWORD: secret
|
|
||||||
DATABASE_SCHEMA: public
|
|
||||||
DATABASE_SUPERUSER: calminer
|
|
||||||
DATABASE_SUPERUSER_PASSWORD: secret
|
|
||||||
DATABASE_SUPERUSER_DB: calminer_ci
|
|
||||||
DATABASE_URL: postgresql+psycopg2://calminer:secret@postgres:5432/calminer_ci
|
|
||||||
services:
|
|
||||||
postgres:
|
|
||||||
image: postgres:16
|
|
||||||
env:
|
|
||||||
POSTGRES_DB: calminer_ci
|
|
||||||
POSTGRES_USER: calminer
|
|
||||||
POSTGRES_PASSWORD: secret
|
|
||||||
options: >-
|
|
||||||
--health-cmd "pg_isready -U calminer -d calminer_ci"
|
|
||||||
--health-interval 10s
|
|
||||||
--health-timeout 5s
|
|
||||||
--health-retries 10
|
|
||||||
steps:
|
|
||||||
- name: Install Node.js runtime
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
|
||||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
||||||
apt-get install -y nodejs
|
|
||||||
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Export PYTHONPATH
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
echo "PYTHONPATH=${{ github.workspace }}" >> "$GITHUB_ENV"
|
|
||||||
|
|
||||||
- name: Prepare Python environment
|
|
||||||
uses: ./.gitea/actions/setup-python-env
|
|
||||||
with:
|
|
||||||
use-system-python: 'true'
|
|
||||||
install-playwright: 'true'
|
|
||||||
|
|
||||||
- name: Run e2e tests
|
|
||||||
run: pytest tests/e2e
|
|
||||||
|
|||||||
Reference in New Issue
Block a user