feat: alterando CI para GitHub Actions #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: tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| php: ['8.2', '8.3', '8.4'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up PHP ${{ matrix.php }} | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| coverage: xdebug | |
| tools: composer:v2, cs2pr | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| vendor | |
| ~/.composer/cache | |
| key: composer-${{ matrix.php }}-${{ hashFiles('composer.json') }} | |
| restore-keys: | | |
| composer-${{ matrix.php }}- | |
| - name: Install dependencies | |
| run: composer install --no-interaction --prefer-dist --no-progress | |
| - name: Run PHPCS (PSR-12) | |
| run: vendor/bin/phpcs --standard=PSR12 src | |
| - name: Run PHPUnit with coverage | |
| run: vendor/bin/phpunit | |
| - name: Upload Clover coverage artifact | |
| if: matrix.php == '8.2' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: clover-${{ matrix.php }} | |
| path: clover.xml | |
| - name: Add coverage summary to job output | |
| if: matrix.php == '8.2' | |
| run: | | |
| echo "### Code coverage artifact generated for PHP ${{ matrix.php }}" >> $GITHUB_STEP_SUMMARY | |
| - name: Upload coverage to Code Climate | |
| if: matrix.php == '8.2' && env.CC_TEST_REPORTER_ID != '' | |
| env: | |
| CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
| run: | | |
| curl -Ls https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | |
| chmod +x ./cc-test-reporter | |
| ./cc-test-reporter before-build | |
| ./cc-test-reporter after-build --coverage-input-type clover --exit-code $? |