diff options
| author | Zhineng Li <[email protected]> | 2026-01-05 17:33:01 +0800 |
|---|---|---|
| committer | Zhineng Li <[email protected]> | 2026-01-05 17:33:01 +0800 |
| commit | 83576e90a4cac04b30cc17df9031e0aff04e2065 (patch) | |
| tree | a6d2a0b5ec02f71f8123c416a792015e6b563bec | |
| parent | a49763dd739c3c68c4a8322896d594e926ac8e6b (diff) | |
| -rw-r--r-- | .gitattributes | 2 | ||||
| -rw-r--r-- | README.md | 10 | ||||
| -rw-r--r-- | composer.json | 10 | ||||
| -rw-r--r-- | docker-compose.yml | 43 | ||||
| -rw-r--r-- | scripts/test.sh | 28 |
5 files changed, 92 insertions, 1 deletions
diff --git a/.gitattributes b/.gitattributes index 805f87c..8644fa0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,8 @@ /.editorconfig export-ignore /.gitignore export-ignore /.php-cs-fixer.dist.php export-ignore +/docker-compose.yml export-ignore /phpstan.neon.dist export-ignore /phpunit.xml.dist export-ignore +/scripts export-ignore /tests export-ignore @@ -100,8 +100,16 @@ echo $structure->size(); // 63 ## Testing +Run the test suite locally: + +```bash +composer test +``` + +Test across all PHP versions and dependency modes: + ```bash -composer run test +composer matrix ``` ## License diff --git a/composer.json b/composer.json index 1776b5f..71deaf1 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,16 @@ "@format", "@lint", "@test" + ], + "matrix": [ + "COMPOSER_FLAGS=--prefer-lowest docker compose run --rm php82", + "COMPOSER_FLAGS=--prefer-stable docker compose run --rm php82", + "COMPOSER_FLAGS=--prefer-lowest docker compose run --rm php83", + "COMPOSER_FLAGS=--prefer-stable docker compose run --rm php83", + "COMPOSER_FLAGS=--prefer-lowest docker compose run --rm php84", + "COMPOSER_FLAGS=--prefer-stable docker compose run --rm php84", + "COMPOSER_FLAGS=--prefer-lowest docker compose run --rm php85", + "COMPOSER_FLAGS=--prefer-stable docker compose run --rm php85" ] }, "config": { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f45b2a3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,43 @@ +services: + php82: + image: php:8.2-cli-alpine + environment: + - COMPOSER_FLAGS=${COMPOSER_FLAGS:-} + volumes: + - .:/app:ro + - composer-cache:/root/.composer + working_dir: /app + command: sh scripts/test.sh + + php83: + image: php:8.3-cli-alpine + environment: + - COMPOSER_FLAGS=${COMPOSER_FLAGS:-} + volumes: + - .:/app:ro + - composer-cache:/root/.composer + working_dir: /app + command: sh scripts/test.sh + + php84: + image: php:8.4-cli-alpine + environment: + - COMPOSER_FLAGS=${COMPOSER_FLAGS:-} + volumes: + - .:/app:ro + - composer-cache:/root/.composer + working_dir: /app + command: sh scripts/test.sh + + php85: + image: php:8.5-cli-alpine + environment: + - COMPOSER_FLAGS=${COMPOSER_FLAGS:-} + volumes: + - .:/app:ro + - composer-cache:/root/.composer + working_dir: /app + command: sh scripts/test.sh + +volumes: + composer-cache: diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100644 index 0000000..70554be --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,28 @@ +#!/bin/sh +set -e + +COMPOSER_PHAR="/root/.composer/composer.phar" +WORKDIR="/tmp/app" + +# Copy project to isolated working directory +rm -rf "$WORKDIR" +cp -r /app "$WORKDIR" +cd "$WORKDIR" + +# Remove lock file and vendor for fresh install +rm -f composer.lock +rm -rf vendor/ + +# Download Composer if not cached +if [ ! -f "$COMPOSER_PHAR" ]; then + echo "Downloading Composer..." + mkdir -p /root/.composer + curl -sS https://getcomposer.org/installer | php -- --install-dir=/root/.composer --filename=composer.phar +fi + +# Install dependencies +echo "COMPOSER_FLAGS: ${COMPOSER_FLAGS:-<empty>}" +php "$COMPOSER_PHAR" update --no-interaction ${COMPOSER_FLAGS:-} + +# Run tests +php "$COMPOSER_PHAR" test |
