Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- name: Install Composer dependencies & cache dependencies
if: steps.check_composer_file.outputs.files_exists == 'true'
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v3
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4
Comment thread
swissspidy marked this conversation as resolved.
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
with:
Expand Down
154 changes: 154 additions & 0 deletions .github/workflows/reusable-functional.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Functional testing
on:
workflow_call:
inputs:
php:
Comment thread
swissspidy marked this conversation as resolved.
type: string
required: true
wp:
type: string
required: true
dbtype:
type: string
required: false
default: 'mysql'
mysql:
type: string
required: false
default: ''
object_cache:
type: string
required: false
default: 'none'
coverage:
type: boolean
required: false
default: false
os:
type: string
required: false
default: 'ubuntu-22.04'

permissions:
contents: read

jobs:
functional:
name: PHP ${{ inputs.php }} | WP ${{ inputs.wp }} | ${{ inputs.dbtype == 'sqlite' && 'SQLite' || inputs.dbtype == 'mariadb' && 'MariaDB' || 'MySQL' }}${{ inputs.object_cache == 'sqlite' && ' (Obj Cache)' || '' }}${{ inputs.coverage && ' (with coverage)' || '' }}${{ startsWith( inputs.os, 'windows' ) && ' (Windows)' || '' }}${{ startsWith( inputs.os, 'macos' ) && ' (macOS)' || '' }}
runs-on: ${{ inputs.os || 'ubuntu-22.04' }}

continue-on-error: ${{ inputs.dbtype == 'sqlite' || inputs.dbtype == 'mariadb' || inputs.php == 'nightly' }}

env:
MYSQL_HOST: 127.0.0.1
MYSQL_TCP_PORT: 3306
WP_CLI_TEST_DBROOTUSER: root
WP_CLI_TEST_DBROOTPASS: root
WP_CLI_TEST_DBNAME: wp_cli_test
WP_CLI_TEST_DBUSER: wp_cli_test
WP_CLI_TEST_DBPASS: password1
WP_CLI_TEST_DBHOST: 127.0.0.1:3306
WP_CLI_TEST_OBJECT_CACHE: ${{ inputs.object_cache }}

steps:
- name: Check out source code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install Ghostscript
if: ${{ inputs.os == 'ubuntu-22.04' || inputs.os == '' }}
run: |
sudo apt-get update
sudo apt-get install ghostscript -y

- name: Set up PHP environment
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
with:
php-version: '${{ inputs.php }}'
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
extensions: gd, imagick, mysql, zip, pdo_sqlite
coverage: ${{ inputs.coverage && 'xdebug' || 'none' }}
tools: composer
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Change ImageMagick policy to allow pdf->png conversion.
if: ${{ inputs.os == 'ubuntu-22.04' || inputs.os == '' }}
run: |
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml

# This date is used to ensure that the PHP compatibility cache is cleared at least once every week.
# http://man7.org/linux/man-pages/man1/date.1.html
- name: "Get last Monday's date"
id: get-date
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT"
Comment thread
swissspidy marked this conversation as resolved.
Outdated

- name: Install Composer dependencies & cache dependencies
uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v3
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
with:
custom-cache-suffix: ${{ steps.get-date.outputs.date }}

# MySQL 8.4 requires explicit loading of mysql_native_password plugin
- name: Determine MySQL authentication configuration
id: mysql-config
if: ${{ inputs.dbtype != 'sqlite' && inputs.mysql == 'mysql-8.4' }}
run: |
echo "auth-config<<EOF" >> $GITHUB_OUTPUT
echo "mysql_native_password=ON" >> $GITHUB_OUTPUT
echo "authentication_policy=mysql_native_password," >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Setup MySQL Server
id: setup-mysql
if: ${{ inputs.dbtype != 'sqlite' }}
uses: shogo82148/actions-setup-mysql@840178c12b07a58353c6312be784c23b63756eea # v1
with:
mysql-version: ${{ inputs.mysql }}
auto-start: true
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
user: ${{ env.WP_CLI_TEST_DBUSER}}
password: ${{ env.WP_CLI_TEST_DBPASS}}
# Fall back to legacy configuration for MySQL 5.6, 5.7, 8.0 and MariaDB.
my-cnf: |
${{ steps.mysql-config.outputs.auth-config || 'default_authentication_plugin=mysql_native_password' }}
${{ inputs.dbtype == 'mariadb' && '[client]' || '' }}
${{ inputs.dbtype == 'mariadb' && 'disable-ssl-verify-server-cert' || '' }}

