update workflow #48
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: Test | |
| on: | |
| pull_request: | |
| branches: ["master"] | |
| paths-ignore: | |
| - "README.md" | |
| - ".gitignore" | |
| - "LICENSE.md" | |
| push: | |
| branches: ["master"] | |
| jobs: | |
| test: | |
| name: Test PHP ${{ matrix.php.version }} ${{ matrix.php.composer }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| php: | |
| - version: '8.1' | |
| composer: --prefer-lowest | |
| - version: '8.2' | |
| composer: --prefer-lowest | |
| - version: '8.3' | |
| composer: --prefer-lowest | |
| - version: '8.4' | |
| composer: --prefer-lowest | |
| - version: '8.1' | |
| composer: --prefer-stable | |
| - version: '8.2' | |
| composer: --prefer-stable | |
| - version: '8.3' | |
| composer: --prefer-stable | |
| - version: '8.4' | |
| composer: --prefer-stable | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # Fetch 10 commits or Scrutinizer will throw ("Failed to retrieve commit parents. | |
| # If you use a shallow git checkout, please checkout at least a depth of one."), | |
| # see: RepositoryIntrospector at scrutinizer-ci/ocular GitHub repository | |
| fetch-depth: 10 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php.version }} | |
| extensions: curl, mbstring, intl, libxml, simplexml | |
| coverage: xdebug | |
| - name: Get composer cache directory | |
| id: composer-cache-dir | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Composer packages | |
| id: composer-cache-restore | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.composer-cache-dir.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install dependencies | |
| run: (test -d vendor && echo vendor directory exists) || composer update --no-interaction --no-scripts --no-ansi ${{ matrix.php.composer }} | |
| - name: Run PHPUnit | |
| run: vendor/bin/phpunit --coverage-text --coverage-clover clover.xml | |
| - name: "[Coveralls] Extract branch name" | |
| if: matrix.php.version == '8.3' && matrix.php.composer == '--prefer-stable' | |
| shell: bash | |
| run: | | |
| if [ -n "${GITHUB_HEAD_REF}" ]; then | |
| echo "Branch from PR: ${GITHUB_HEAD_REF}" | |
| echo "branch=${GITHUB_HEAD_REF}" >> $GITHUB_OUTPUT | |
| else | |
| branch_name="${GITHUB_REF#refs/heads/}" | |
| echo "Branch from push: ${branch_name}" | |
| echo "branch=${branch_name}" >> $GITHUB_OUTPUT | |
| fi | |
| id: extract_branch | |
| - name: "[Coveralls] Checkout branch" | |
| if: matrix.php.version == '8.3' && matrix.php.composer == '--prefer-stable' | |
| shell: bash | |
| run: git fetch && git checkout ${{ steps.extract_branch.outputs.branch }} | |
| - name: "[Coveralls] Send report" | |
| if: matrix.php.version == '8.3' && matrix.php.composer == '--prefer-stable' | |
| run: ./vendor/bin/php-coveralls -v -x clover.xml -o coveralls-upload.json | |
| env: | |
| COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} |