|
| 1 | +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions |
| 2 | +# https://github.com/sebastianbergmann/phpunit/blob/main/.github/workflows/ci.yaml |
| 3 | + |
| 4 | +# https://github.com/actions/checkout |
| 5 | +# https://github.com/actions/upload-artifact |
| 6 | +# https://github.com/shivammathur/setup-php |
| 7 | +# https://github.com/ramsey/composer-install |
| 8 | +# https://github.com/codecov/codecov-action |
| 9 | +# https://github.com/codacy/codacy-coverage-reporter-action |
| 10 | +# https://github.com/JamesIves/github-pages-deploy-action |
| 11 | +# https://github.com/stefanzweifel/git-auto-commit-action |
| 12 | + |
| 13 | +on: |
| 14 | + push: |
| 15 | + branches: |
| 16 | + - main |
| 17 | + pull_request: |
| 18 | + branches: |
| 19 | + - main |
| 20 | + |
| 21 | +name: "Continuous Integration" |
| 22 | + |
| 23 | +env: |
| 24 | + PHP_EXTENSIONS: "" # caution: setting 'none' resets/disables shared extensions |
| 25 | + PHP_INI_VALUES: memory_limit=-1, error_reporting=-1, display_errors=On |
| 26 | + |
| 27 | +jobs: |
| 28 | + |
| 29 | + static-code-analysis: |
| 30 | + name: "Static Code Analysis" |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + strategy: |
| 34 | + fail-fast: true |
| 35 | + matrix: |
| 36 | + php-version: |
| 37 | + - "8.1" |
| 38 | + - "8.2" |
| 39 | + - "8.3" |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: "Checkout" |
| 43 | + uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: "Install PHP" |
| 46 | + uses: shivammathur/setup-php@v2 |
| 47 | + with: |
| 48 | + php-version: ${{ matrix.php-version }} |
| 49 | + extensions: ${{ env.PHP_EXTENSIONS }} |
| 50 | + ini-values: ${{ env.PHP_INI_VALUES }} |
| 51 | + coverage: none |
| 52 | + |
| 53 | + - name: "Validate composer.json" |
| 54 | + run: composer validate --ansi --strict |
| 55 | + |
| 56 | + - name: "Install dependencies with composer" |
| 57 | + uses: ramsey/composer-install@v3 |
| 58 | + |
| 59 | + - name: "Run PHPStan" |
| 60 | + run: php vendor/bin/phpstan |
| 61 | + |
| 62 | + |
| 63 | + tests: |
| 64 | + name: "Unit Tests" |
| 65 | + needs: static-code-analysis |
| 66 | + runs-on: ${{ matrix.os }} |
| 67 | + |
| 68 | + strategy: |
| 69 | + fail-fast: false |
| 70 | + matrix: |
| 71 | + os: |
| 72 | + - ubuntu-latest |
| 73 | + - windows-latest |
| 74 | + php-version: |
| 75 | + - "8.1" |
| 76 | + - "8.2" |
| 77 | + - "8.3" |
| 78 | + |
| 79 | + steps: |
| 80 | + - name: "Checkout" |
| 81 | + uses: actions/checkout@v4 |
| 82 | + |
| 83 | + - name: "Install PHP with extensions" |
| 84 | + uses: shivammathur/setup-php@v2 |
| 85 | + with: |
| 86 | + php-version: ${{ matrix.php-version }} |
| 87 | + extensions: ${{ env.PHP_EXTENSIONS }} |
| 88 | + ini-values: ${{ env.PHP_INI_VALUES }} |
| 89 | + coverage: pcov |
| 90 | + |
| 91 | + - name: "Install dependencies with composer" |
| 92 | + uses: ramsey/composer-install@v3 |
| 93 | + |
| 94 | + - name: "Run tests with phpunit" |
| 95 | + run: php vendor/bin/phpunit --colors=always --configuration=phpunit.xml.dist |
| 96 | + |
| 97 | +# - name: "Send code coverage report to Codecov.io" |
| 98 | +# uses: codecov/codecov-action@v4 |
| 99 | +# with: |
| 100 | +# token: ${{ secrets.CODECOV_TOKEN }} |
| 101 | +# files: .build/coverage/clover.xml |
| 102 | + |
| 103 | +# - name: "Send code coverage report to Codacy" |
| 104 | +# uses: codacy/codacy-coverage-reporter-action@v1 |
| 105 | +# with: |
| 106 | +# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} |
| 107 | +# coverage-reports: .build/coverage/clover.xml |
| 108 | + |
0 commit comments