Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
83ab584
Merge branch 'main' into chore-add-phpunit-tests
colinmurphy Jun 3, 2025
b402f05
Removed Post_Data_Model class as not used anymore.
colinmurphy Jun 3, 2025
77ae3dd
Merge branch 'main' into chore-add-phpunit-tests
colinmurphy Jun 3, 2025
9ce7e07
Initial setup of testing framework.
colinmurphy Jun 4, 2025
4910d38
Modified workflow to fix working directory issue.
colinmurphy Jun 4, 2025
fd7b00c
Moved codeception into its own action.
colinmurphy Jun 4, 2025
d2417aa
Updated path for the codeception action.
colinmurphy Jun 4, 2025
9c387c0
Fixing action to get it working.
colinmurphy Jun 4, 2025
f41a5fa
Fixed path.
colinmurphy Jun 4, 2025
b9dc66a
Added missing step to get plugin directory.
colinmurphy Jun 4, 2025
4167311
Fixed variable for working directory to include plugins.
colinmurphy Jun 4, 2025
f5d3b54
Updating action. Not complete.
colinmurphy Jun 4, 2025
05e30c4
Updated workflow.
colinmurphy Jun 4, 2025
aaa3442
Fixed workflow.
colinmurphy Jun 4, 2025
bbbc9e4
Added .env.ci file
colinmurphy Jun 4, 2025
00501ab
Added missing install plugins script.
colinmurphy Jun 4, 2025
e949af5
Only install npm if it exists.
colinmurphy Jun 4, 2025
85c2210
Added tests.
colinmurphy Jun 4, 2025
86b4a38
Added codeception config file.
colinmurphy Jun 4, 2025
96881aa
Added missing dev packages for composer.
colinmurphy Jun 4, 2025
faebbea
Fixes for tests
colinmurphy Jun 4, 2025
75615de
Added codeception build.
colinmurphy Jun 4, 2025
a5cc643
Trying to cache composer vendor directory.
colinmurphy Jun 6, 2025
1af13c9
Removed cached files.
colinmurphy Jun 6, 2025
05c017f
Updated other actions for composer.
colinmurphy Jun 6, 2025
5ca6bb5
test: e2e tests init
ahuseyn Jun 12, 2025
e2bce02
test: add GH workflow for e2e
ahuseyn Jun 12, 2025
94a7d66
test: update workflow
ahuseyn Jun 12, 2025
7d438ee
test: add playwright config
ahuseyn Jun 12, 2025
778e441
test: add testing libraries to root package
ahuseyn Jun 12, 2025
7777d13
test: add lockfile
ahuseyn Jun 12, 2025
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
25 changes: 14 additions & 11 deletions .github/actions/code-quality/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ inputs:
working-directory:
description: 'Directory to run composer and quality tools in'
required: true
php-version:
description: 'PHP version to use'
required: false
default: '7.4'
composer-options:
description: 'Additional composer options'
required: false
default: '--no-progress'

runs:
using: "composite"
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2
coverage: none

- name: Install dependencies
uses: ramsey/composer-install@v2
- name: Setup PHP with Cached Composer
uses: ./.github/actions/setup-php-composer
with:
php-version: ${{ inputs.php-version }}
working-directory: ${{ inputs.working-directory }}
composer-options: "--no-progress"
composer-options: ${{ inputs.composer-options }}

- name: Run PHPStan
working-directory: ${{ inputs.working-directory }}
Expand All @@ -33,4 +36,4 @@ runs:
- name: Run PHP CodeSniffer
working-directory: ${{ inputs.working-directory }}
run: composer run-script check-cs
shell: bash
shell: bash
106 changes: 106 additions & 0 deletions .github/actions/codeception/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: 'Run Codeception Tests'
description: 'Sets up environment and runs Codeception test suites'
inputs:
working-directory:
description: 'Plugin directory to run tests in'
required: true
php:
description: 'PHP version'
required: true
extensions:
description: 'PHP extensions'
required: true
wordpress:
description: 'WordPress version'
required: true
composer-options:
description: 'Additional composer options'
required: false
default: '--no-progress'
runs:
using: "composite"
steps:
- name: Setup PHP with Cached Composer
uses: ./.github/actions/setup-php-composer
with:
php-version: ${{ inputs.php }}
working-directory: ${{ inputs.working-directory }}
composer-options: ${{ inputs.composer-options }}

