From 157012a45b14a8be18970547a8f951cb761998e8 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Tue, 11 Aug 2026 20:13:21 +0000 Subject: [PATCH] Build/Test Tools: Skip `pull_request` triggered runs in private repos. This modifies the conditions for GitHub Actions workflow runs so that they do not run within private forks and mirrors for `pull_request` events when the PR is in `draft` status. For situations where this may be desirable, a `Draft Workflow Runs` label can be added to a `draft` pull request to force workflows to run. Props desrosj, jorbin. See #65848. git-svn-id: https://develop.svn.wordpress.org/trunk@63183 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/coding-standards.yml | 18 +++++- .github/workflows/end-to-end-tests.yml | 9 ++- .github/workflows/javascript-tests.yml | 9 ++- .../workflows/javascript-type-checking.yml | 9 ++- .github/workflows/performance.yml | 12 +++- .github/workflows/php-compatibility.yml | 9 ++- .github/workflows/phpstan-static-analysis.yml | 9 ++- .github/workflows/phpunit-tests.yml | 61 +++++++++++++++++-- .github/workflows/test-build-processes.yml | 9 ++- .github/workflows/upgrade-develop-testing.yml | 20 +++++- .github/workflows/workflow-lint.yml | 9 ++- 11 files changed, 156 insertions(+), 18 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 56a5961acd741..dda9f22aaae10 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -50,7 +50,14 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/reusable-coding-standards-php.yml@trunk permissions: contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + if: | + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) # Runs the JavaScript coding standards checks. jshint: @@ -58,7 +65,14 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/reusable-coding-standards-javascript.yml@trunk permissions: contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + if: | + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) slack-notifications: name: Slack Notifications diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index ca7bed7591e1f..eb3dac37b78ad 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -57,7 +57,14 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/reusable-end-to-end-tests.yml@trunk permissions: contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + if: | + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) strategy: fail-fast: false matrix: diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index a06a37afb3321..51099b97d2a74 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -53,7 +53,14 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/reusable-javascript-tests.yml@trunk permissions: contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + if: | + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) slack-notifications: name: Slack Notifications diff --git a/.github/workflows/javascript-type-checking.yml b/.github/workflows/javascript-type-checking.yml index 01422a6d7d7ac..d27b6e191c28d 100644 --- a/.github/workflows/javascript-type-checking.yml +++ b/.github/workflows/javascript-type-checking.yml @@ -46,7 +46,14 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/reusable-javascript-type-checking-v1.yml@trunk permissions: contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + if: | + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) slack-notifications: name: Slack Notifications diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index dc83e2a9d297b..44d7f1e6df16a 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -51,7 +51,17 @@ jobs: determine-matrix: name: Determine Matrix runs-on: ubuntu-24.04 - if: ${{ ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) && ! contains( github.event.before, '00000000' ) }} + if: | + ( + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) + ) && + ! contains( github.event.before, '00000000' ) permissions: actions: read env: diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index 26fd352258b86..7c9d2bae79074 100644 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -42,7 +42,14 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/reusable-php-compatibility.yml@trunk permissions: contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + if: | + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) slack-notifications: name: Slack Notifications diff --git a/.github/workflows/phpstan-static-analysis.yml b/.github/workflows/phpstan-static-analysis.yml index a9e2c787725e2..892c8e566edd4 100644 --- a/.github/workflows/phpstan-static-analysis.yml +++ b/.github/workflows/phpstan-static-analysis.yml @@ -42,7 +42,14 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/reusable-phpstan-static-analysis-v1.yml@trunk permissions: contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + if: | + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) slack-notifications: name: Slack Notifications diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 63a5442132bdc..2830355214fd4 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -57,7 +57,14 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/reusable-prepare-gutenberg.yml@trunk permissions: contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + if: | + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) # # Creates a PHPUnit test job for each PHP/MySQL combination. @@ -73,7 +80,16 @@ jobs: permissions: contents: read secrets: inherit - if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) }} + if: | + startsWith( github.repository, 'WordPress/' ) && ( + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) + ) strategy: fail-fast: false matrix: @@ -154,7 +170,16 @@ jobs: permissions: contents: read secrets: inherit - if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) }} + if: | + startsWith( github.repository, 'WordPress/' ) && ( + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) + ) strategy: fail-fast: false matrix: @@ -210,7 +235,16 @@ jobs: permissions: contents: read secrets: inherit - if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) }} + if: | + startsWith( github.repository, 'WordPress/' ) && ( + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) + ) strategy: fail-fast: false matrix: @@ -257,7 +291,16 @@ jobs: permissions: contents: read secrets: inherit - if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) }} + if: | + startsWith( github.repository, 'WordPress/' ) && ( + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) + ) strategy: fail-fast: false matrix: @@ -289,7 +332,13 @@ jobs: permissions: contents: read secrets: inherit - if: ${{ ! startsWith( github.repository, 'WordPress/' ) && github.event_name == 'pull_request' }} + if: | + ! startsWith( github.repository, 'WordPress/' ) && + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) strategy: fail-fast: false matrix: diff --git a/.github/workflows/test-build-processes.yml b/.github/workflows/test-build-processes.yml index ef67633d2ff03..2b9b3e0b3c17c 100644 --- a/.github/workflows/test-build-processes.yml +++ b/.github/workflows/test-build-processes.yml @@ -51,7 +51,14 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/reusable-test-core-build-process.yml@trunk permissions: contents: read - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + if: | + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) strategy: fail-fast: false matrix: diff --git a/.github/workflows/upgrade-develop-testing.yml b/.github/workflows/upgrade-develop-testing.yml index e09c1049f3674..d6ddf5fae4bc0 100644 --- a/.github/workflows/upgrade-develop-testing.yml +++ b/.github/workflows/upgrade-develop-testing.yml @@ -44,7 +44,16 @@ jobs: build: name: Build uses: WordPress/wordpress-develop/.github/workflows/reusable-build-package.yml@trunk - if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) }} + if: | + startsWith( github.repository, 'WordPress/' ) && ( + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) + ) permissions: contents: read @@ -87,7 +96,14 @@ jobs: upgrade-tests-develop-forks: name: Upgrade from ${{ matrix.wp }} uses: WordPress/wordpress-develop/.github/workflows/reusable-upgrade-testing.yml@trunk - if: ${{ github.repository != 'WordPress/wordpress-develop' }} + # This job also runs for the push event, which has no draft state to check. + if: | + github.repository != 'WordPress/wordpress-develop' && ( + github.event_name != 'pull_request' || + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) needs: [ build ] permissions: contents: read diff --git a/.github/workflows/workflow-lint.yml b/.github/workflows/workflow-lint.yml index 774d621151408..dd36bfcc43187 100644 --- a/.github/workflows/workflow-lint.yml +++ b/.github/workflows/workflow-lint.yml @@ -33,7 +33,14 @@ jobs: lint: name: Lint GitHub Action files uses: WordPress/wordpress-develop/.github/workflows/reusable-workflow-lint.yml@trunk - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + if: | + github.repository == 'WordPress/wordpress-develop' || ( + github.event_name == 'pull_request' && ( + ! github.event.repository.private || + ! github.event.pull_request.draft || + contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) + ) + ) permissions: security-events: write actions: read