Skip to content

Commit dee57f1

Browse files
GaryJonesclaude
andcommitted
ci: add GitHub Actions workflows for CS, linting, and tests
Adds automated CI pipelines for code quality and testing: - cs-lint.yml: PHPCS, PHP linting, and XML validation - integration.yml: PHPUnit integration tests via wp-env Tests run on PHP 8.2+ with WordPress 6.4 and latest versions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent a0c74d0 commit dee57f1

File tree

2 files changed

+174
-0
lines changed

2 files changed

+174
-0
lines changed

.github/workflows/cs-lint.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: CS & Lint
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/cs-lint.yml'
7+
- '**.php'
8+
- '.phpcs.xml.dist'
9+
- 'phpunit.xml.dist'
10+
- 'composer.json'
11+
push:
12+
branches:
13+
- develop
14+
- trunk
15+
paths:
16+
- '.github/workflows/cs-lint.yml'
17+
- '**.php'
18+
- '.phpcs.xml.dist'
19+
- 'phpunit.xml.dist'
20+
- 'composer.json'
21+
workflow_dispatch:
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
checkcs:
28+
name: "Basic CS and QA checks"
29+
runs-on: ubuntu-latest
30+
31+
env:
32+
XMLLINT_INDENT: " "
33+
34+
strategy:
35+
matrix:
36+
php: ['8.2', 'latest', '8.5']
37+
fail-fast: false
38+
39+
continue-on-error: ${{ matrix.php == '8.5' }}
40+
41+
steps:
42+
- name: Setup PHP ${{ matrix.php }}
43+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
44+
with:
45+
php-version: ${{ matrix.php }}
46+
coverage: none
47+
tools: cs2pr
48+
49+
# Show PHP lint violations inline in the file diff.
50+
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
51+
- name: Register PHP lint violations to appear as file diff comments
52+
uses: korelstar/phplint-problem-matcher@cb2b753750ec7bf13a7cde0a476df8c5605bdfb1 # v1.2.0
53+
54+
# Show XML violations inline in the file diff.
55+
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
56+
- name: Register XML violations to appear as file diff comments
57+
uses: korelstar/xmllint-problem-matcher@1bd292d642ddf3d369d02aaa8b262834d61198c0 # v1.2.0
58+
59+
- name: Checkout code
60+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
61+
with:
62+
persist-credentials: false
63+
64+
# Validate the composer.json file.
65+
# @link https://getcomposer.org/doc/03-cli.md#validate
66+
- name: Validate Composer installation
67+
run: composer validate --no-check-all
68+
69+
# Install dependencies and handle caching in one go.
70+
# @link https://github.com/marketplace/actions/install-composer-dependencies
71+
- name: Install Composer dependencies
72+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
73+
74+
# Lint PHP.
75+
- name: Lint PHP against parse errors
76+
run: composer lint-ci | cs2pr
77+
78+
# Needed as runs-on: system doesn't have xml-lint by default.
79+
# @link https://github.com/marketplace/actions/xml-lint
80+
- name: Lint phpunit.xml.dist
81+
uses: ChristophWurst/xmllint-action@7c54ff113fc0f6d4588a15cb4dfe31b6ecca5212 # v1.2.1
82+
with:
83+
xml-file: ./phpunit.xml.dist
84+
xml-schema-file: ./vendor/phpunit/phpunit/phpunit.xsd
85+
86+
# Check the code-style consistency of the PHP files.
87+
- name: Check PHP code style
88+
continue-on-error: true
89+
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml
90+
91+
- name: Show PHPCS results in PR
92+
run: cs2pr ./phpcs-report.xml

.github/workflows/integration.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Run PHPUnit
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/integration.yml'
7+
- '**.php'
8+
- 'phpunit.xml.dist'
9+
- 'composer.json'
10+
push:
11+
branches:
12+
- develop
13+
- trunk
14+
paths:
15+
- '.github/workflows/integration.yml'
16+
- '**.php'
17+
- 'phpunit.xml.dist'
18+
- 'composer.json'
19+
workflow_dispatch:
20+
21+
permissions:
22+
contents: read
23+
24+
# Cancels all previous workflow runs for the same branch that have not yet completed.
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.ref }}
27+
cancel-in-progress: true
28+
29+
jobs:
30+
test:
31+
name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
32+
runs-on: ubuntu-latest
33+
34+
env:
35+
WP_VERSION: ${{ matrix.wordpress }}
36+
37+
strategy:
38+
matrix:
39+
include:
40+
# Check lowest supported WP version, with the lowest supported PHP.
41+
- wordpress: '6.4'
42+
php: '8.2'
43+
# Check latest WP with the highest supported PHP.
44+
- wordpress: 'latest'
45+
php: 'latest'
46+
fail-fast: false
47+
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
51+
with:
52+
persist-credentials: false
53+
54+
- name: Install wordpress environment
55+
run: npm install -g @wordpress/env
56+
57+
- name: Setup PHP ${{ matrix.php }}
58+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
59+
with:
60+
php-version: ${{ matrix.php }}
61+
62+
- name: Install Composer dependencies
63+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
64+
with:
65+
composer-options: --ignore-platform-req=php+
66+
67+
- name: Setup problem matchers for PHP
68+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
69+
70+
- name: Setup problem matchers for PHPUnit
71+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
72+
73+
- name: Setup wp-env
74+
run: wp-env start
75+
env:
76+
WP_ENV_CORE: WordPress/WordPress#${{ matrix.wordpress == 'latest' && 'master' || matrix.wordpress }}
77+
78+
- name: Run integration tests (single site)
79+
run: composer test:integration
80+
81+
- name: Run integration tests (multisite)
82+
run: composer test:integration-ms

0 commit comments

Comments
 (0)