ci: upload coverage to Codecov #22
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
| # CI for php-sdk. | |
| # | |
| # Action pinning policy: | |
| # - First-party actions (actions/*) are pinned to a major tag (e.g. @v4). | |
| # - Third-party actions are pinned to a full commit SHA, with the released | |
| # version recorded in a trailing comment for human review. | |
| name: test | |
| on: | |
| push: | |
| branches: [main] | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| - 'LICENSE' | |
| - '.gitignore' | |
| - '.editorconfig' | |
| pull_request: | |
| branches: [main] | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| - 'LICENSE' | |
| - '.gitignore' | |
| - '.editorconfig' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| name: PHP ${{ matrix.php }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ['8.4'] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 1 | |
| - name: Setup PHP ${{ matrix.php }} | |
| uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: pdo, pdo_sqlite, mbstring, json | |
| coverage: pcov | |
| tools: composer:v2 | |
| - name: Get composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" | |
| - name: Cache composer dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock', '**/composer.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-php-${{ matrix.php }}-composer- | |
| - name: Install dependencies | |
| run: composer install --no-progress --no-interaction --prefer-dist | |
| - name: Lint (php-cs-fixer dry-run) | |
| if: hashFiles('.php-cs-fixer.dist.php', '.php-cs-fixer.php') != '' | |
| run: vendor/bin/php-cs-fixer fix --dry-run --diff | |
| - name: Run PHPUnit (with Clover coverage) | |
| run: vendor/bin/phpunit --coverage-clover=coverage.xml | |
| # Non-blocking: a Codecov outage cannot break CI. | |
| - name: Upload coverage to Codecov | |
| # codecov/codecov-action v6.0.1 | |
| uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1 | |
| with: | |
| fail_ci_if_error: false | |
| flags: unittests | |
| files: ./coverage.xml | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload test artifacts on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: test-artifacts-php-${{ matrix.php }} | |
| path: | | |
| .phpunit.cache/ | |
| build/ | |
| coverage.xml | |
| if-no-files-found: ignore | |
| retention-days: 7 |