95 lines
2.5 KiB
YAML
95 lines
2.5 KiB
YAML
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: Check existing Node.js
|
|
id: node-check
|
|
shell: bash
|
|
run: |
|
|
set -Eeuo pipefail
|
|
|
|
if command -v node >/dev/null 2>&1; then
|
|
node_version="$(node -p 'process.versions.node')"
|
|
node_major="${node_version%%.*}"
|
|
|
|
if [ "$node_major" = "20" ]; then
|
|
echo "use_existing_node=true" >> "$GITHUB_OUTPUT"
|
|
echo "Node.js $node_version already available; skipping setup-node"
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
echo "use_existing_node=false" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Setup Node.js
|
|
if: steps.node-check.outputs.use_existing_node != 'true'
|
|
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
|