Skip to content

playwright ci

playwright ci #12

Workflow file for this run

name: "Run Playwright tests"
on:
pull_request:
push:
branches:
- main
- 'releases/*'
workflow_dispatch:
jobs:
test-linux:
name: Playwright tests on ${{ matrix.os }} (headless=${{ matrix.headless }})
runs-on: ubuntu-20.04 # Specify the Ubuntu version you prefer
strategy:
fail-fast: false
matrix:
headless: [true]
steps:
# 1. Checkout the repository
- uses: actions/checkout@v3
# 2. Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
# 3. Setup pnpm
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7.x
# 4. Cache pnpm dependencies
- name: Cache pnpm dependencies
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# 5. Install dependencies
- name: Install dependencies
run: pnpm install
# 6. Build the @instructure/idb-cache package
- name: Build idb-cache package
run: pnpm --filter @instructure/idb-cache build
# 7. Build the idb-cache-app
- name: Build idb-cache-app
run: pnpm --filter idb-cache-app build
# 8. Serve the idb-cache-app
- name: Serve idb-cache-app
run: pnpm --filter idb-cache-app preview -- --port 3000 &
# The '&' runs the serve command in the background
# 9. Wait for the server to be ready
- name: Wait for idb-cache-app to be ready
run: |
for i in {1..60}; do
if curl -s http://localhost:3000 > /dev/null; then
echo "Server is ready!"
break
fi
echo "Waiting for server to be ready... ($i/60)"
sleep 1
done
# 10. Run Playwright tests in headless mode
- name: Run Playwright tests (Headless)
if: ${{ matrix.headless == true }}
run: pnpm --filter idb-cache-app playwright test
# 11. Run Playwright tests in headful mode on Linux
- name: Run Playwright tests (Headful)
if: ${{ matrix.headless == false }}
run: |
export HEADFUL=true
xvfb-run --auto-servernum -- pnpm --filter idb-cache-app playwright test