Skip to content
Merged
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
52 changes: 47 additions & 5 deletions .github/workflows/reusable-code-quality.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,35 +23,48 @@ jobs:
actionlint:
name: Lint GitHub Actions workflows
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check out source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
Comment thread
swissspidy marked this conversation as resolved.

- name: Add problem matcher
run: |
curl -s -o .github/actionlint-matcher.json https://raw.githubusercontent.com/rhysd/actionlint/main/.github/actionlint-matcher.json
curl --fail --silent --show-error -o .github/actionlint-matcher.json https://raw.githubusercontent.com/rhysd/actionlint/main/.github/actionlint-matcher.json
echo "::add-matcher::.github/actionlint-matcher.json"

# Pinned by digest rather than `:latest`, so the linter cannot change
# underneath ~45 repositories without a commit here, and so the image layer
# can be reused instead of re-resolved on every run.
- name: Check workflow files
uses: docker://rhysd/actionlint:latest
uses: docker://rhysd/actionlint@sha256:5457037ba91acd225478edac3d4b32e45cf6c10291e0dabbfd2491c63129afe1 # v1.7.11
with:
args: -color -shellcheck=

lint:
name: Lint PHP files
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Check existence of composer.json file
id: check_composer_file
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"

# See the note on the equivalent step in reusable-unit.yml: no lock file is
# committed, so the cache key must be rotated on a schedule.
- name: Determine the weekly Composer cache suffix
id: composer-cache-suffix
run: echo "value=$(date -u +%Y-%W)" >> "$GITHUB_OUTPUT"

- name: Set up PHP environment
if: steps.check_composer_file.outputs.files_exists == 'true'
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
Expand All@@ -65,6 +78,8 @@ jobs:
- name: Install Composer dependencies & cache dependencies
if: steps.check_composer_file.outputs.files_exists == 'true'
uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # 4.0.0
with:
custom-cache-suffix: ${{ steps.composer-cache-suffix.outputs.value }}
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}

Expand DownExpand Up@@ -98,29 +113,37 @@ jobs:
lint-gherkin:
name: Lint Gherkin Feature files
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Setup node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 'lts/*'

# `--fail` matters here: without it curl happily writes an error page to the
# config file and the linter then runs against garbage rules.
- name: Download lint rules
run: curl https://raw.githubusercontent.com/wp-cli/.github/refs/heads/main/.gherkin-lintrc -o $RUNNER_TEMP/.gherkin-lintrc
run: curl --fail --silent --show-error https://raw.githubusercontent.com/wp-cli/.github/refs/heads/main/.gherkin-lintrc -o "$RUNNER_TEMP/.gherkin-lintrc"

- name: Run linter
run: npx --yes gherkin-lint -c $RUNNER_TEMP/.gherkin-lintrc
run: npx --yes gherkin-lint -c "$RUNNER_TEMP/.gherkin-lintrc"

lint-spellcheck:
name: Spell check
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check out source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Check existence of config file
id: check_files
Expand All@@ -133,17 +156,25 @@ jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Check out source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Check existence of composer.json & phpcs.xml.dist files
id: check_files
run: echo "files_exists=$([ -f composer.json ] && [ -f phpcs.xml.dist ] && echo true || echo false)" >> "$GITHUB_OUTPUT"

# See the note on the equivalent step in reusable-unit.yml: no lock file is
# committed, so the cache key must be rotated on a schedule.
- name: Determine the weekly Composer cache suffix
id: composer-cache-suffix
run: echo "value=$(date -u +%Y-%W)" >> "$GITHUB_OUTPUT"

- name: Set up PHP environment
if: steps.check_files.outputs.files_exists == 'true'
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
Expand All@@ -156,6 +187,8 @@ jobs:
- name: Install Composer dependencies & cache dependencies
if: steps.check_files.outputs.files_exists == 'true'
uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # 4.0.0
with:
custom-cache-suffix: ${{ steps.composer-cache-suffix.outputs.value }}
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}

Expand All@@ -177,17 +210,25 @@ jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Check out source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Check existence of composer.json file
id: check_files
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"

# See the note on the equivalent step in reusable-unit.yml: no lock file is
# committed, so the cache key must be rotated on a schedule.
- name: Determine the weekly Composer cache suffix
id: composer-cache-suffix
run: echo "value=$(date -u +%Y-%W)" >> "$GITHUB_OUTPUT"

- name: Set up PHP environment
if: steps.check_files.outputs.files_exists == 'true'
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
Expand All@@ -200,10 +241,11 @@ jobs:
- name: Install Composer dependencies & cache dependencies
if: steps.check_files.outputs.files_exists == 'true'
uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # 4.0.0
with:
custom-cache-suffix: ${{ steps.composer-cache-suffix.outputs.value }}
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}


