Skip to content

Commit 228977b

Browse files
authored
Restructure workflows, tests and dev packages (#86)
- refactors GitHub's actions to run a matrix of tests for PHP >= 7.0 - implements [PHPUnit-Polyfills](https://github.com/Yoast/PHPUnit-Polyfills) - reorganizes test files for ease of access and extension - simplifies composers, exposing one slick file for library users - separates concerns, grouping dev-related files in the `dev` directory ### What problem does it fix? - tests are now run for all required PHP versions - there were 2 top-level composer files, now only the right one is exposed ### How to test if it works? - create a branch and set up a PR, the CI should run and test your code against all PHP & OS versions - expect at least 27 checks
1 parent 557dd5e commit 228977b

32 files changed

+290
-5957
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Run PHPUnit tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
description: 'Operating system to run tests on'
8+
required: false
9+
type: 'string'
10+
default: 'ubuntu-latest'
11+
php:
12+
description: 'The version of PHP to use, in the format of X.Y'
13+
required: true
14+
type: 'string'
15+
phpunit-config:
16+
description: 'The PHPUnit configuration file to use'
17+
required: false
18+
type: 'string'
19+
default: 'phpunit.xml.dist'
20+
env:
21+
LOCAL_PHP: ${{ inputs.php }}-fpm
22+
PHPUNIT_CONFIG: ${{ inputs.phpunit-config }}
23+
24+
jobs:
25+
phpunit-tests:
26+
name: ${{ inputs.os }}
27+
runs-on: ${{ inputs.os }}
28+
timeout-minutes: 20
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
- name: Set up PHP
35+
uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: '${{ inputs.php }}'
38+
tools: phpunit-polyfills
39+
40+
- name: Install Composer dependencies
41+
uses: ramsey/composer-install@v3
42+
with:
43+
ignore-cache: "yes"
44+
composer-options: "--optimize-autoloader"
45+
46+
- name: Run PHPUnit tests
47+
run: phpunit tests --testdox

.github/workflows/phpunit-tests.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: PHPUnit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- trunk
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
name: PHP ${{ matrix.php }}
12+
uses: ./.github/workflows/phpunit-tests-run.yml
13+
permissions:
14+
contents: read
15+
secrets: inherit
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ ubuntu-latest, macos-latest, windows-latest ]
20+
php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
21+
22+
with:
23+
os: ${{ matrix.os }}
24+
php: ${{ matrix.php }}
25+
phpunit-config: ${{ 'phpunit.xml.dist' }}

composer-dev.json

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)