Skip to content

Run Cypress on main #1052

Run Cypress on main

Run Cypress on main #1052

Workflow file for this run

name: Run Cypress on main
on:
push:
branches:
- main
workflow_dispatch:
schedule:
# At 08:00 daily
- cron: '0 8 * * *'
jobs:
test:
name: WordPress ${{ matrix.wp-version }} (${{ matrix.spec }})
concurrency:
group: cypress - ${{ github.event.pull_request.number || github.ref }} - ${{ matrix.wp-version }} - ${{ matrix.spec }}
cancel-in-progress: true
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
wp-version: [null]
spec: ['block', 'global']
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Install and Build
run: |
npm ci
npx eslint --max-warnings 0 .
npm run build
- name: Get Latest WP Branch
if: ${{ matrix.wp-version }}
run: |
echo "branch=$(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/WordPress/WordPress/branches\?per_page\=100 | jq '.[].name' | awk '/-branch/' | sort -V | tail -n1 | tr -d '"')" >> $GITHUB_ENV
- name: Maybe remove .wp-env.json
if: ${{ matrix.wp-version }}
run: rm .wp-env.json
- name: Maybe change WP version
uses: jsdaniell/[email protected]
if: ${{ matrix.wp-version }}
with:
name: '.wp-env.json'
json: '{ "core": "WordPress/WordPress#${{ env.branch }}", "plugins":["."] }'
- name: Start server
run: |
npm install -g @wordpress/env
wp-env start --update
echo "WordPress version: `wp-env run cli core version`"
- name: Cypress run
uses: cypress-io/github-action@v6
with:
browser: chrome
spec: cypress/e2e/${{ matrix.spec }}.cy.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos
path: cypress/videos