Merge pull request #406 from myrotvorets/renovate/sjinks-setup-wordpr… #1092
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: CI | |
on: | |
push: | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
unit-tests: | |
name: "WP ${{ matrix.config.wp }}, multisite: ${{ matrix.config.ms }}, PHP: ${{ matrix.config.php }}" | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { wp: latest, ms: 'no', php: '8.1', coverage: 'yes' } | |
- { wp: nightly, ms: 'no', php: '8.1', coverage: 'yes' } | |
- { wp: latest, ms: 'yes', php: '8.1', coverage: 'yes' } | |
- { wp: nightly, ms: 'yes', php: '8.1', coverage: 'yes' } | |
- { wp: latest, ms: 'no', php: '8.2' } | |
- { wp: nightly, ms: 'no', php: '8.2' } | |
- { wp: latest, ms: 'yes', php: '8.2' } | |
- { wp: nightly, ms: 'yes', php: '8.2' } | |
- { wp: latest, ms: 'no', php: '8.3' } | |
- { wp: nightly, ms: 'no', php: '8.3' } | |
- { wp: latest, ms: 'yes', php: '8.3' } | |
- { wp: nightly, ms: 'yes', php: '8.3' } | |
services: | |
mysql: | |
image: mariadb:latest@sha256:a9547599cd87d7242435aea6fda22a9d83e2c06d16c658ef70d2868b3d3f6a80 | |
ports: | |
- "3306:3306" | |
env: | |
MYSQL_ROOT_PASSWORD: wordpress | |
MARIADB_INITDB_SKIP_TZINFO: 1 | |
MYSQL_USER: wordpress | |
MYSQL_PASSWORD: wordpress | |
MYSQL_DATABASE: wordpress_test | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Install dependencies | |
run: sudo apt-get update && sudo apt-get -y install subversion | |
- name: Decide whether to enable coverage | |
id: coverage | |
run: | | |
if [ "${{ matrix.config.coverage }}" = "yes" ]; then | |
echo "coverage=pcov" >> "${GITHUB_OUTPUT}" | |
echo 'ini=pcov.directory=inc, pcov.exclude="~/(vendor|tests)/~"' >> "${GITHUB_OUTPUT}" | |
else | |
echo "coverage=none" >> "${GITHUB_OUTPUT}" | |
echo "ini=opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M" >> "${GITHUB_OUTPUT}" | |
fi | |
- name: Set up PHP | |
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # 2.31.1 | |
with: | |
coverage: ${{ steps.coverage.outputs.coverage }} | |
ini-values: ${{ steps.coverage.outputs.ini }} | |
php-version: ${{ matrix.config.php }} | |
env: | |
fail-fast: 'true' | |
- name: Install dependencies | |
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # 3.0.0 | |
- name: Set up WordPress and WordPress Test Library | |
uses: sjinks/setup-wordpress-test-library@1332d0431f1d82b54ed40ec0c6708035694e6cad # v2.1.3 | |
with: | |
version: ${{ matrix.config.wp }} | |
- name: Set up multisite mode | |
run: echo "WP_MULTISITE=1" >> $GITHUB_ENV | |
if: matrix.config.ms == 'yes' | |
- name: Verify MariaDB connection | |
run: | | |
while ! mysqladmin ping -h 127.0.0.1 -P ${{ job.services.mysql.ports[3306] }} --silent; do | |
sleep 1 | |
done | |
timeout-minutes: 1 | |
- name: Run tests | |
run: | | |
OPTIONS= | |
if [ "${{ steps.coverage.outputs.coverage }}" != 'none' ]; then | |
OPTIONS="$OPTIONS --coverage-clover=clover.xml" | |
fi | |
vendor/bin/phpunit --order-by=random ${OPTIONS} | |
- name: Upload coverage report | |
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # v5.1.1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: clover.xml | |
flags: unittests | |
if: ${{ steps.coverage.outputs.coverage != 'none' }} |