|
| 1 | +--- |
| 2 | +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json |
1 | 3 | name: PHPUnit
|
2 | 4 |
|
3 |
| -on: [push] |
| 5 | +on: [ push ] |
4 | 6 |
|
5 | 7 | jobs:
|
6 | 8 | build-test:
|
7 | 9 | runs-on: ubuntu-latest
|
8 | 10 |
|
| 11 | + permissions: |
| 12 | + contents: write |
| 13 | + statuses: write |
| 14 | + |
| 15 | + outputs: |
| 16 | + lock: ${{ steps.hash.outputs.lock }} |
| 17 | + cache: ${{ steps.composer-cache.outputs.cache }} |
| 18 | + |
| 19 | + strategy: |
| 20 | + fail-fast: true |
| 21 | + matrix: |
| 22 | + php-versions: [ '8.0', '8.1', '8.2', '8.3' ] |
| 23 | + stability: [ 'stable', 'lowest' ] |
| 24 | + |
9 | 25 | steps:
|
10 | 26 | - uses: actions/checkout@v2
|
11 | 27 |
|
12 |
| - - uses: php-actions/composer@v5 |
| 28 | + - name: Setup PHP |
| 29 | + uses: shivammathur/setup-php@v2 |
| 30 | + with: |
| 31 | + php-version: ${{ matrix.php }} |
| 32 | + tools: composer |
| 33 | + extensions: json, dom, curl, libxml, mbstring |
| 34 | + coverage: xdebug |
| 35 | + env: |
| 36 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Get composer cache directory |
| 39 | + id: composer-cache |
| 40 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
13 | 41 |
|
14 |
| - - name: PHPUnit Tests |
15 |
| - uses: php-actions/phpunit@v2 |
| 42 | + - name: Get composer.lock or composer.json hash for caching |
| 43 | + id: hash |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + if [ -f composer.lock ]; then |
| 47 | + echo "lock=${{ hashFiles('**/composer.lock') }}" >> $GITHUB_OUTPUT |
| 48 | + else |
| 49 | + echo "lock=${{ hashFiles('**/composer.json') }}" >> $GITHUB_OUTPUT |
| 50 | + fi |
| 51 | +
|
| 52 | + - name: Cache Composer packages |
| 53 | + id: composer-cache |
| 54 | + uses: actions/cache@v4 |
16 | 55 | with:
|
17 |
| - php_extensions: xdebug mbstring |
18 |
| - bootstrap: vendor/autoload.php |
19 |
| - configuration: phpunit.xml |
20 |
| - args: --coverage-text |
| 56 | + path: ${{ outputs.cache }} |
| 57 | + key: ${{ runner.os }}-php-${{ matrix.php }}-${{ outputs.lock }} |
| 58 | + restore-keys: | |
| 59 | + ${{ runner.os }}-php-${{ matrix.php }}-${{ outputs.lock }} |
| 60 | + ${{ runner.os }}-php-${{ matrix.php }}- |
| 61 | + ${{ runner.os }}-php- |
| 62 | +
|
| 63 | + - name: Install Dependencies (prefer-${{ matrix.stability }}) |
| 64 | + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-${{ matrix.stability }} |
| 65 | + |
| 66 | + - name: Configure matchers |
| 67 | + uses: mheap/phpunit-matcher-action@v1 |
| 68 | + |
| 69 | + - name: Execute composer test (Unit and Feature tests) |
| 70 | + run: composer test:ci |
0 commit comments