Skip to content

Commit 9f44b4d

Browse files
GaryJonesclaude
andcommitted
ci: add unit test workflow
Adds GitHub Actions workflow for running unit tests across multiple PHP versions (7.4, 8.1, 8.2, 8.3). Unit tests run without WordPress using Brain Monkey, enabling faster feedback on pure PHP logic. Workflow is hardened with: - Minimal permissions (contents: read) - Pinned action versions with SHA - persist-credentials: false 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent e7fb1df commit 9f44b4d

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/unit.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- trunk
8+
paths:
9+
- '**.php'
10+
- 'composer.json'
11+
- 'phpunit.xml.dist'
12+
- '.github/workflows/unit.yml'
13+
pull_request:
14+
paths:
15+
- '**.php'
16+
- 'composer.json'
17+
- 'phpunit.xml.dist'
18+
- '.github/workflows/unit.yml'
19+
workflow_dispatch:
20+
21+
permissions:
22+
contents: read
23+
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
unit-tests:
30+
name: PHP ${{ matrix.php }}
31+
runs-on: ubuntu-latest
32+
timeout-minutes: 10
33+
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
php:
38+
- '7.4'
39+
- '8.1'
40+
- '8.2'
41+
- '8.3'
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
46+
with:
47+
persist-credentials: false
48+
49+
- name: Setup PHP ${{ matrix.php }}
50+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
51+
with:
52+
php-version: ${{ matrix.php }}
53+
coverage: none
54+
55+
- name: Install Composer dependencies
56+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
57+
58+
- name: Setup problem matchers for PHP
59+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
60+
61+
- name: Setup problem matchers for PHPUnit
62+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
63+
64+
- name: Run unit tests
65+
run: composer test:unit

0 commit comments

Comments
 (0)