godaddy-wordpress/go

View on GitHub
.github/workflows/run-tests.yml

Summary

Maintainability
Test Coverage
name: Tests

on:
  pull_request:
    branches:
      - master

jobs:
  php:
    name: PHP Unit
    runs-on: ubuntu-latest
    strategy:
      matrix:
        phpVersion: ["7.4", "8.3"]

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version-file: '.nvmrc'
          cache: 'yarn'

      - name: Setup WP-CLI
        uses: godaddy-wordpress/setup-wp-cli@1

      - name: Install dependencies and build
        run: |
          npm i -g yarn
          composer install
          yarn install --immutable
          yarn build

      - name: Setup wp-env
        uses: godaddy-wordpress/setup-wp-env@v1
        with:
          core: 'WordPress/WordPress#6.4'
          phpVersion: ${{ matrix.phpVersion }}
          plugins: '["https://downloads.wordpress.org/plugin/coblocks.zip","https://downloads.wordpress.org/plugin/woocommerce.zip"]'
          themes: '["."]'

      - name: Prepare tests
        run: |
          cd $(wp-env install-path)
          docker-compose run --rm -u $(id -u) -e HOME=/tmp tests-cli cp wp-content/themes/go/.dev/tests/php/assets/es_ES.mo wp-content/themes/go/languages/es_ES.mo

      - name: Run tests
        run: |
          wp-env run phpunit "composer run test --working-dir=html/wp-content/themes/go/"

  js:
    name: JS Unit
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version-file: '.nvmrc'
          cache: 'yarn'

      - name: Install dependencies
        run: yarn install --immutable

      - name: Run tests
        run: yarn run test:js

  a11y:
    name: Accessibility
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup wp-env
        uses: godaddy-wordpress/setup-wp-env@v1
        with:
          core: 'WordPress/WordPress#6.4'
          phpVersion: '8.3'
          plugins: '["https://downloads.wordpress.org/plugin/coblocks.zip","https://downloads.wordpress.org/plugin/woocommerce.zip"]'
          themes: '["."]'

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version-file: '.nvmrc'
          cache: 'yarn'

      - name: Setup WP-CLI
        uses: godaddy-wordpress/setup-wp-cli@1

      - name: Install dependencies and build
        run: |
          npm i -g yarn
          composer install
          yarn install --immutable
          yarn build

      - name: Prepare tests
        run: |
          wp-env run cli "wp db import wp-content/themes/go/.dev/tests/a11y-test-db.sql"

      - name: Run tests
        run: |
          A11Y=$(yarn test:a11y)
          echo "$A11Y"
          if [[ $A11Y != *"All accessibility tests have passed"* ]]; then
            exit 1
          fi

  e2e:
    name: Customizer E2E
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup wp-env
        uses: godaddy-wordpress/setup-wp-env@v1
        with:
          core: 'WordPress/WordPress#6.4'
          phpVersion: '8.3'
          plugins: '["https://downloads.wordpress.org/plugin/coblocks.zip","https://downloads.wordpress.org/plugin/woocommerce.zip"]'
          themes: '["."]'

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version-file: '.nvmrc'
          cache: 'yarn'

      - name: Setup WP-CLI
        uses: godaddy-wordpress/setup-wp-cli@1

      - name: Install dependencies and build
        run: |
          npm i -g yarn
          composer install
          yarn install --immutable
          yarn build

      - name: Prepare tests
        run: |
          wp-env run cli "wp theme activate go"
          wp-env run cli "wp option update permalink_structure '/%postname%'"

      - name: Run tests
        run: yarn test:e2e:customizer -- --record
        
      - name: Upload failure video
        if: ${{ failure() }}
        uses: actions/upload-artifact@v3
        with:
          name: customizer.spec.js.mp4
          path: ./.dev/tests/cypress/videos/**/*.mp4
          retention-days: 1