Skip to content

[MOB-12020] playwright GitHub actions setup #1437

[MOB-12020] playwright GitHub actions setup

[MOB-12020] playwright GitHub actions setup #1437

Workflow file for this run

# This workflow will do a clean install of node dependencies, cache/restore them,
# build the source code and run tests
# source: https://github.com/actions/starter-workflows/blob/main/ci/node.js.yml
name: ci
permissions:
contents: read
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Use Node.js 18.12.0
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: "18.12.0"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn prepublishOnly
- run: node index.node.js
- run: yarn test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
- run: yarn check-deps
e2e-tests:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
browser: [chromium, firefox, webkit]
fail-fast: false
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Use Node.js 18.12.0
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: "18.12.0"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn prepublishOnly
- name: Install React example dependencies
working-directory: ./react-example
run: |
# Try frozen lockfile first, fallback to regeneration if corrupted
yarn install --frozen-lockfile || {
echo "Lockfile corrupted, regenerating..."
rm yarn.lock
yarn install
}
- name: Cache Playwright browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**/playwright.config.ts') }}
restore-keys: |
${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
${{ runner.os }}-playwright-
- name: Install Playwright browsers
working-directory: ./react-example
run: yarn playwright:install --with-deps
- name: Create environment configuration
working-directory: ./react-example
run: |
cat > .env << 'EOF'
API_KEY=${{ secrets.ITERABLE_API_KEY }}
JWT_SECRET=${{ secrets.JWT_SECRET }}
USE_JWT=true
JWT_GENERATOR=https://jwt-generator.stg-itbl.co/generate
[email protected]
EOF
- name: Build React example app
working-directory: ./react-example
run: yarn build
- name: Start React example server
working-directory: ./react-example
run: |
yarn webpack serve --config webpack.config.js --port 8080 &
for i in {1..15}; do
if curl -f http://localhost:8080 >/dev/null 2>&1; then
echo "Server is ready"
break
fi
if [ $i -eq 15 ]; then
echo "Server failed to start after 75 seconds"
exit 1
fi
echo "Waiting for server... (attempt $i/15)"
sleep 5
done
- name: Run Playwright tests
working-directory: ./react-example
run: yarn playwright test --project=${{ matrix.browser }}
env:
CI: true
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-${{ matrix.browser }}
path: react-example/playwright-report/
retention-days: 30