|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +jobs: |
| 10 | + tests: |
| 11 | + name: Tests (PHP ${{ matrix.php }}) |
| 12 | + runs-on: ubuntu-24.04 |
| 13 | + |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + php: ['8.2', '8.3', '8.4', '8.5'] |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 |
| 22 | + |
| 23 | + - name: Setup PHP |
| 24 | + uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2 |
| 25 | + with: |
| 26 | + php-version: ${{ matrix.php }} |
| 27 | + extensions: json |
| 28 | + coverage: xdebug |
| 29 | + tools: composer:v2 |
| 30 | + |
| 31 | + - name: Get composer cache directory |
| 32 | + id: composer-cache |
| 33 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 34 | + |
| 35 | + - name: Cache dependencies |
| 36 | + uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5 |
| 37 | + with: |
| 38 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 39 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 40 | + restore-keys: ${{ runner.os }}-composer- |
| 41 | + |
| 42 | + - name: Install dependencies |
| 43 | + run: composer update -n --prefer-dist |
| 44 | + |
| 45 | + - name: Create build directory |
| 46 | + run: mkdir -p build/logs |
| 47 | + |
| 48 | + - name: Run tests |
| 49 | + run: vendor/bin/phpunit |
| 50 | + |
| 51 | + - name: Upload test results |
| 52 | + if: always() |
| 53 | + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5 |
| 54 | + with: |
| 55 | + name: test-results-php-${{ matrix.php }} |
| 56 | + path: build/logs/ |
| 57 | + retention-days: 7 |
| 58 | + |
| 59 | + code-style: |
| 60 | + name: Code Style |
| 61 | + runs-on: ubuntu-24.04 |
| 62 | + |
| 63 | + steps: |
| 64 | + - name: Checkout code |
| 65 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 |
| 66 | + |
| 67 | + - name: Setup PHP |
| 68 | + uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2 |
| 69 | + with: |
| 70 | + php-version: '8.2' |
| 71 | + tools: composer:v2 |
| 72 | + |
| 73 | + - name: Get composer cache directory |
| 74 | + id: composer-cache |
| 75 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 76 | + |
| 77 | + - name: Cache dependencies |
| 78 | + uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5 |
| 79 | + with: |
| 80 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 81 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 82 | + restore-keys: ${{ runner.os }}-composer- |
| 83 | + |
| 84 | + - name: Install dependencies |
| 85 | + run: composer update -n --prefer-dist |
| 86 | + |
| 87 | + - name: Run PHP CS Fixer |
| 88 | + run: vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no |
0 commit comments