feat: add playwright e2e workflow
This commit is contained in:
75
.gitea/workflows/playwright.yml
Normal file
75
.gitea/workflows/playwright.yml
Normal file
@@ -0,0 +1,75 @@
|
||||
name: Playwright Holiday Property Booking
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- develop
|
||||
- qa
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
- qa
|
||||
|
||||
jobs:
|
||||
playwright:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
github-server-url: https://git.dumas.ddns.net
|
||||
|
||||
- name: Resolve environment
|
||||
shell: bash
|
||||
env:
|
||||
GITEA_REF: ${{ gitea.ref }}
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
|
||||
case "$GITEA_REF" in
|
||||
refs/heads/develop)
|
||||
echo "PLAYWRIGHT_BASE_URL=http://192.168.1.15:7003" >> "$GITHUB_ENV"
|
||||
echo "PLAYWRIGHT_ENV_NAME=dev" >> "$GITHUB_ENV"
|
||||
;;
|
||||
refs/heads/qa)
|
||||
echo "PLAYWRIGHT_BASE_URL=http://192.168.1.15:6003" >> "$GITHUB_ENV"
|
||||
echo "PLAYWRIGHT_ENV_NAME=qa" >> "$GITHUB_ENV"
|
||||
;;
|
||||
*)
|
||||
echo "Skipping unmapped ref: $GITEA_REF"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Install Playwright browsers
|
||||
run: npx playwright install --with-deps chromium
|
||||
|
||||
- name: Wait for deployed app
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
|
||||
for attempt in 1 2 3 4 5 6 7 8 9 10; do
|
||||
if curl --fail --silent --show-error --location --max-time 15 "${PLAYWRIGHT_BASE_URL}/api/health" >/dev/null; then
|
||||
echo "Application is ready on attempt $attempt"
|
||||
exit 0
|
||||
fi
|
||||
echo "Application not ready on attempt $attempt; retrying..."
|
||||
sleep 6
|
||||
done
|
||||
|
||||
echo "Application never became ready"
|
||||
exit 1
|
||||
|
||||
- name: Run Playwright suite
|
||||
run: npm run test:e2e
|
||||
|
||||
Reference in New Issue
Block a user