mirror of
https://hk.gh-proxy.com/https://github.com/mcp-wp/mcp-server.git
synced 2026-03-03 13:46:16 +08:00
135 lines
4 KiB
YAML
135 lines
4 KiB
YAML
name: Lint and Test
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
# Cancels all previous workflow runs for the same branch that have not yet completed.
|
|
concurrency:
|
|
# The concurrency group contains the workflow name and the branch name.
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
lint-php:
|
|
name: PHP Lints
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: latest
|
|
coverage: none
|
|
tools: composer, cs2pr
|
|
|
|
- name: Install PHP dependencies
|
|
uses: ramsey/composer-install@a2636af0004d1c0499ffca16ac0b4cc94df70565
|
|
with:
|
|
composer-options: '--prefer-dist --no-scripts'
|
|
|
|
- name: Validate composer.json
|
|
run: composer validate --no-check-all --strict
|
|
|
|
- name: Lint PHP
|
|
run: composer lint
|
|
|
|
|
|
unit-php:
|
|
name: 'PHP ${{ matrix.php }} - WP ${{ matrix.wp }}'
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
mysql:
|
|
image: mariadb:lts
|
|
env:
|
|
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: true
|
|
MARIADB_DATABASE: wordpress_test
|
|
MARIADB_MYSQL_LOCALHOST_USER: 1
|
|
MARIADB_MYSQL_LOCALHOST_GRANTS: USAGE
|
|
ports:
|
|
- 3306
|
|
options: --health-cmd="healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
|
|
continue-on-error: ${{ matrix.experimental }}
|
|
strategy:
|
|
matrix:
|
|
php: ['8.2']
|
|
wp: ['latest']
|
|
coverage: [false]
|
|
experimental: [false]
|
|
include:
|
|
- php: '8.3'
|
|
wp: 'latest'
|
|
coverage: true
|
|
experimental: false
|
|
|
|
- php: '8.4'
|
|
wp: 'trunk'
|
|
experimental: true
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ matrix.php }}
|
|
extensions: mysql
|
|
coverage: xdebug
|
|
tools: composer, cs2pr
|
|
|
|
- name: Shutdown default MySQL service
|
|
run: sudo service mysql stop
|
|
|
|
- name: Verify MariaDB connection
|
|
run: |
|
|
while ! mysqladmin ping -h"127.0.0.1" -P"${{ job.services.mysql.ports[3306] }}" --silent; do
|
|
sleep 1
|
|
done
|
|
|
|
- name: Install svn
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y subversion
|
|
|
|
- name: Set up tests
|
|
run: bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1:${{ job.services.mysql.ports['3306'] }} ${{ matrix.wp }} true
|
|
|
|
- name: Install PHP dependencies
|
|
uses: ramsey/composer-install@v3
|
|
with:
|
|
composer-options: '--prefer-dist --no-progress --no-interaction --no-scripts'
|
|
|
|
- name: Run tests
|
|
run: |
|
|
composer test
|
|
composer test:multisite
|
|
if: ${{ ! matrix.coverage }}
|
|
|
|
- name: Run tests with coverage
|
|
run: |
|
|
composer test -- --coverage-clover artifacts/coverage.xml
|
|
composer test:multisite -- --coverage-clover artifacts/coverage-multisite.xml
|
|
if: ${{ matrix.coverage }}
|
|
|
|
- name: Upload code coverage report
|
|
uses: codecov/codecov-action@v5.4.0
|
|
with:
|
|
files: artifacts/coverage.xml
|
|
flags: default
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
if: ${{ matrix.coverage }}
|
|
|
|
- name: Upload code coverage report
|
|
uses: codecov/codecov-action@v5.4.0
|
|
with:
|
|
files: artifacts/coverage-multisite.xml
|
|
flags: multisite
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
if: ${{ matrix.coverage }}
|