Merge pull request #492 from buddypress/feature/misc-changes #234
This file contains 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: Unit Tests | |
on: | |
pull_request: | |
push: | |
branches: [ master ] | |
jobs: | |
tests: | |
name: "WP: ${{ matrix.wp_version }} - PHP: ${{ matrix.php }}" | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
php: ['7.4', '8.0', '8.1', '8.2'] | |
wp_version: ['master'] | |
include: | |
- php: '8.0' | |
wp_version: '6.4' | |
- php: '7.4' | |
wp_version: '6.4' | |
- php: '7.4' | |
wp_version: '5.8' | |
env: | |
WP_ENV_PHP_VERSION: ${{ matrix.php }} | |
WP_VERSION: ${{ matrix.wp_version }} | |
steps: | |
- name: Cancel previous runs of this workflow (pull requests only) | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Check Gitignored files | |
run: if [[ ! -z $(git ls-files -i --exclude-standard) ]]; then exit 1; fi | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
tools: composer:v2 | |
coverage: none | |
- name: Install Composer dependencies | |
uses: ramsey/composer-install@v2 | |
with: | |
composer-options: "--ignore-platform-reqs" | |
- name: Adapt WP PHPUnit version for WP < 6.1 | |
run: | | |
if [ ${{ env.WP_VERSION }} == '5.8' ]; then | |
composer require wp-phpunit/wp-phpunit:6.0 --dev --ignore-platform-reqs | |
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 phpunit | |
if: ${{ success() || failure() }} | |
- name: Running multisite unit tests | |
run: npm run phpunit:mu | |
if: ${{ success() || failure() }} | |
- name: Stop Docker environment | |
run: npm run wp-env stop | |
if: ${{ success() || failure() }} |