- add composer install step to the workflow #2
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: GraphiQL End-to-End Tests | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
- master | ||
pull_request: | ||
branches: | ||
- develop | ||
- master | ||
paths: | ||
- '**.js' | ||
- '.github/workflows/*.yml' | ||
- '!docs/**' | ||
jobs: | ||
e2e-tests: | ||
name: E2E tests on Node ${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ['18'] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 7.4 | ||
extensions: mbstring, intl | ||
tools: composer | ||
- name: Install PHP dependencies | ||
run: | | ||
composer install --optimize-autoloader | ||
- name: Install JavaScript dependencies | ||
run: npm ci | ||
- name: Build Assets | ||
run: npm run build | ||
- name: Install Playwright dependencies | ||
run: | | ||
npx playwright install chromium firefox webkit --with-deps | ||
- name: Start WordPress Environment | ||
run: npm run wp-env -- start | ||
- name: Run E2E tests | ||
run: npm run test:e2e | ||
continue-on-error: true # This allows the workflow to continue even if this step fails, so that screenshots can be collected. | ||
- name: List Screenshots | ||
if: always() # Ensures this step always runs for diagnostic purposes | ||
run: | | ||
echo "Listing contents of artifacts/test-results/" | ||
ls -R artifacts/test-results/ || echo "No screenshots directory found" | ||
- name: Check for Screenshots and Upload if Present | ||
if: always() # This ensures the step runs regardless of previous success/failure | ||
run: | | ||
if [ -d artifacts/test-results/ ] && [ "$(ls -A artifacts/test-results/)" ]; then | ||
echo "Screenshots found, uploading..." | ||
echo "::set-output name=upload_screenshots::true" | ||
else | ||
echo "No screenshots found, skipping upload." | ||
echo "::set-output name=upload_screenshots::false" | ||
fi | ||
id: check_screenshots | ||
- name: Upload Screenshots on Failure | ||
if: always() # This ensures that the following steps are only run if the previous step fails. | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: failed-test-screenshots | ||
path: artifacts/test-results/ | ||
compression-level: 1 | ||
if-no-files-found: warn | ||
retention-days: 1 | ||
overwrite: true | ||
- name: Stop WordPress Environment | ||
run: npm run wp-env -- stop | ||