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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.{css,json,scss,xml,yml}]
indent_style = space
indent_size = 2
136 changes: 92 additions & 44 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,97 @@
name: Tests

on:
pull_request:
branches: [main]
push:
branches: [main]
pull_request:
branches: [main]
push:
branches: [main]

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest

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

- name: Install PHP 8.4
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
ini-values: date.timezone='UTC'
extensions: posix, dom, curl, libxml, mbstring, zip, pcntl, pdo, pgsql, pdo_pgsql, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: pcov
tools: composer:v2

- name: Add PHP symlink for php84
run: sudo ln -s /usr/bin/php /usr/bin/php84

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Run PHP Lint
uses: overtrue/phplint@10.0
with:
path: ./src

# - name: Cache Composer packages
# uses: actions/cache@v3
# with:
# path: vendor
# key: ${{ runner.os }}-php-${{ hashFiles('composer.lock') }}
# restore-keys: |
# ${{ runner.os }}-php-

- name: Install dependencies
run: composer test-init

# - name: Static analysis
# run: composer qa
version_check:
runs-on: ubuntu-latest

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

- name: Read plugin version
id: current_version
shell: bash
run: |
set -euo pipefail

MAIN_FILE="src/i-order-terms.php"
PLUGIN_VERSION=$(grep -Po "^\s*\*\s*Version:\s*\K[^\s]+" "$MAIN_FILE" | head -n1)
echo "Plugin version: $PLUGIN_VERSION"
echo "version=$PLUGIN_VERSION" >> $GITHUB_OUTPUT

- name: Check plugin versions match
shell: bash
run: |
set -euo pipefail

VERSION="${{ steps.current_version.outputs.version }}"

CLASS_FILE="src/code/class-i-order-terms.php"
README_FILE="src/readme.txt"
CLASS_VER=$(grep -Po "const\s+PLUGIN_VERSION\s*=\s*'[^']+'" "$CLASS_FILE" | grep -Po "'\K[^']+(?=')")
README_VER=$(grep -Po "^\s*Stable tag:\s*\K[^\s]+" "$README_FILE" | head -n1)

echo "Main plugin version: $VERSION"
echo "Class version: $CLASS_VER"
echo "Stable version: $README_VER"

if [ -z "$VERSION" ] || [ -z "$CLASS_VER" ] || [ -z "$README_VER" ]; then
echo "Could not parse versions from files (v='$VERSION', class='$CLASS_VER', readme='$README_VER')." >&2
exit 1
fi
if [ "$VERSION" != "$CLASS_VER" ] || [ "$VERSION" != "$README_VER" ]; then
echo "Version mismatch: v=$VERSION, class=$CLASS_VER, readme=$README_VER" >&2
exit 1
fi
echo "All versions match!"

test:
runs-on: ubuntu-latest

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

- name: Install PHP 8.4
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
ini-values: date.timezone='UTC'
extensions: posix, dom, curl, libxml, mbstring, zip, pcntl, pdo, pgsql, pdo_pgsql, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: pcov
tools: composer:v2

- name: Add PHP symlink for php84
run: sudo ln -s /usr/bin/php /usr/bin/php84

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Run PHP Lint
uses: overtrue/phplint@10.0
with:
path: ./src

# - name: Cache Composer packages
# uses: actions/cache@v3
# with:
# path: vendor
# key: ${{ runner.os }}-php-${{ hashFiles('composer.lock') }}
# restore-keys: |
# ${{ runner.os }}-php-

- name: Install dependencies
run: composer test-init

# - name: Static analysis
# run: composer qa