- name: Prepare test database
if: ${{ inputs.dbtype != 'sqlite' }}
run: composer prepare-tests

- name: Check Behat environment
env:
WP_VERSION: '${{ inputs.wp }}'
WP_CLI_TEST_DBTYPE: ${{ inputs.dbtype || 'mysql' }}
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
WP_CLI_TEST_DEBUG_BEHAT_ENV: 1
run: composer behat

- name: Run Behat
env:
WP_VERSION: '${{ inputs.wp }}'
WP_CLI_TEST_DBTYPE: ${{ inputs.dbtype || 'mysql' }}
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
WP_CLI_TEST_COVERAGE: ${{ inputs.coverage }}
BEHAT_ARGS: ${{ format( '{0}', runner.debug && '--format=pretty' ) }}
run: |
composer behat -- $BEHAT_ARGS || composer behat-rerun -- $BEHAT_ARGS

- name: Retrieve list of coverage files
id: coverage_files
if: ${{ inputs.coverage }}
run: |
FILES=$(find "$GITHUB_WORKSPACE/build/logs" -path '*.*' | paste -s -d "," -)
echo "files=$FILES" >> $GITHUB_OUTPUT

- name: Upload code coverage report
if: ${{ inputs.coverage }}
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
with:
# Because somehow providing `directory: build/logs` doesn't work for these files
files: ${{ steps.coverage_files.outputs.files }}
flags: feature
token: ${{ secrets.CODECOV_TOKEN }}
56 changes: 8 additions & 48 deletions .github/workflows/reusable-regenerate-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,61 +44,21 @@ jobs:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Configure git user
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- name: Check if remote branch exists
id: check_remote_branch
run: |
echo "exists=$(git ls-remote --exit-code --heads origin regenerate-readme &>/dev/null && echo "true" || echo "false")" >>"${GITHUB_OUTPUT}"

- name: Create branch to base pull request on
if: ${{ steps.check_remote_branch.outputs.exists == 'false' }}
run: |
git checkout -b regenerate-readme

- name: Fetch existing branch to add commits to
if: ${{ steps.check_remote_branch.outputs.exists == 'true' }}
run: |
git fetch --all --prune
git checkout regenerate-readme
git pull --no-rebase

- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar
sudo mv wp-cli-nightly.phar /usr/local/bin/wp
sudo chmod +x /usr/local/bin/wp

- name: Regenerate README.md file
run: |
wp package install "wp-cli/scaffold-package-command:^2"
wp scaffold package-readme --branch=${{ github.event.repository.default_branch }} --force .

Comment thread
swissspidy marked this conversation as resolved.
- name: Check if there are changes
id: check_changes
run: |
echo "detected=$(test -n "$(git status --porcelain 2>/dev/null)" && echo "true" || echo "false")" >>"${GITHUB_OUTPUT}"

- name: Commit changes
if: ${{ steps.check_changes.outputs.detected == 'true' }}
run: |
git add README.md
git commit -m "Regenerate README file - $(date +'%Y-%m-%d')"
git push origin regenerate-readme

- name: Create pull request
if: ${{ steps.check_changes.outputs.detected == 'true' && steps.check_remote_branch.outputs.exists == 'false' }}
uses: repo-sync/pull-request@7e79a9f5dc3ad0ce53138f01df2fad14a04831c5 # v2
uses: peter-evans/create-pull-request@v7
Comment thread
swissspidy marked this conversation as resolved.
Outdated
with:
source_branch: regenerate-readme
destination_branch: ${{ github.event.repository.default_branch }}
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: Regenerate README file
pr_body: |
branch: regenerate-readme
base: ${{ github.event.repository.default_branch }}
token: ${{ secrets.GITHUB_TOKEN }}
title: Regenerate README file
body: |
**This is an automated pull-request**

Refreshes the `README.md` file with the latest changes to the docblocks in the source code.
pr_label: scope:documentation
labels: scope:documentation
commit-message: "Regenerate README file"
Loading
Loading