Merge pull request #31 from happyprime/task/update-php-versions #4
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: PHPStan | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| php-version: | ||
| type: string | ||
| description: 'PHP version to use' | ||
| required: true | ||
| default: '8.3' | ||
| working-directory: | ||
| type: string | ||
| description: 'Working directory for the PHP project' | ||
| required: false | ||
| default: '.' | ||
| secrets: | ||
| composer-auth-token: | ||
| description: 'GitHub token for private Composer dependencies' | ||
| required: false | ||
| # The GITHUB_TOKEN used by Dependabot has read-only permissions | ||
| # by default, so we provide write permissions to this workflow | ||
| # so that comments can be left on the pull request. | ||
| # https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#changing-github_token-permissions | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| jobs: | ||
| phpstan: | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: ${{ inputs.working-directory }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ inputs.php-version }} | ||
| coverage: none | ||
| tools: composer | ||
| - name: Cache Composer | ||
| id: cache-composer | ||
| run: | | ||
| echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
| - uses: actions/cache@v5 | ||
| with: | ||
| path: ${{ steps.cache-composer.outputs.dir }} | ||
| key: ${{ runner.os }}-composer-${{ hashFiles(format('{0}/composer.lock', inputs.working-directory)) }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-composer- | ||
| - name: Install dependencies | ||
| env: | ||
| COMPOSER_AUTH: ${{ secrets.composer-auth-token && format('{{"github-oauth":{{"github.com":"{0}"}}}}', secrets.composer-auth-token) || '' }} | ||
| run: | | ||
| composer install --prefer-dist --no-progress | ||
| - name: Detect coding standard violations | ||
| run: vendor/bin/phpstan analyse | ||