GH Actions: WordPress + BuddyPress test environment
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: Tests | |
on: [ push ] | |
jobs: | |
tests: | |
runs-on: ubuntu-20.04 | |
if: "!contains(github.event.head_commit.message, '[skip ci]')" | |
strategy: | |
matrix: | |
wp-versions: [ 5.6 ] | |
php-versions: [ 7.4 ] | |
name: WP ${{ matrix.wp-versions }} on PHP ${{ matrix.php-versions }} | |
env: | |
php-ini-values: post_max_size=256M | |
wp-bp-directory: src/wp-content/plugins/buddypress | |
DB_DATABASE: wordpress_test | |
DB_USER: root | |
DB_PASSWORD: 'root' | |
DB_HOST: localhost | |
steps: | |
- run: | | |
sudo /etc/init.d/mysql start | |
mysql -e 'CREATE DATABASE wordpress_test;' -uroot -proot | |
mysql -e 'SHOW DATABASES;' -uroot -proot | |
- name: Cancel previous runs of this workflow | |
uses: styfle/cancel-workflow-action@0.6.0 | |
with: | |
access_token: ${{ github.token }} | |
- name: Checkout WordPress | |
uses: actions/checkout@v2 | |
with: | |
repository: WordPress/wordpress-develop | |
ref: ${{ matrix.wp-versions }} | |
path: '' | |
- name: Checkout BuddyPress | |
uses: actions/checkout@v2 | |
with: | |
path: ${{ env.wp-bp-directory }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
tools: pecl | |
php-version: ${{ matrix.php-versions }} | |
ini-values: ${{ env.php-ini-values }} | |
env: | |
update: true | |
- name: Get Composer cache directory | |
working-directory: ${{ env.wp-bp-directory }} | |
id: composer-cache | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Cache Composer dependencies | |
uses: actions/cache@v1 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Install Composer dependencies | |
working-directory: ${{ env.wp-bp-directory }} | |
run: composer install -q --prefer-dist --no-progress --ansi --no-interaction --no-suggest | |
- name: Install NodeJS | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 12.16.0 | |
- name: Cache NodeJS modules | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm- | |
- name: Install Node dependencies | |
working-directory: ${{ env.wp-bp-directory }} | |
run: npm ci | |
- name: Install phpunit 5.x on PHP 5.6 | |
if: ${{ matrix.php-versions == '5.6' }} | |
run: | | |
composer global require --dev phpunit/phpunit ^5 -q --prefer-dist --no-progress --ansi --no-interaction --no-suggest | |
phpunit --version | |
- name: Install phpunit 6.x on PHP 7.4 | |
if: ${{ matrix.php-versions == '7.4' }} | |
run: | | |
composer global require --dev phpunit/phpunit ^6 -q --prefer-dist --no-progress --ansi --no-interaction --no-suggest | |
phpunit --version | |
- name: Set up tests config | |
run: | | |
cp wp-tests-config-sample.php wp-tests-config.php | |
sed -i "s/youremptytestdbnamehere/${{ env.DB_DATABASE }}/" wp-tests-config.php | |
sed -i "s/yourusernamehere/${{ env.DB_USER }}/" wp-tests-config.php | |
sed -i "s/yourpasswordhere/${{ env.DB_PASSWORD }}/" wp-tests-config.php | |
sed -i "s/localhost/${{ env.DB_HOST }}:${{ job.services.mysql.ports['3306'] }}/" wp-tests-config.php | |
- name: Upload build artifact (TEMP) | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wp-${{ matrix.wp-versions }}-php-${{ matrix.php-versions }} | |
path: wp-tests-config.php | |
- name: Run phpunit tests | |
working-directory: ${{ env.wp-bp-directory }} | |
run: phpunit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have this error