Skip to content

Commit

Permalink
ci: add e2e test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
johanohly committed Nov 20, 2024
1 parent b50894e commit a132728
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Playwright Tests

on:
push:
branches: ['main']
pull_request:
branches: ['main']
workflow_dispatch:

jobs:
e2e_tests:
name: 'E2E Tests'
timeout-minutes: 60
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2

- name: Set up env
run: cp .env.example .env && sed -i 's/password@db/password@localhost/' .env

- name: Cache dependencies
uses: actions/cache@v3
id: cache-dependencies
with:
path: node_modules
key: packages-${{ hashFiles('bun.lockb') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: bun install --frozen-lockfile

- name: Build the app
run: bun run build

- name: Start Services
run: bun run dx:up

- name: Cache playwright
id: cache-playwright
uses: actions/cache@v3
with:
path: |
~/.cache/ms-playwright
${{ github.workspace }}/node_modules/playwright
key: playwright-${{ hashFiles('bun.lockb') }}
restore-keys: playwright-

- name: Install playwright
if: steps.cache-playwright.outputs.cache-hit != 'true'
run: bunx playwright install --with-deps

- name: Create the database
run: bun run prisma:migrate-dev

- name: Seed the database
run: bun run prisma:seed

- name: Run Playwright tests
run: bun run test:e2e

- uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: 'test-results/*'
retention-days: 30
File renamed without changes.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"format": "prettier --write \"src/**/*.{js,ts,html,svelte,css}\" --ignore-path ./.prettierignore && eslint ./src --fix",
"test:unit": "vitest --run --passWithNoTests",
"test:unit:watch": "vitest --watch --passWithNoTests",
"pretest:e2e": "bun scripts/other/confirm.js \"Are you sure you want to run e2e tests? This will reset your database (yes/no)\"",
"test:e2e": "bun run db:reset && bunx playwright test && bun run db:reset",
"test:e2e": "start-server-and-test \"bun run preview --port 3000\" http://localhost:3000 \"bunx playwright test\"",
"pretest:e2e:dev": "bun scripts/other/confirm.js \"Are you sure you want to run e2e tests? This will reset your database (yes/no)\"",
"test:e2e:dev": "bun run db:reset && bunx playwright test && bun run db:reset",
"test:e2e:results": "bunx playwright show-report",
"coverage": "vitest --run --coverage --passWithNoTests",
"db:migrate-dev": "prisma migrate dev --skip-seed",
Expand Down Expand Up @@ -103,6 +104,7 @@
"prettier-plugin-tailwindcss": "^0.6.8",
"prisma": "^5.20.0",
"prisma-kysely": "^1.8.0",
"start-server-and-test": "^2.0.8",
"svelte": "^5.0.0",
"svelte-adapter-bun": "^0.5.2",
"svelte-check": "^4.0.4",
Expand Down

0 comments on commit a132728

Please sign in to comment.