Repository navigation
PHPStan: Update to 2.3.6 and phpstan-phpunit to 2.1.2 #142272
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
| name: Enforce labels on Pull Request | |
| on: | |
| pull_request_target: | |
| types: | |
| [ | |
| opened, | |
| reopened, | |
| labeled, | |
| unlabeled, | |
| ready_for_review, | |
| review_requested, | |
| ] | |
| # Disable permissions for all available scopes by default. | |
| # Any needed permissions should be configured at the job level. | |
| permissions: {} | |
| jobs: | |
| type-related-labels: | |
| name: Check the type label | |
| runs-on: 'ubuntu-slim' | |
| if: ${{ github.event.pull_request.state == 'open' }} | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| timeout-minutes: 5 | |
| # Shared with every other writer of this comment. See bundle-size.yml. | |
| concurrency: | |
| group: pr-meta-${{ github.event.number }} | |
| cancel-in-progress: false | |
| queue: max | |
| steps: | |
| # A `pull_request_target` job has a writable token, so it checks out | |
| # the base branch it was triggered on, never the pull request's head. | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| sparse-checkout: tools/pr-meta | |
| show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} | |
| persist-credentials: false | |
| - name: Check for a type label | |
| id: check | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PR_NUMBER: ${{ github.event.number }} | |
| REPO: ${{ github.repository }} | |
| run: | | |
| mkdir -p pr-meta | |
| # Read the labels now rather than from the event payload. Runs | |
| # queue behind each other on the shared lock, so an older one | |
| # can arrive after a newer one already fixed the labels. | |
| type_labels="$(gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" \ | |
| --jq '[ .[].name | select( startswith( "[Type]" ) ) ]')" | |
| count="$(printf '%s' "$type_labels" | jq 'length')" | |
| if [ "$count" -eq 1 ]; then | |
| echo "ok=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "ok=false" >> "$GITHUB_OUTPUT" | |
| applied="$(printf '%s' "$type_labels" | jq -r 'if length == 0 then "none" else join( ", " ) end')" | |
| cat > pr-meta/body.md <<EOF | |
| This pull request needs exactly one label indicating its type, and has ${count}. | |
| - Required: any label starting with \`[Type]\`. | |
| - Found: ${applied}. | |
| Read more about [Type labels in Gutenberg](https://github.com/WordPress/gutenberg/labels?q=type). If you cannot add labels yourself, a reviewer can do it for you. | |
| EOF | |
| # Runs whatever the check found, since an empty section is what | |
| # clears the warning once the labels are right. Not when the check | |
| # itself failed: no body file then means "labels are fine", and a | |
| # failed API call would erase a warning nothing had disproved. | |
| - name: Report the result | |
| if: ${{ !cancelled() && steps.check.outcome == 'success' }} | |
| uses: ./tools/pr-meta | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| section: labels | |
| body-path: pr-meta/body.md | |
| # Opening or reopening only reports the warning above, since a | |
| # pull request needs time to be labelled. These are the events the | |
| # workflow enforced on before it also ran on opened and reopened. | |
| - name: Require exactly one type label | |
| if: ${{ steps.check.outputs.ok != 'true' && contains( fromJSON( '["labeled", "unlabeled", "ready_for_review", "review_requested"]' ), github.event.action ) }} | |
| run: exit 1 |