cleanup #15
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Playwright Tests | |
on: | |
pull_request: | |
branches: [main] | |
jobs: | |
test: | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install | |
- name: Install Playwright Browsers | |
run: pnpm exec playwright install --with-deps | |
- name: Wait for Vercel Preview | |
id: wait_for_preview | |
run: | | |
# Maximum wait time in seconds (5 minutes) | |
max_wait=300 | |
wait_interval=10 | |
elapsed=0 | |
while [ $elapsed -lt $max_wait ]; do | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
DEPLOYMENTS=$(curl -s -H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \ | |
"https://api.vercel.com/v6/deployments?meta-githubPrId=$PR_NUMBER&state=READY&limit=1") | |
PREVIEW_URL=$(echo $DEPLOYMENTS | jq -r '.deployments[0].url') | |
if [ ! -z "$PREVIEW_URL" ] && [ "$PREVIEW_URL" != "null" ]; then | |
if [[ $PREVIEW_URL != http* ]]; then | |
PREVIEW_URL="https://$PREVIEW_URL" | |
fi | |
echo "PREVIEW_URL=$PREVIEW_URL" >> $GITHUB_OUTPUT | |
echo "Preview URL found: $PREVIEW_URL" | |
exit 0 | |
fi | |
echo "Waiting for Vercel preview deployment... (${elapsed}s elapsed)" | |
sleep $wait_interval | |
elapsed=$((elapsed + wait_interval)) | |
done | |
echo "Timeout waiting for Vercel preview deployment" | |
exit 1 | |
env: | |
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
- name: Run Playwright tests | |
run: | | |
echo "Testing against URL: $PLAYWRIGHT_TEST_BASE_URL" | |
env: | |
PLAYWRIGHT_TEST_BASE_URL: ${{ steps.wait_for_preview.outputs.PREVIEW_URL }} | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: playwright-report | |
path: | | |
playwright-report/ | |
test-results/ | |
retention-days: 30 |