- name: Setup environment
run: |
cp ${{ inputs.working-directory }}/.docker/.env.ci ${{ inputs.working-directory }}/.env
cd ${{ inputs.working-directory }}
echo "INCLUDE_EXTENSIONS=${{ inputs.extensions }}" >> .env
echo "WP_VERSION=${{ inputs.wordpress }}" >> .env
echo "PHP_VERSION=${{ inputs.php }}" >> .env
shell: bash

- name: Build test environment
run: composer run docker:build
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
WP_VERSION: ${{ inputs.wordpress }}
PHP_VERSION: ${{ inputs.php }}

- name: Start test environment
working-directory: ${{ inputs.working-directory }}
shell: bash
run: |
docker compose --env-file .env up --detach

CONTAINER_ID=$(docker compose ps -q wordpress)
if [ -n "$CONTAINER_ID" ]; then
docker exec $CONTAINER_ID init-docker.sh
else
echo "Error: WordPress container not found."
exit 1
fi
env:
WP_VERSION: ${{ inputs.wordpress }}
PHP_VERSION: ${{ inputs.php }}

- name: Run Acceptance Tests w/ Docker
working-directory: ${{ inputs.working-directory }}
shell: bash
run: |
docker exec \
--env DEBUG=${{ env.DEBUG }} \
--env SKIP_TESTS_CLEANUP=${{ env.SKIP_TESTS_CLEANUP }} \
--env SUITES=acceptance \
$(docker compose ps -q wordpress) \
bash -c "cd wp-content/plugins/$(basename ${{ inputs.working-directory }}) && bin/run-codeception.sh"
env:
DEBUG: ${{ env.ACTIONS_STEP_DEBUG }}
SKIP_TESTS_CLEANUP: 'true'
continue-on-error: true

- name: Run Functional Tests w/ Docker
working-directory: ${{ inputs.working-directory }}
shell: bash
run: |
docker exec \
--env DEBUG=${{ env.DEBUG }} \
--env SKIP_TESTS_CLEANUP=${{ env.SKIP_TESTS_CLEANUP }} \
--env SUITES=functional \
$(docker compose ps -q wordpress) \
bash -c "cd wp-content/plugins/$(basename ${{ inputs.working-directory }}) && bin/run-codeception.sh"
env:
DEBUG: ${{ env.ACTIONS_STEP_DEBUG }}
SKIP_TESTS_CLEANUP: 'true'
continue-on-error: true

- name: Run WPUnit Tests w/ Docker
working-directory: ${{ inputs.working-directory }}
shell: bash
run: |
docker exec \
--env COVERAGE=${{ inputs.coverage }} \
--env USING_XDEBUG=${{ inputs.coverage }} \
--env DEBUG=${{ env.DEBUG }} \
--env SUITES=wpunit \
$(docker compose ps -q wordpress) \
bash -c "cd wp-content/plugins/$(basename ${{ inputs.working-directory }}) && bin/run-codeception.sh"
env:
DEBUG: ${{ env.ACTIONS_STEP_DEBUG }}
15 changes: 10 additions & 5 deletions .github/actions/create-plugin-artifact/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ inputs:
slug:
description: 'Plugin slug (directory name under plugins/)'
required: true
composer-options:
description: 'Additional composer options'
required: false
default: '--no-progress'
runs:
using: "composite"
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
- name: Setup PHP with Cached Composer
uses: ./.github/actions/setup-php-composer
with:
php-version: '7.4'
php-version: ${{ inputs.php }}
working-directory: ${{ inputs.working-directory }}
composer-options: ${{ inputs.composer-options }}

