Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Lint

on:
push:
branches:
- trunk
pull_request:

jobs:
phpcs:
name: PHPCS (WordPress Coding Standards)
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout
uses: actions/checkout@v6
with:
# Need history on PRs so we can diff against the base ref.
fetch-depth: ${{ github.event_name == 'pull_request' && 0 || 1 }}

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: composer:v2, cs2pr
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-phpcs-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-${{ runner.os }}-phpcs-

- name: Install composer dependencies
run: composer install --prefer-dist --no-progress --no-interaction

- name: Determine PHP files to scan
id: scan
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
FILES=$(git diff --name-only --diff-filter=ACMR "$BASE_SHA" HEAD -- '*.php' | tr '\n' ' ')
echo "Changed PHP files vs $BASE_SHA: $FILES"
{
echo "files<<EOF"
echo "$FILES"
echo "EOF"
} >> "$GITHUB_OUTPUT"
else
echo "Full-tree scan (push event)."
fi

- name: Run PHPCS
id: phpcs
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
FILES="${{ steps.scan.outputs.files }}"
if [ -z "${FILES// }" ]; then
echo "No PHP files changed in this PR; skipping PHPCS."
exit 0
fi
vendor/bin/phpcs --report-full --report-checkstyle=phpcs-report.xml $FILES
else
vendor/bin/phpcs --report-full --report-checkstyle=phpcs-report.xml
fi
continue-on-error: true

- name: Annotate PR with PHPCS results
if: always() && hashFiles('phpcs-report.xml') != ''
run: cs2pr --graceful-warnings phpcs-report.xml

- name: Fail if PHPCS reported issues
if: steps.phpcs.outcome == 'failure'
run: exit 1

js-lint:
name: ESLint & checktextdomain
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'

- name: Install npm dependencies
run: npm ci

- name: Run ESLint
run: npx grunt eslint:grunt eslint:core

- name: Run checktextdomain
run: npx grunt checktextdomain
126 changes: 126 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: PHPUnit Tests

on:
push:
branches:
- trunk
pull_request:

jobs:
phpunit:
name: PHP ${{ matrix.php }} / WP ${{ matrix.wp }}
runs-on: ubuntu-latest
timeout-minutes: 30

services:
mariadb:
image: mariadb:11
env:
MARIADB_ROOT_PASSWORD: root
MARIADB_DATABASE: wordpress_test
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=10

strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
wp: [ 'trunk' ]
experimental: [ false ]
include:
# PHP 8.5 is bleeding-edge: allow failures while still surfacing results.
- php: '8.5'
wp: 'trunk'
experimental: true
exclude:
- php: '8.5'
wp: 'trunk'
experimental: false

continue-on-error: ${{ matrix.experimental }}

env:
WP_DEVELOP_DIR: ${{ github.workspace }}/wordpress-develop
PLUGIN_SLUG: bbpress

steps:
- name: Checkout bbPress
uses: actions/checkout@v6
with:
path: plugin-src

- name: Checkout WordPress (${{ matrix.wp }})
uses: actions/checkout@v6
with:
repository: WordPress/wordpress-develop
ref: ${{ matrix.wp }}
path: wordpress-develop

- name: Move plugin into WordPress develop tree
run: |
mkdir -p "${WP_DEVELOP_DIR}/src/wp-content/plugins"
mv plugin-src "${WP_DEVELOP_DIR}/src/wp-content/plugins/${PLUGIN_SLUG}"

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
extensions: mysqli, mbstring, intl, curl, dom, json, libxml, xml, zip
ini-values: error_reporting=E_ALL, display_errors=On

- name: Get composer cache directory
id: composer-cache
working-directory: ${{ env.WP_DEVELOP_DIR }}/src/wp-content/plugins/${{ env.PLUGIN_SLUG }}
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-php${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-${{ runner.os }}-php${{ matrix.php }}-

- name: Install composer dependencies
working-directory: ${{ env.WP_DEVELOP_DIR }}/src/wp-content/plugins/${{ env.PLUGIN_SLUG }}
run: composer install --prefer-dist --no-progress --no-interaction

- name: Configure WordPress tests
working-directory: ${{ env.WP_DEVELOP_DIR }}
run: |
cp wp-tests-config-sample.php wp-tests-config.php
sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php
sed -i "s/yourusernamehere/root/" wp-tests-config.php
sed -i "s/yourpasswordhere/root/" wp-tests-config.php
sed -i "s|localhost|127.0.0.1|" wp-tests-config.php

- name: Wait for MariaDB to be ready
run: |
for i in {1..30}; do
if mysqladmin ping -h 127.0.0.1 -P 3306 -uroot -proot --silent; then
echo "MariaDB is up"
exit 0
fi
sleep 2
done
echo "MariaDB did not become ready in time" >&2
exit 1

- name: Show tool versions
working-directory: ${{ env.WP_DEVELOP_DIR }}/src/wp-content/plugins/${{ env.PLUGIN_SLUG }}
run: |
php --version
composer --version
vendor/bin/phpunit --version
mysql --version

- name: Run PHPUnit
working-directory: ${{ env.WP_DEVELOP_DIR }}/src/wp-content/plugins/${{ env.PLUGIN_SLUG }}
run: composer test
115 changes: 0 additions & 115 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module.exports = function( grunt ) {
// Ignore these
'!**/.{svn,git}/**',
'!.editorconfig',
'!.github/**',
'!.gitignore',
'!.travis.yml',
'!build/**',
'!Gruntfile.js',
'!node_modules/**',
Expand Down Expand Up @@ -276,7 +276,7 @@ module.exports = function( grunt ) {
ext: '.css',
src: [ 'includes/admin/styles/*/colors.scss' ],
options: {
implementation: require('node-sass'),
implementation: require('sass'),
outputStyle: 'expanded'
}
}
Expand Down
Loading