- name: Check existence of vendor/bin/phpstan file
id: check_phpstan_binary_file
run: echo "files_exists=$(test -f vendor/bin/phpstan && echo true || echo false)" >> "$GITHUB_OUTPUT"
Expand Down
59 changes: 52 additions & 7 deletions .github/workflows/reusable-functional.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,20 +25,30 @@ on:
required: false
default: false
os:
description: 'Runner to use. Defaults to ubuntu-22.04, or the RUNNERS_NAME repository variable when set.'
type: string
required: false
default: 'ubuntu-22.04'
default: ''

permissions:
contents: read

jobs:
functional:
name: Behat | 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' }}
# The calling job already states "Behat | PHP x" and groups on it, so this only
# needs to identify the leg within that group. The database version is spelled
# out because "MySQL" alone rendered the mysql-8.0 and mysql-8.4 legs
# identically.
name: WP ${{ inputs.wp }} | ${{ inputs.dbtype == 'sqlite' && 'SQLite' || inputs.mysql || 'MySQL' }}${{ inputs.object_cache == 'sqlite' && ' (Obj Cache)' || '' }}${{ inputs.coverage && ' (with coverage)' || '' }}${{ startsWith( inputs.os, 'windows' ) && ' (Windows)' || '' }}${{ startsWith( inputs.os, 'macos' ) && ' (macOS)' || '' }}
# Repositories with a heavy Behat suite can point the default Linux legs at a
# larger runner by setting the `RUNNERS_NAME` repository variable, without
# having to fork this workflow. Explicit macOS/Windows legs are unaffected.
runs-on: ${{ inputs.os || vars.RUNNERS_NAME || 'ubuntu-22.04' }}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

continue-on-error: ${{ inputs.dbtype == 'mariadb' || inputs.php == 'nightly' || startsWith( inputs.os, 'windows' ) || startsWith( inputs.os, 'macos' ) }}

timeout-minutes: ${{ ( startsWith( inputs.os, 'windows' ) || startsWith( inputs.os, 'macos' ) ) && 120 || inputs.coverage && 90 || 60 }}

env:
MYSQL_HOST: 127.0.0.1
MYSQL_TCP_PORT: 3306
Expand DownExpand Up@@ -77,10 +87,21 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
Comment thread
swissspidy marked this conversation as resolved.

# Ghostscript ships with the GitHub-hosted images, so the `apt-get update`
# this used to run unconditionally cost every Behat leg ~25s for a package
# that was already there. Keep the install as a fallback in case a future
# image drops it.
- name: Install Ghostscript
if: ${{ inputs.os == 'ubuntu-22.04' || inputs.os == '' }}
# Keyed on the actual runner rather than the `os` input: an empty input no
# longer implies ubuntu-22.04 now that RUNNERS_NAME can select the image.
if: ${{ runner.os == 'Linux' }}
run: |
if command -v gs > /dev/null 2>&1; then
echo "Ghostscript $(gs --version) is already installed; skipping."
exit 0
fi
sudo apt-get update
sudo apt-get install ghostscript -y

Expand All@@ -90,7 +111,12 @@ jobs:

- name: Install dependencies (macOS)
if: ${{ startsWith(inputs.os, 'macos') }}
run: brew install ghostscript
run: |
if command -v gs > /dev/null 2>&1; then
echo "Ghostscript $(gs --version) is already installed; skipping."
exit 0
fi
brew install ghostscript

- name: Set up PHP environment
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
Expand All@@ -104,12 +130,31 @@ jobs:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Change ImageMagick policy to allow pdf->png conversion.
if: ${{ inputs.os == 'ubuntu-22.04' || inputs.os == '' }}
# Keyed on the actual runner rather than the `os` input, and tolerant of
# images that ship a different ImageMagick layout — `sed -i` on a missing
# file exits non-zero and would fail the leg.
if: ${{ runner.os == 'Linux' }}
run: |
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
if [ -f /etc/ImageMagick-6/policy.xml ]; then
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
else
echo 'No ImageMagick 6 policy file found; nothing to relax.'
fi

# WP-CLI packages do not commit a lock file, so `composer update` resolves
# dependencies on every run while the cache key stays pinned to composer.json.
# Rotating the suffix weekly stops `dev-*` requirements from being served out
# of an indefinitely stale cache. `%Y-%W` is portable across the GNU, BSD and
# Git-for-Windows implementations of `date`.
- name: Determine the weekly Composer cache suffix
id: composer-cache-suffix
shell: bash
run: echo "value=$(date -u +%Y-%W)" >> "$GITHUB_OUTPUT"

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

Expand Down
Loading