Add a test suite, coding standards and CI #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| name: PHP ${{ matrix.php }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: [ '8.3', '8.4', '8.5' ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: mbstring | |
| coverage: none | |
| tools: composer:v2 | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-progress --no-interaction | |
| - name: Lint | |
| run: find src tests -name '*.php' -print0 | xargs -0 -n1 -P4 php -l > /dev/null | |
| - name: Coding standards | |
| run: composer lint | |
| - name: Formatting | |
| # Separate from the lint: a clean lint does not mean a clean format | |
| # check, and a green build has to mean both. | |
| run: composer format:check | |
| - name: Tests | |
| # set -o pipefail, because a pipeline reports its last command and tee | |
| # always succeeds -- without it a failing suite exits 0 and reads green. | |
| run: | | |
| set -o pipefail | |
| composer test | tee phpunit.log | |
| grep -qE 'OK \(|Tests: ' phpunit.log || { | |
| echo '::error::phpunit produced no result -- the suite did not run' | |
| exit 1 | |
| } |