Merge branch 'release/1.0' #66
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: Run unit tests | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
- release/* | |
- feature/* | |
jobs: | |
build: | |
# Job name is Greeting | |
name: tests | |
# This job runs on Linux | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:8.0 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: yes | |
MYSQL_DATABASE: lamp | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
env: | |
extensions: pcov, curl, intl, mysqli, json, dom, bcmath, zip | |
key: cache-v4 | |
COVERAGE_DIR: ${{ github.workspace }}/coverage | |
COVERAGE_TMP_DIR: ${{ github.workspace }}/coverage-tmp | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Create directories | |
run: | | |
mkdir -p $COVERAGE_DIR | |
mkdir -p $COVERAGE_TMP_DIR | |
#- name: Added MySQL users | |
# run: | | |
# mysql -uroot -proot -e "CREATE DATABASE tests; CREATE USER 'default'@'localhost' IDENTIFIED WITH mysql_native_password BY 'secret'; GRANT ALL PRIVILEGES ON * . * TO 'default'@'localhost'; \q" | |
- name: Setup cache environment | |
id: cache-env | |
uses: shivammathur/cache-extensions@v1 | |
with: | |
php-version: 8.1 | |
extensions: ${{ env.extensions }} | |
key: ${{ env.key }} | |
- name: Cache extensions | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.cache-env.outputs.dir }} | |
key: ${{ steps.cache-env.outputs.key }} | |
restore-keys: ${{ steps.cache-env.outputs.key }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.1 | |
extensions: ${{ env.extensions }} | |
ini-values: > | |
post_max_size=256M, | |
short_open_tag=On, | |
pcov.directory='${{ github.workspace }}/', | |
pcov.exclude='/.*\/vendor\/.*/' | |
coverage: pcov | |
tools: pecl,composer:v1 | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Cache composer dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Install PHP dependencies | |
run: composer install --prefer-dist | |
- name: Patch issues with WordPress test suite | |
run: | | |
cd vendor/wordpress/wordpress/tests/phpunit/tests | |
grep -lr "@covers [_a-z]\{1,\}" . | xargs sed -i -e 's/@covers \([_a-z]\)/@covers \\\1/g' | |
# Core unit tests | |
- name: Run core unit tests | |
run: | | |
composer run-script tests -- --log-junit ~/results/core.xml --coverage-php $COVERAGE_TMP_DIR/core.cov | |
- name: Upload code coverage | |
uses: actions/upload-artifact@v1 | |
if: ${{ success() || failure() }} | |
with: | |
name: coverage | |
path: ${{ env.COVERAGE_DIR }} | |