Skip to content
Open
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
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,54 @@ jobs:
- name: Run PHPStan
run: composer phpstan

unit:
name: Unit (PHPUnit)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'

- name: Cache Composer
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-unit-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-unit-

# wp-env downloads WordPress and the core PHPUnit suite into this
# directory, which is roughly a gigabyte of git clones. Caching it keeps
# `env:start` from re-cloning them on every run. The key covers the
# wp-env config and version, because a change to either means different
# sources have to be downloaded.
- name: Cache wp-env sources
uses: actions/cache@v4
with:
path: ~/.wp-env
key: ${{ runner.os }}-wp-env-${{ hashFiles('.wp-env.json', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-wp-env-

# Also installs the Composer dependencies through the postinstall script.
- name: Install dependencies
run: npm ci

- name: Start wp-env
run: npm run env:start

- name: Run unit tests
run: npm run test:unit

- name: Stop wp-env
if: always()
run: npm run env:stop

e2e:
name: E2E (Playwright)
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@ package/dist
# PHPStan result cache
/.phpstan-cache/

# PHPUnit
/.phpunit.result.cache
/phpunit.xml

# Generated docs (published to gh-pages by workflow)
/docs/
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"phpstan/phpstan": "^2.0",
"szepeviktor/phpstan-wordpress": "^2.0",
"php-stubs/wp-cli-stubs": "^2.10",
"php-stubs/woocommerce-stubs": "^9.0"
"php-stubs/woocommerce-stubs": "^9.0",
"phpunit/phpunit": "^9.6@stable",
"yoast/phpunit-polyfills": "^1.1@stable"
},
"config": {
"platform": {
Expand All @@ -34,6 +36,9 @@
],
"phpstan": [
"phpstan analyse --memory-limit=-1"
],
"test": [
"phpunit"
]
},
"minimum-stability": "dev"
Expand Down
Loading
Loading