Skip to content

Commit

Permalink
Update plugin unit testing with more WordPress versions and Nightly W…
Browse files Browse the repository at this point in the history
…ordPress builds (#1887)

* Modernize plugin testing

* Fix directory

* Fix the path

* Our older composer setup does not run on PHP 7.4

* Ensure we end the command

* Ensure we're passing WP_VERSION

* FROM should be after ARG

* Update PHP version

* Normalize E2E tests

* Ensure we're using PHP 8.2 for all

* Remove redudant steps and normalize output

* Reverse the order of the E2E tests

* Don't fail fast with Matrix

* Reintroduce "Maybe update DB" step to E2E tests

* Update DB on correct workflow

* Upload fail output to correct location

* Fix output path

* Revert E2E changes

* Use current WP version for default

* Use current WP version for default

* Include WP version for current E2E build

* Revert plugin E2E test to WP 6.4

* Add plugin unit tests for WordPress nightly

* Fix workflow name

* Update test names for better identification.

* Call out existing plugin E2E tests are against legacy Faust.
  • Loading branch information
Chris Wiegman authored May 16, 2024
1 parent ec6f4e9 commit 6e5ef28
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-next-example.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: E2E Test
name: E2E Test Packages (Legacy)

on:
pull_request:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-next-faustwp-example.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: E2E Test
name: E2E Test Packages

on:
pull_request:
paths-ignore:
- '**/*.md'

jobs:
e2e-test-next-getting-started-example:
e2e-test-faustwp-getting-started-example:
name: (faustwp) Next Getting Started Example on Node ${{ matrix.node }}
runs-on: ubuntu-22.04
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-nightly-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: E2E Nightly Test
name: E2E Test Packages (Nightly)

on:
workflow_run:
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/e2e-test-plugin.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: E2E Test Plugin
name: E2E Test Plugin (Legacy)

on:
pull_request:
paths-ignore:
- '**/*.md'

jobs:
e2e_test_plugin:
e2e_test_plugin_legacy:
timeout-minutes: 10
runs-on: ubuntu-22.04
steps:
Expand All @@ -20,12 +20,6 @@ jobs:
run: |
npm ci
npm run build
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: pcov
ini-values: pcov.directory=includes
- name: Setup Frontend
run: |
NEXT_PUBLIC_WORDPRESS_URL=http://localhost:8080 FAUSTWP_SECRET_KEY=00000000-0000-4000-8000-000000000001 npm run dev:next:getting-started &
Expand All @@ -34,7 +28,10 @@ jobs:
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
- name: Setup Containers
working-directory: plugins/faustwp
run: docker-compose up -d
run: |
docker-compose build \
--build-arg WP_VERSION=6.4
docker-compose up -d
- name: Sleep 15 seconds
run: sleep 15
- name: Maybe upgrade WP DB
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/test-plugin.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- '**/*.md'

jobs:
test_packages:
unit-test_packages:
name: "Test packages on Node.js ${{ matrix.node }} ${{ matrix.os }}"
strategy:
matrix:
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/unit-test-plugin-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Unit Test Plugin / WordPress Nightly

on:
pull_request:
paths-ignore:
- '**/*.md'

jobs:
unit_test_plugin:
runs-on: ubuntu-22.04

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

- name: Create Docker Containers
working-directory: ./plugins/faustwp
run: |
docker-compose build \
--build-arg WP_VERSION=6.5
docker-compose up -d
- name: Wait for db
run: |
while ! mysqladmin ping --host=127.0.0.1 --port=33066 --password=$MYSQL_ROOT_PASSWORD --silent; do
sleep 1
done
- name: Setup testing framework
working-directory: ./plugins/faustwp
run: docker exec -e COVERAGE=1 $(docker-compose ps -q wordpress) init-testing-environment.sh

- name: Ensure Correct WordPress version
working-directory: ./plugins/faustwp
run: |
docker exec -w /var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) wp core version --allow-root
docker exec -w /var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) wp core upgrade --version=nightly --force --allow-root
docker exec -w /var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) wp core version --allow-root
- name: Install and activate WP GraphQL
working-directory: ./plugins/faustwp
run: docker exec -e COVERAGE=1 -w /var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) wp plugin install wp-graphql --activate --allow-root

- name: Install Dependencies
working-directory: ./plugins/faustwp
run: docker exec -e COVERAGE=1 -w /var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) composer install

- name: Run unit tests
working-directory: ./plugins/faustwp
run: docker exec -e COVERAGE=1 -w /var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) composer test
48 changes: 48 additions & 0 deletions .github/workflows/unit-test-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Unit Test Plugin

on:
pull_request:
paths-ignore:
- '**/*.md'

jobs:
unit_test_plugin:
name: WordPress ${{ matrix.wordpress }}
runs-on: ubuntu-22.04
strategy:
matrix:
wordpress: [ '6.5', '6.4', '6.3', '6.2', '6.1' ]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create Docker Containers
env:
WP_VERSION: ${{ matrix.wordpress }}
working-directory: ./plugins/faustwp
run: |
docker-compose build \
--build-arg WP_VERSION=${{ matrix.wordpress }}
docker-compose up -d
- name: Wait for db
run: |
while ! mysqladmin ping --host=127.0.0.1 --port=33066 --password=$MYSQL_ROOT_PASSWORD --silent; do
sleep 1
done
- name: Setup testing framework
working-directory: ./plugins/faustwp
run: docker exec -e COVERAGE=1 $(docker-compose ps -q wordpress) init-testing-environment.sh

- name: Install and activate WP GraphQL
working-directory: ./plugins/faustwp
run: docker exec -e COVERAGE=1 -w /var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) wp plugin install wp-graphql --activate --allow-root

- name: Install Dependencies
working-directory: ./plugins/faustwp
run: docker exec -e COVERAGE=1 -w /var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) composer install

- name: Run unit tests
working-directory: ./plugins/faustwp
run: docker exec -e COVERAGE=1 -w /var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) composer test
7 changes: 2 additions & 5 deletions plugins/faustwp/.docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
ARG WP_VERSION=6.4

FROM wordpress:${WP_VERSION}

# Needed to specify the build args again after the FROM command.
ARG WP_VERSION

FROM wordpress:${WP_VERSION}-php8.2

# Save the build args for use by the runtime environment
ENV WP_VERSION=${WP_VERSION}

Expand Down
1 change: 1 addition & 0 deletions plugins/faustwp/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
links:
- db
environment:
WP_VERSION: ${WP_VERSION:-6.5}
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: root
Expand Down

0 comments on commit 6e5ef28

Please sign in to comment.