Skip to content

release: v0.13.3 (#471) #11

release: v0.13.3 (#471)

release: v0.13.3 (#471) #11

Workflow file for this run

name: Codeception
on:
workflow_dispatch:
push:
branches:
- develop
- main
pull_request:
types:
- opened
- synchronize
- ready_for_review
paths:
- 'bin/**'
- 'src/**'
- 'tests/**'
- '.github/workflows/codeception.yml'
- '**.php'
- '.env.dist'
- '.nvmrc'
- '.wp-env.json'
- 'codecov.yml'
- 'codeception.dist.yml'
- 'composer.json'
- 'composer.lock'
- 'package-lock.json'
- 'package.json'
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
# Runs the Codeception tests for WordPress.
#
# Performs the following steps:
# - Sets environment variables.
# - Checks out the repository.
# - Sets up PHP.
# - Installs Composer dependencies.
# - Sets up Node.js.
# - Installs npm dependencies.
# - Starts the WordPress Docker testing environment (with or without pcov coverage).
# - Logs PHP and WordPress versions from the container.
# - Runs Codeception tests (with coverage if enabled).
# - Uploads code coverage report to Codecov.io (if coverage is enabled).
# - Uploads HTML coverage report as an artifact (if coverage is enabled).
codeception:
name: PHP ${{ matrix.php }} WP ${{ matrix.wordpress }}${{ matrix.coverage && ' (coverage)' || '' }}
runs-on: ubuntu-24.04
permissions:
contents: read
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
## GF 2.9.x only supports from WP 6.5, and we have no way to access earlier versions.
php: ['8.4', '8.3', '8.2', '8.1']
wordpress: ['6.9','6.8', '6.7', '6.6', '6.5']
coverage: [0]
include:
- php: '8.4'
wordpress: '6.9'
coverage: '1'
# Unsupported combinated by wp-env
exclude:
- php: '8.4'
wordpress: ['6.5', '6.6']
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ matrix.wordpress == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wordpress ) }}
steps:
- name: Configure environment variables
run: |
echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV"
echo "PHP_FPM_GID=$(id -g)" >> "$GITHUB_ENV"
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false
##
# This allows Composer dependencies to be installed using a single step.
#
# Since the tests are currently run within the Docker containers where the PHP version varies,
# the same PHP version needs to be configured for the action runner machine so that the correct
# dependency versions are installed and cached.
##
- name: Set up PHP
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # v2.35.4
with:
php-version: '${{ matrix.php }}'
tools: composer:v2
extensions: json, mbstring
- name: Install Composer dependencies
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3.1.1
- name: Setup Node
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
cache: 'npm'
node-version-file: '.nvmrc'
- name: Install NPM dependencies
run: npm ci
- name: Create cache directories
run: mkdir -p ~/.wp-env/downloads tests/_data/plugins tests/_data/mu-plugins
- name: Cache WordPress downloads
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.wp-env/downloads
key: ${{ runner.os }}-wp-env-downloads-${{ hashFiles('.wp-env.json') }}
restore-keys: |
${{ runner.os }}-wp-env-downloads-
- name: Cache WordPress Plugins
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: |
tests/_data/plugins
tests/_data/mu-plugins
key: ${{ runner.os }}-wp-plugins-${{ hashFiles('.wp-env.json', 'bin/_lib.sh', 'bin/after-start.sh', 'bin/setup.sh') }}
restore-keys: |
${{ runner.os }}-wp-plugins-
- name: Setup .env file
run: |
cp .env.dist .env
echo GF_KEY=${{ secrets.GF_KEY }} >> .env
- name: Start the Docker testing environment
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
with:
timeout_minutes: 10
max_attempts: 3
command: |
${{ matrix.coverage && 'PCOV_ENABLED=1 ' || '' }}npm run wp-env start -- ${{ secrets.ACTIONS_STEP_DEBUG && '--debug' || '' }}
- name: Log versions
run: |
npm run wp-env -- run cli php -- -v
npm run wp-env -- run cli wp core version
- name: Run Acceptance Tests
run: |
npm run test:codecept -- run acceptance ${{ secrets.ACTIONS_STEP_DEBUG && '--debug' || '' }}
- name: Run Unit Tests
run: |
npm run test:codecept -- run unit ${{ secrets.ACTIONS_STEP_DEBUG && '--debug' || '' }}
- name: Run WPUnit Tests ${{ matrix.coverage && ' with coverage report' || '' }}
run: |
npm run test:codecept -- run wpunit ${{ secrets.ACTIONS_STEP_DEBUG && '--debug' || '' }} ${{ matrix.coverage && '--coverage --coverage-xml --coverage-html' || '' }}
- name: Upload test failure artifacts
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: test-failures-php${{ matrix.php }}-wp${{ matrix.wordpress }}
path: tests/_output/*.fail.html
if-no-files-found: ignore
- name: Upload HTML coverage report as artifact
if: ${{ matrix.coverage }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: wp-code-coverage-${{ matrix.php }}-${{ matrix.wordpress }}
path: tests/_output/coverage
overwrite: true
- name: Upload code coverage report
continue-on-error: true
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: tests/_output/coverage.xml
flags: wpunit
fail_ci_if_error: true