|
| 1 | +name: PHPStan Static Analysis |
| 2 | + |
| 3 | +on: |
| 4 | + # PHPStan testing was introduced in @todo. |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - trunk |
| 8 | + - '6.9' |
| 9 | + - '[7-9].[0-9]' |
| 10 | + tags: |
| 11 | + - '6.9' |
| 12 | + - '6.9.[0-9]+' |
| 13 | + - '[7-9].[0-9]' |
| 14 | + - '[7-9]+.[0-9].[0-9]+' |
| 15 | + pull_request: |
| 16 | + branches: |
| 17 | + - trunk |
| 18 | + - '6.9' |
| 19 | + - '[7-9].[0-9]' |
| 20 | + paths: |
| 21 | + # This workflow only scans PHP files. |
| 22 | + - '**.php' |
| 23 | + # These files configure Composer. Changes could affect the outcome. |
| 24 | + - 'composer.*' |
| 25 | + # These files configure PHPStan. Changes could affect the outcome. |
| 26 | + - 'phpstan.neon.dist' |
| 27 | + - 'tests/phpstan/base.neon' |
| 28 | + # Confirm any changes to relevant workflow files. |
| 29 | + - '.github/workflows/php-static-analysis.yml' |
| 30 | + - '.github/workflows/reusable-php-static-analysis.yml' |
| 31 | + workflow_dispatch: |
| 32 | + |
| 33 | +# Cancels all previous workflow runs for pull requests that have not completed. |
| 34 | +concurrency: |
| 35 | + # The concurrency group contains the workflow name and the branch name for pull requests |
| 36 | + # or the commit hash for any other events. |
| 37 | + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} |
| 38 | + cancel-in-progress: true |
| 39 | + |
| 40 | +# Disable permissions for all available scopes by default. |
| 41 | +# Any needed permissions should be configured at the job level. |
| 42 | +permissions: {} |
| 43 | + |
| 44 | +jobs: |
| 45 | + # Runs PHPStan Static Analysis. |
| 46 | + phpstan: |
| 47 | + name: PHP coding standards |
| 48 | + uses: ./.github/workflows/reusable-php-static-analysis.yml |
| 49 | + permissions: |
| 50 | + contents: read |
| 51 | + if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }} |
| 52 | + |
| 53 | + slack-notifications: |
| 54 | + name: Slack Notifications |
| 55 | + uses: ./.github/workflows/slack-notifications.yml |
| 56 | + permissions: |
| 57 | + actions: read |
| 58 | + contents: read |
| 59 | + needs: [ phpstan ] |
| 60 | + if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} |
| 61 | + with: |
| 62 | + calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }} |
| 63 | + secrets: |
| 64 | + SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} |
| 65 | + SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} |
| 66 | + SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} |
| 67 | + SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} |
| 68 | + |
| 69 | + failed-workflow: |
| 70 | + name: Failed workflow tasks |
| 71 | + runs-on: ubuntu-24.04 |
| 72 | + permissions: |
| 73 | + actions: write |
| 74 | + needs: [ slack-notifications ] |
| 75 | + if: | |
| 76 | + always() && |
| 77 | + github.repository == 'WordPress/wordpress-develop' && |
| 78 | + github.event_name != 'pull_request' && |
| 79 | + github.run_attempt < 2 && |
| 80 | + ( |
| 81 | + contains( needs.*.result, 'cancelled' ) || |
| 82 | + contains( needs.*.result, 'failure' ) |
| 83 | + ) |
| 84 | +
|
| 85 | + steps: |
| 86 | + - name: Dispatch workflow run |
| 87 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 88 | + with: |
| 89 | + retries: 2 |
| 90 | + retry-exempt-status-codes: 418 |
| 91 | + script: | |
| 92 | + github.rest.actions.createWorkflowDispatch({ |
| 93 | + owner: context.repo.owner, |
| 94 | + repo: context.repo.repo, |
| 95 | + workflow_id: 'failed-workflow.yml', |
| 96 | + ref: 'trunk', |
| 97 | + inputs: { |
| 98 | + run_id: `${context.runId}`, |
| 99 | + } |
| 100 | + }); |
0 commit comments