Skip to content

Commit

Permalink
Merge pull request #6 from luke-h1/feat/e2e-in-ci
Browse files Browse the repository at this point in the history
fix(ci): add e2e support in CI
  • Loading branch information
luke-h1 authored Aug 11, 2024
2 parents 3e9f7ba + 97e718c commit 4acaff4
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ runs:
run: pnpm test:ci
shell: bash

- name: stop test DB
run: docker compose down
shell: bash

- name: tsc
run: pnpm tsc
shell: bash

- name: build
run: pnpm build
shell: bash

- name: e2e local
uses: ./.github/actions/e2e
with:
target: e2e-local
36 changes: 36 additions & 0 deletions .github/actions/e2e/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: e2e tests
description: Run e2e tests
inputs:
target:
description: 'make target to execute'
required: true
runs:
using: composite
steps:
- name: Get installed Playwright version
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package.json').devDependencies['@playwright/test'])")" >> $GITHUB_ENV
shell: bash

- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}

- name: Install browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: make e2e-install-browsers
shell: bash

- name: ${{ inputs.environment }} UI tests
if: inputs.target == 'e2e-local'
run: ./scripts/setup-e2edb.sh && pnpx start-server-and-test dev 8000 e2e:local
shell: bash

- name: ${{ inputs.environment }} UI tests
if: inputs.target != 'e2e-local'
run: make ${{ inputs.target }}
shell: bash
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build": "npm run clean && tsc",
"clean": "rm -rf dist",
"commit": "npx cz",
"e2e:local": "make e2e-local",
"db:seed": "ts-node prisma/seed.ts",
"db:down": "pnpm prisma migrate reset",
"db:drop": "pnpm prisma db push --force-reset",
Expand Down
8 changes: 8 additions & 0 deletions scripts/setup-e2edb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

trap 'echo -e "\033[31m✖ An error occurred. Exiting...\033[0m"; exit 1;' ERR

DATABASE_URL='postgresql://pets:pets@localhost:5432/pets?schema=public' pnpm db:migrate-dev && DATABASE_URL='postgresql://pets:pets@localhost:5432/pets?schema=public' pnpm prisma db push
echo -e "\033[32m✔ Test Database migrated\033[0m"

0 comments on commit 4acaff4

Please sign in to comment.