Skip to content

Merge pull request #59 from thebrandonallen/dependabot/npm_and_yarn/b… #90

Merge pull request #59 from thebrandonallen/dependabot/npm_and_yarn/b…

Merge pull request #59 from thebrandonallen/dependabot/npm_and_yarn/b… #90

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: PHPUnit Tests
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
tests:
name: "WP: ${{ matrix.wp_version }} - PHP: ${{ matrix.php }}"
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.4', '8.0', '8.1', '8.2']
wp_version: ['5.9', '6.0', '6.1', '6.2', '6.3', 'master']
include:
- php: '7.2'
wp_version: '5.1'
- php: '7.2'
wp_version: '5.8'
- php: '7.4'
wp_version: '5.8'
- php: '8.0'
wp_version: '5.8'
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_VERSION: ${{ matrix.wp_version }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Cancel previous runs of this workflow
uses: styfle/cancel-workflow-action@0.5.0
with:
access_token: ${{ github.token }}
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- name: Log information
run: |
echo "$GITHUB_REF"
echo "$GITHUB_EVENT_NAME"
npm --version
node --version
git --version
php --version
composer --version
- name: Validate Composer
run: composer validate --strict
- name: Install Composer dependencies
uses: ramsey/composer-install@v1
with:
composer-options: "--ignore-platform-reqs"
- name: Adjust phpunit/wp-phpunit version
run: if [ ${{ env.WP_VERSION }} == '5.1' ]; then composer require --dev --with-all-dependencies "wp-phpunit/wp-phpunit:5.1.*" "phpunit/phpunit:^6"; fi
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Validate node modules
run: if [[ -f package.json ]]; then npm audit --audit-level=high --production --cache ~/.npm; fi
- name: Install node modules
run: npm ci --cache ~/.npm
- name: Setup WordPress
run: echo "{\"core\":\"WordPress/WordPress#${WP_VERSION}\"}" >> .wp-env.override.json
- name: Install WordPress
run: |
chmod -R 767 ./
npm run wp-env start -- --update
- name: Running single site unit tests
run: npm run test-php
if: ${{ success() || failure() }}
- name: Stop Docker environment
run: npm run wp-env stop
if: ${{ success() || failure() }}