Merge pull request #868 from newfold-labs/dependabot/npm_and_yarn/dev… #2664
This file contains hidden or 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: Cypress Tests | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| - 'develop' | |
| pull_request: | |
| types: [ opened, synchronize, reopened, ready_for_review ] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| # Disable permissions for all available scopes by default. | |
| # Any needed permissions should be configured at the job level. | |
| permissions: {} | |
| jobs: | |
| test: | |
| name: Run Cypress Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 | |
| with: | |
| php-version: '8.1' | |
| coverage: none | |
| tools: composer, cs2pr | |
| - name: Setup workflow context | |
| id: workflow | |
| working-directory: ${{ runner.temp }} | |
| env: | |
| REPO: ${{ github.repository }} | |
| run: | | |
| mkdir dist | |
| echo "DIST=${PWD}/dist" >> "$GITHUB_OUTPUT" | |
| echo "PACKAGE=${REPO##*/}" >> "$GITHUB_OUTPUT" | |
| - name: Use Node.js 20.x | |
| uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | |
| with: | |
| node-version: 20.x | |
| cache: 'npm' | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" | |
| - name: Cache Composer vendor directory | |
| uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| - name: Show versions | |
| run: | | |
| php --version | |
| composer --version | |
| node --version | |
| npm --version | |
| - name: Validate composer.json and composer.lock | |
| run: composer validate | |
| - name: Install PHP Dependencies | |
| run: composer install --no-progress --no-dev --optimize-autoloader --prefer-source | |
| - name: Setup Registry | |
| run: printf "\n//npm.pkg.github.com/:_authToken=${{ secrets.NEWFOLD_ACCESS_TOKEN }}" >> .npmrc | |
| - name: NPM Install | |
| run: npm install --legacy-peer-deps | |
| - name: Build JavaScript | |
| run: npm run build | |
| - name: Create Distribution Copy | |
| env: | |
| DIST: ${{ steps.workflow.outputs.DIST }} | |
| PACKAGE: ${{ steps.workflow.outputs.PACKAGE }} | |
| run: rsync -r --include-from=.distinclude --exclude-from=.distignore . "$DIST/$PACKAGE" | |
| - name: List Distribution Files | |
| working-directory: ${{ steps.workflow.outputs.DIST }} | |
| run: find . | |
| - name: Configure WordPress | |
| env: | |
| DIST: ${{ steps.workflow.outputs.DIST }} | |
| PACKAGE: ${{ steps.workflow.outputs.PACKAGE }} | |
| run: | | |
| jq -n \ | |
| --arg plugin "$DIST/$PACKAGE" \ | |
| '{plugins: [$plugin]}' > .wp-env.override.json | |
| - name: Install WordPress | |
| uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 | |
| with: | |
| timeout_minutes: 4 | |
| max_attempts: 3 | |
| command: npx wp-env start --debug | |
| - name: Run Cypress Tests | |
| run: npm run test:e2e -- --browser chrome | |
| - name: Store screenshots of test failures | |
| if: failure() | |
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 | |
| with: | |
| name: screenshots | |
| path: ./tests/cypress/screenshots | |
| - name: Output debug.log file contents | |
| if: always() | |
| continue-on-error: true | |
| run: | | |
| npx wp-env run wordpress cat /var/www/html/wp-content/debug.log | |
| - name: Output wordpress docker logs | |
| if: always() | |
| continue-on-error: true | |
| run: | | |
| npx wp-env logs --watch=false --debug=true |