name: Run unit tests on PR on: pull_request: paths-ignore: - '**/changelog/**' defaults: run: shell: bash concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: {} jobs: test: if: ${{ github.event.pull_request.user.login != 'github-actions[bot]' }} name: PHP ${{ matrix.php }} WP ${{ matrix.wp }} ${{ matrix.hpos && 'HPOS' || '' }} timeout-minutes: 30 runs-on: ubuntu-20.04 permissions: contents: read continue-on-error: ${{ matrix.wp == 'nightly' }} env: HPOS: ${{ matrix.hpos }} strategy: fail-fast: false matrix: php: ['7.4', '8.0'] wp: ['latest'] unittests: ['shard1', 'shard2'] include: - wp: nightly php: '7.4' unittests: 'shard1' - wp: nightly php: '7.4' unittests: 'shard2' - wp: '6.1' php: 7.4 unittests: 'shard1' - wp: '6.1' php: 7.4 unittests: 'shard2' - wp: 'latest' php: '7.4' hpos: true unittests: 'shard1' - wp: 'latest' php: '7.4' hpos: true unittests: 'shard2' services: database: image: mysql:5.6 env: MYSQL_ROOT_PASSWORD: root ports: - 3306:3306 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 steps: - uses: actions/checkout@v3 - name: Setup WooCommerce Monorepo uses: ./.github/actions/setup-woocommerce-monorepo with: php-version: ${{ matrix.php }} - id: parseMatrix name: Parse Matrix Variables uses: actions/github-script@v6 with: script: | const parseWPVersion = require( './.github/workflows/scripts/parse-wp-version' ); parseWPVersion( '${{ matrix.wp }}' ).then( ( version ) => { core.setOutput( 'wpVersion', version ); } ); - name: Prepare Testing Environment env: WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }} WP_ENV_PHP_VERSION: ${{ matrix.php }} run: pnpm --filter=woocommerce env:test - name: Run Tests env: WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }} WP_ENV_PHP_VERSION: ${{ matrix.php }} run: pnpm --filter=woocommerce test:unit:env --testsuite ${{ matrix.unittests }}