Skip to content

Commit

Permalink
maint/update-tests (#12)
Browse files Browse the repository at this point in the history
* maint/update-tests Updated `.gitattributes`.

* maint/update-tests Updated `.github/workflows/test.yml`.

* maint/update-tests Updated `composer.json`.

* maint/update-tests Created `phpunit71.xml`.

* maint/update-tests Created `phpunit72.xml`.

* maint/update-tests Created `phpunit73.xml`.

* maint/update-tests Created `phpunit74.xml`.

* maint/update-tests Created `phpunit80.xml`.

* maint/update-tests Created `phpunit81.xml`.

* maint/update-tests Created `phpunit82.xml`.

* maint/update-tests Created `phpunit83.xml`.

* maint/update-tests Created `phpunit84.xml`.

* maint/update-tests Updated `test.sh`.

---------

Co-authored-by: david_smith <david_smith@sweetwater.com>
  • Loading branch information
zero-to-prod and david_smith authored Jan 4, 2025
1 parent b66c19c commit 5b27dc3
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 23 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
/LICENSE.md export-ignore
/logo.png export-ignore
/phpunit.xml export-ignore
/phpunit71.xml export-ignore
/phpunit72.xml export-ignore
/phpunit73.xml export-ignore
/phpunit74.xml export-ignore
/phpunit80.xml export-ignore
/phpunit81.xml export-ignore
/phpunit82.xml export-ignore
/phpunit83.xml export-ignore
/phpunit84.xml export-ignore
/README.md export-ignore
/SECURITY.md export-ignore
/test.sh export-ignore
26 changes: 6 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,15 @@ jobs:

strategy:
matrix:
php-version: [php71, php72, php73, php74, php80, php81, php82, php83, php84]
php-version: [84, 83, 82, 81, 80, 74, 73, 72, 71]

steps:
- uses: actions/checkout@v4

- name: Validate composer files
run: composer validate --strict

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ./vendor-${{ matrix.php-version }}
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-

- name: Install dependencies (if needed)
- name: Install dependencies for PHP${{ matrix.php-version }}
run: |
if [ ! -d ./vendor-${{ matrix.php-version }} ] || [ -z "$(ls -A ./vendor-${{ matrix.php-version }})" ]; then
echo "Dependencies not found or vendor directory is empty. Installing dependencies..."
docker compose run --rm -v ${{ github.workspace }}/vendor-${{ matrix.php-version }}:/app/vendor ${{ matrix.php-version }}composer composer install --prefer-dist
else
echo "Dependencies already installed for ${{ matrix.php-version }}. Skipping composer install."
fi
docker compose run --rm php${{ matrix.php-version }}composer composer update --no-cache
- name: Run tests
run: docker compose run --rm -v ${{ github.workspace }}/vendor-${{ matrix.php-version }}:/app/vendor ${{ matrix.php-version }} vendor/bin/phpunit
- name: Run PHPUnit tests for PHP${{ matrix.php-version }}
run: |
docker compose run --rm php${{ matrix.php-version }} vendor/bin/phpunit --configuration phpunit${{ matrix.php-version }}.xml
27 changes: 27 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,33 @@
],
"docker": [
"docker compose run --rm "
],
"test71": [
"docker compose run --rm php71 ./vendor/bin/phpunit --configuration phpunit71.xml"
],
"test72": [
"docker compose run --rm php72 ./vendor/bin/phpunit --configuration phpunit72.xml"
],
"test73": [
"docker compose run --rm php73 ./vendor/bin/phpunit --configuration phpunit73.xml"
],
"test74": [
"docker compose run --rm php74 ./vendor/bin/phpunit --configuration phpunit74.xml"
],
"test80": [
"docker compose run --rm php80 ./vendor/bin/phpunit --configuration phpunit80.xml"
],
"test81": [
"docker compose run --rm php81 ./vendor/bin/phpunit --configuration phpunit81.xml"
],
"test82": [
"docker compose run --rm php82 ./vendor/bin/phpunit --configuration phpunit82.xml"
],
"test83": [
"docker compose run --rm php83 ./vendor/bin/phpunit --configuration phpunit83.xml"
],
"test84": [
"docker compose run --rm php84 ./vendor/bin/phpunit --configuration phpunit84.xml"
]
},
"scripts-descriptions": {
Expand Down
21 changes: 21 additions & 0 deletions phpunit71.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true"
colors="true"
>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
21 changes: 21 additions & 0 deletions phpunit72.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true"
colors="true"
>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
13 changes: 13 additions & 0 deletions phpunit73.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" verbose="true" colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
13 changes: 13 additions & 0 deletions phpunit74.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" verbose="true" colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
13 changes: 13 additions & 0 deletions phpunit80.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" verbose="true" colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
13 changes: 13 additions & 0 deletions phpunit81.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
13 changes: 13 additions & 0 deletions phpunit82.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
13 changes: 13 additions & 0 deletions phpunit83.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
13 changes: 13 additions & 0 deletions phpunit84.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
6 changes: 3 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
set -e

php_versions=("php84" "php83" "php82" "php81" "php80" "php74" "php73" "php72" "php71")
php_versions=("84" "83" "82" "81" "80" "74" "73" "72" "71")

for version in "${php_versions[@]}"; do
docker compose run --rm "${version}composer" composer update --no-cache
docker compose run --rm php"${version}composer" composer update --no-cache

if ! docker compose run --rm "$version" vendor/bin/phpunit; then
if ! docker compose run --rm php"${version}" vendor/bin/phpunit --configuration phpunit"${version}".xml; then
exit 1
fi
done

0 comments on commit 5b27dc3

Please sign in to comment.