diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..e36386b --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,65 @@ +name: Continuous Integration + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: + - '5.6' + - '7.0' + - '7.1' + - '7.2' + - '7.3' + - '7.4' + - '8.0' + - '8.1' + - '8.2' + - '8.3' + - '8.4' + - '8.5' + + name: PHP ${{ matrix.php-version }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: + coverage: none + # Composer 2.3+ needs PHP 7.2.5; the 2.2 LTS line still runs on 5.6. + tools: ${{ contains(fromJSON('["5.6","7.0","7.1"]'), matrix.php-version) && 'composer:v2.2' || 'composer:v2' }} + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-php${{ matrix.php-version }}-composer- + + # update, not install: no lock file is committed, so each PHP version + # resolves the PHPUnit and polyfill versions that support it. + - name: Install dependencies + run: composer update --no-interaction --prefer-dist + + - name: Validate composer.json + run: composer validate --no-check-lock --no-check-publish + + - name: Run test suite + run: ./vendor/bin/phpunit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..68f9559 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +# Releasing this package: Actions -> Release -> Run workflow, pick the branch +# (2.x) and type the version. Or from a terminal: +# +# gh workflow run release.yml --ref 2.x -f version=2.0.5 +# +# The shared workflow creates the tag itself, and only after every check has +# passed. Do not tag by hand -- Packagist derives versions from tags, so a tag +# is a published version the moment it exists. +# +# Release notes come from this package's own CHANGES.md. The version you type +# must match the version at the top of the change log -- or, for a pre-release +# such as 2.0.5-alpha1, its base version, so that alphas and betas do not each +# need a change log section of their own. + +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to release, e.g. 2.0.5' + required: true + type: string + +jobs: + release: + uses: auraphp/bin/.github/workflows/release.yml@v1.0.0 + permissions: + contents: write + with: + version: ${{ inputs.version }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8d1cf20 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/composer.lock +/vendor +/phpunit.xml +/.phpunit.result.cache diff --git a/CHANGES.md b/CHANGES.md index 0ef9efa..5bb09f3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1 +1,34 @@ +# CHANGELOG + +## 2.0.5 + +Maintenance release: the package now has continuous integration, and a +release workflow, for the first time. + +- The test suite was written against the PHPUnit 4/5 API + (`PHPUnit_Framework_TestCase`, `setExpectedException()`), which PHPUnit 6 + removed, so it could not run on any supported PHP at all. It now runs on + PHP 5.6 through 8.5: 11 tests, 17 assertions. +- ADD: `phpunit/phpunit` and `yoast/phpunit-polyfills` to `require-dev`. + The package had no test runner declared at all, so `composer install` + produced nothing to run the tests with. +- ADD: a Continuous Integration workflow, and a Release workflow calling the + shared `auraphp/bin` workflow. +- FIX: the `nds()` test helper stringified the nested base-dir arrays from + `getPrefixes()` to `'Array'` instead of recursing into them, so + `testAddPrefix` could never pass. The library itself was correct. +- The suite runs on **PHP 5.6 through 8.5**, via + [`yoast/phpunit-polyfills`][polyfills], which lets one set of tests run on + PHPUnit 5.7 through 11. Tests use `set_up()` rather than `setUp(): void`, + because the `void` return type is a parse error before PHP 7.1. +- `phpunit.xml.dist` is deliberately minimal, so that a single config file is + valid for every PHPUnit version in that range. + +[polyfills]: https://github.com/Yoast/PHPUnit-Polyfills + +No library code changed. `require.php` is unchanged, so nothing changes for +consumers of this package. + +## 2.0.4 + Hygiene release: update the license year, and remove a branch alias. diff --git a/composer.json b/composer.json index 0a7891b..945b95d 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,10 @@ "Aura\\Autoload\\": "src/" } }, + "require-dev": { + "phpunit/phpunit": "^5.7.21 || ^6.4.4 || ^7.5 || ^8.5 || ^9.6 || ^11.0", + "yoast/phpunit-polyfills": "^2.0.5 || ^3.1.2 || ^4.0.0" + }, "extra": { "aura": { "type": "library" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 761e67c..9083bfb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,8 @@ - + + - + ./tests diff --git a/tests/LoaderTest.php b/tests/LoaderTest.php index ec9cd22..9b4d937 100644 --- a/tests/LoaderTest.php +++ b/tests/LoaderTest.php @@ -1,13 +1,13 @@ loader = new Loader; } @@ -195,9 +195,16 @@ public function testPsr0Loading() $this->assertSame($expect, $actual); } - // normalize directory separators in file names for windows compatibilitys + // normalize directory separators in file names for windows compatibility. + // recurses, because getPrefixes() returns base dirs nested one level under + // each prefix -- str_replace() on a nested array stringifies the inner + // arrays to 'Array' instead of descending into them. protected function nds($file) { + if (is_array($file)) { + return array_map(array($this, 'nds'), $file); + } + return str_replace('/', DIRECTORY_SEPARATOR, $file); } }