Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 19 additions & 84 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
e2e-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
container:
image: mcr.microsoft.com/playwright:v1.56.1-jammy
options: --user 1001

strategy:
matrix:
Expand All @@ -62,117 +65,49 @@ jobs:
${{ runner.os }}-react-deps-
- 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
}
# Advanced browser caching strategy
- name: Cache Playwright browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-v2-${{ matrix.browser }}-${{ hashFiles('react-example/yarn.lock') }}
restore-keys: |
${{ runner.os }}-playwright-v2-${{ matrix.browser }}-
${{ runner.os }}-playwright-${{ matrix.browser }}-
${{ runner.os }}-playwright-v2-
# Browser-specific installation strategy
run: yarn install --frozen-lockfile

- name: Install Playwright browsers
working-directory: ./react-example
run: |
echo "πŸ“₯ Installing ${{ matrix.browser }} browser..."

# Smart installation based on browser type and cache status
cache_hit="${{ steps.playwright-cache.outputs.cache-hit }}"

if [ "$cache_hit" = "true" ]; then
echo "Cache hit: Installing browser only..."
yarn playwright install ${{ matrix.browser }}
elif [ "${{ matrix.browser }}" = "webkit" ]; then
echo "Cache miss + WebKit: Installing with dependencies..."
yarn playwright install ${{ matrix.browser }} --with-deps
elif [ "${{ matrix.browser }}" = "firefox" ]; then
echo "Cache miss + Firefox: Installing with dependencies..."
yarn playwright install ${{ matrix.browser }} --with-deps
else
echo "Cache miss + Chromium: Installing browser only..."
yarn playwright install ${{ matrix.browser }}
fi
# WebKit-specific dependency fix (Ubuntu 22.04 compatibility)
- name: Fix WebKit dependencies
if: matrix.browser == 'webkit'
run: |
echo "πŸ”§ Applying WebKit Ubuntu 22.04 fixes..."
sudo apt-get update -qq
# Install the exact library versions WebKit needs
sudo apt-get install -y libwoff2-1.1.0 libwoff2dec1 fonts-liberation || true
echo "βœ… WebKit dependencies updated"

# Browser environment setup (flags now handled by Playwright config)
- name: Setup browser environment
run: |
echo "πŸš€ Browser environment configured via Playwright config"
echo "βœ… CI-optimized browser launch parameters will be applied automatically"
echo "πŸ“₯ Installing ${{ matrix.browser }} browser (dependencies already in Docker image)..."
yarn playwright install ${{ matrix.browser }}
echo "βœ… Browser installed"
- 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
API_KEY=${{ secrets.ITERABLE_NO_JWT_API_KEY }}
USE_JWT=false
[email protected]
EOF
- name: Build React example app
working-directory: ./react-example
run: yarn build
# Enhanced server startup with better resource management
- name: Start React example server
working-directory: ./react-example
run: |
echo "πŸš€ Starting React server..."

# Set Node.js memory limits for better stability
export NODE_OPTIONS="--max-old-space-size=4096"

# Start server with optimized settings
yarn webpack serve --config webpack.config.js --port 8080 --host 0.0.0.0 &
SERVER_PID=$!
echo "Server started with PID: $SERVER_PID"

# Enhanced health check with better error reporting
for i in {1..20}; do
# Wait for server to be ready
for i in {1..30}; do
if curl -f http://localhost:8080 >/dev/null 2>&1; then
echo "βœ… Server ready after ${i} attempts ($(($i*3)) seconds)"
echo "βœ… Server ready after ${i} attempts"
break
fi
if [ $i -eq 20 ]; then
echo "❌ Server startup failed after 60 seconds"
echo "πŸ“‹ Debug information:"
ps aux | grep webpack || true
netstat -tulpn | grep 8080 || true
curl -v http://localhost:8080 || true
if [ $i -eq 30 ]; then
echo "❌ Server startup failed"
exit 1
fi
sleep 3
echo "Server startup attempt $i/20..."
sleep 2
done
# Enhanced test execution with browser-specific optimizations
- name: Run Playwright tests
working-directory: ./react-example
run: |
yarn playwright test --project=${{ matrix.browser }}
run: yarn playwright test --project=${{ matrix.browser }}
env:
CI: true
# Browser-specific environment variables
DISPLAY: :99 # Virtual display for browsers
# WebKit library path configuration
LD_LIBRARY_PATH: $HOME/.cache/ms-playwright/${{ matrix.browser }}-*/minibrowser-wpe/lib:$LD_LIBRARY_PATH
# Enhanced artifact management

- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
Expand All @@ -188,7 +123,7 @@ jobs:
name: test-results-${{ matrix.browser }}-${{ github.run_number }}
path: react-example/test-results/
retention-days: 7
# Comprehensive cleanup with port management

- name: Cleanup server processes
if: always()
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ results
browserstack.json
.DS_Store
stats.json
.idea
.idea
.cursor
Loading
Loading