gocodebox/lifterlms-rest

View on GitHub
.github/workflows/test-phpunit.yml

Summary

Maintainability
Test Coverage
###
#
# This workflow file is deployed into this repository via the "Sync Organization Files" workflow
#
# Direct edits to this file are at risk of being overwritten by the next sync. All edits should be made
# to the source file.
#
# @see Sync workflow {@link https://github.com/gocodebox/.github/actions/workflows/workflow-sync.yml}
# @see Workflow template {@link https://github.com/gocodebox/.github/blob/trunk/.github/workflow-templates/test-phpunit.yml}
#
###
name: Test PHPUnit

on:
  workflow_dispatch:
    inputs:
      cache-suffix:
        description: Cache suffix
        type: string
  pull_request:
  # Once daily at 01:00 UTC.
  # schedule:
  #  - cron: '0 1 * * *'

concurrency:
  group: ${{ github.workflow }}-${{ 'pull_request' == github.event_name && github.head_ref || github.sha }}
  cancel-in-progress: true

jobs:

  ###
  #
  # Setup the test matrix.
  #
  ###
  set-matrix:
    name: Setup Matrix
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.setup.outputs.matrix }}
    steps:
      - uses: actions/checkout@v2
      - id: setup
        uses: gocodebox/.github/.github/actions/setup-matrix@trunk

  ###
  #
  # Run tests.
  #
  ###
  test:
    name: WP ${{ matrix.WP }} on PHP ${{ matrix.PHP }}${{ matrix.name-append }}

    needs: set-matrix
    runs-on: ubuntu-latest
    continue-on-error: ${{ matrix.allow-failure }}

    strategy:
      fail-fast: false
      matrix: ${{ fromJSON( needs.set-matrix.outputs.matrix ) }}

    steps:

      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Environment
        uses: gocodebox/.github/.github/actions/setup-phpunit@trunk
        with:
          php-version: ${{ matrix.PHP }}
          wp-version: ${{ matrix.WP }}
          llms-branch: ${{ matrix.LLMS }}
          env-file: ".github/.env.test-phpunit"
          deploy-key: ${{ secrets.LLMS_DEPLOY_KEY }}
          secrets: ${{ toJSON( secrets ) }}
          cache-suffix: ${{ inputs.cache-suffix }}

      - name: Install NPM Dependencies
        run: npm ci && npm run build

      - name: Run Tests
        run: composer run tests

  ###
  #
  # Check the status of the entire test matrix.
  #
  # This will succeed if all jobs from the `test` job's matrix succeed. It allows jobs marked with `allow-failure`
  # to fail.
  #
  # This job can be used as a single status check for branch protection rules. Without this
  # we would need to require every job in the above build matrix.
  #
  ###
  status:
    name: Test PHPUnit Status
    runs-on: ubuntu-latest
    if: ${{ always() }}
    needs: test
    steps:
      - name: Check overall matrix status
        if: ${{ 'success' != needs.test.result }}
        run: exit 1