- name: Install dependencies and build
- name: Create plugin artifact
working-directory: plugins/${{ inputs.slug }}
run: |
composer install --no-dev --optimize-autoloader
echo "${GITHUB_SHA}" > build-sha.txt
rm -f plugin-build/${{ inputs.slug }}-*.zip
composer archive -vvv --format=zip --file="plugin-build/${{ inputs.slug }}" --dir="."
Expand Down
50 changes: 50 additions & 0 deletions .github/actions/setup-php-composer/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Setup PHP with Cached Composer"
description: "Setup PHP and install Composer dependencies with caching"
inputs:
php-version:
description: "PHP version to setup"
required: false
default: "7.4"
working-directory:
description: "Working directory for composer install"
required: true
composer-options:
description: "Additional composer options"
required: false
default: "--no-progress --optimize-autoloader"
tools:
description: "Tools to install with PHP"
required: false
default: "composer:v2"

runs:
using: "composite"
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
tools: ${{ inputs.tools }}
coverage: none

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

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: |
${{ steps.composer-cache.outputs.dir }}
${{ inputs.working-directory }}/vendor
key: composer-${{ runner.os }}-php${{ inputs.php-version }}-${{ hashFiles(format('{0}/composer.lock', inputs.working-directory)) }}
restore-keys: |
composer-${{ runner.os }}-php${{ inputs.php-version }}-
composer-${{ runner.os }}-

- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
working-directory: ${{ inputs.working-directory }}
composer-options: ${{ inputs.composer-options }}
7 changes: 6 additions & 1 deletion .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Code Quality

on:
push:
branches:
- main
paths:
- 'plugins/**.php'
pull_request:
paths:
- 'plugins/**'
- 'plugins/**.php'

jobs:
run:
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Codeception

on:
push:
branches:
- main
paths:
- 'plugins/**.php'
pull_request:
paths:
- 'plugins/**.php'

# Cancel previous workflow run groups that have not completed.
concurrency:
# Group workflow runs by workflow name, along with the head branch ref of the pull request
# or otherwise the branch or tag ref.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
continuous_integration:
runs-on: ubuntu-latest
name: WordPress ${{ matrix.wordpress }} on PHP ${{ matrix.php }}

strategy:
matrix:
# TODO: Add back in once working
# php: ["8.4","8.3","8.2", "8.1", "8.0", "7.4"]
# wordpress: ["6.8","6.7", "6.6", "6.5", "6.4", "6.3", "6.2"]
php: [ "8.2"]
wordpress: [ "6.8" ]
include:
- php: "8.2"
wordpress: "6.8"
coverage: 1
exclude:
# New WP versions that dont support older PHP versions
- php: "8.0"
wordpress: "6.8"
- php: "8.0"
wordpress: "6.7"
- php: "8.0"
wordpress: "6.6"
- php: "8.0"
wordpress: "6.5"
- php: "7.4"
wordpress: "6.8"
- php: "7.4"
wordpress: "6.7"
- php: "7.4"
wordpress: "6.6"
- php: "7.4"
wordpress: "6.5"
fail-fast: false

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

- name: Get changed plugin directory
id: plugin
run: |
git fetch --prune --unshallow
plugin=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '^plugins/' | head -1 | cut -d/ -f2)
echo "slug=$plugin" >> $GITHUB_OUTPUT

- name: Run Codeception Tests
uses: ./.github/actions/codeception
with:
working-directory: plugins/${{ steps.plugin.outputs.slug }}
php: ${{ matrix.php }}
wordpress: ${{ matrix.wordpress }}
extensions: json,mbstring
46 changes: 46 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Playwright End-to-End Tests

on:
push:
branches:
- main
paths:
- "plugins/hwp-previews/**"
pull_request:
branches:
- main
paths:
- "plugins/hwp-previews/**"

jobs:
playwright-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: plugins/hwp-previews

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Install playwright browsers
run: npx playwright install chromium --with-deps

- name: Start wp-env
run: |
npm run wp-env -- start

- name: Run Playwright tests
run: npm run test:e2e

- name: Stop wp-env
run: npm wp-env -- stop
2 changes: 1 addition & 1 deletion .github/workflows/plugin-artifact-for-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Plugin Artifact for PR
on:
pull_request:
paths:
- 'plugins/**'
- 'plugins/**.php'

jobs:
create-plugin-artifact:
Expand Down
Loading
Loading