Merge 'validate-code-static' and 'run-tests' jobs into single matrix #5
Workflow file for this run
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] | |
| jobs: | |
| validate-code-style: | |
| name: PSR-12 Code style | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Validate composer.json and composer.lock | |
| run: composer validate | |
| - name: Get Composer Cache Directory | |
| id: composer-cache | |
| run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
| - name: Cache composer dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install PHP_CodeSniffer composer package | |
| run: composer global require "squizlabs/php_codesniffer=*" | |
| - name: Validate PSR-12 Code Style | |
| run: ~/.composer/vendor/bin/phpcs | |
| validate-and-test: | |
| name: Static Analysis & Tests with PHP ${{ matrix.php-versions }} | |
| runs-on: ubuntu-latest | |
| env: | |
| extensions: mbstring, intl, json, phalcon, redis, mongodb, xdebug | |
| key: cache-v0.0.2 | |
| services: | |
| mongodb: | |
| image: mongo:3.6 | |
| ports: | |
| - 27017:27017 | |
| needs: validate-code-style | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php-versions: ['8.1', '8.2', '8.3', '8.4'] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Setup cache environment | |
| id: cache-env | |
| uses: shivammathur/cache-extensions@v1 | |
| with: | |
| php-version: ${{ matrix.php-versions }} | |
| extensions: ${{ env.extensions }} | |
| key: ${{ env.key }} | |
| - name: Cache extensions | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ steps.cache-env.outputs.dir }} | |
| key: ${{ steps.cache-env.outputs.key }} | |
| restore-keys: ${{ steps.cache-env.outputs.key }} | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| coverage: xdebug | |
| php-version: ${{ matrix.php-versions }} | |
| extensions: ${{ env.extensions }} | |
| tools: pecl | |
| - name: Get Composer Cache Directory | |
| id: composer-cache | |
| run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
| - name: Cache composer dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install Composer dependencies | |
| run: composer install --prefer-dist --no-suggest | |
| - name: Run Psalm | |
| if: always() | |
| run: vendor/bin/psalm | |
| - name: Run PHPStan | |
| if: always() | |
| run: vendor/bin/phpstan analyse src | |
| - name: Run test suites | |
| if: success() | |
| run: vendor/bin/phpunit --coverage-clover=coverage-${{ matrix.php-versions }}.xml | |
| - name: Upload coverage to Codecov | |
| if: success() | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| token: ${{secrets.CODECOV_TOKEN}} | |
| file: ./coverage-*.xml |