Make WordPress Core


Ignore:
Timestamp:
08/01/2025 12:42:18 PM (7 months ago)
Author:
desrosj
Message:

Build/Test Tools: Spawn fewer jobs in GitHub Actions on forks.

The GitHub Actions workflows currently limit when jobs run for forks by short-circuiting any that are triggered by push events when not running within the wordpress-develop repository.

Because the large majority of forks are not created under organizations, they will be subject to the individual account limit of 20 concurrent jobs (40 for pro accounts) at any given time instead of the 500 concurrent job limit that applies to the WordPress organization. This means that a single pull request back to a fork can take several hours to complete the workflow jobs that are spawned.

This revises the conditional statements to further limit the number of jobs that spawn within a fork while still allowing the full test matrices for forks within the WordPress organization and pull requests back to wordpress-develop.

These adjustments result in a maximum of 53 jobs when all workflows configured to run within forks are triggered. Of these, ~66% will run in less than 3 minutes, and ~55% will run in less than 1 minute.

Props jorbin, johnbillion.
Fixes #63752.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/phpunit-tests.yml

    r60532 r60534  
    6464      contents: read
    6565    secrets: inherit
    66     if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
     66    if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) ) }}
    6767    strategy:
    6868      fail-fast: false
     
    141141      contents: read
    142142    secrets: inherit
    143     if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
     143    if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) ) }}
    144144    strategy:
    145145      fail-fast: false
     
    193193      contents: read
    194194    secrets: inherit
    195     if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
     195    if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) ) }}
    196196    strategy:
    197197      fail-fast: false
     
    233233      contents: read
    234234    secrets: inherit
    235     if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
     235    if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) ) }}
    236236    strategy:
    237237      fail-fast: false
     
    247247      phpunit-test-groups: ${{ matrix.phpunit-test-groups }}
    248248
     249  #
     250  # Runs unit tests for forks.
     251  #
     252  # Because the majority of forks will belong to personal GitHub accounts (which are limited to just 20 concurrent jobs
     253  # at any given time), forks only run a small subset of test combinations. This allows contributors to open pull
     254  # requests back to their own forks for testing purposes without having to wait hours for workflow to complete.
     255  #
     256  limited-matrix-for-forks:
     257    name: PHP ${{ matrix.php }}
     258    uses: ./.github/workflows/reusable-phpunit-tests-v3.yml
     259    permissions:
     260      contents: read
     261    secrets: inherit
     262    if: ${{ ! startsWith( github.repository, 'WordPress/' ) && github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
     263    strategy:
     264      fail-fast: false
     265      matrix:
     266        php: [ '7.2', '8.4' ]
     267        db-version: [ '8.4', '11.8' ]
     268        db-type: [ 'mysql', 'mariadb' ]
     269        multisite: [ false ]
     270
     271        include:
     272          # Include one multisite job for each database type.
     273          - php: '8.4'
     274            db-version: '8.4'
     275            db-type: 'mysql'
     276            multisite: true
     277          - php: '8.4'
     278            db-version: '11.8'
     279            db-type: 'mariadb'
     280            multisite: true
     281          # Test with memcached.
     282          - php: '8.4'
     283            db-version: '8.4'
     284            db-type: 'mysql'
     285            multisite: true
     286            memcached: true
     287          # Run specific test groups once.
     288          - php: '8.4'
     289            db-version: '8.4'
     290            db-type: 'mysql'
     291            phpunit-test-groups: 'html-api-html5lib-tests'
     292
     293        exclude:
     294          # Exclude PHP versions that are not supported by the database versions.
     295          - db-type: 'mysql'
     296            db-version: '11.8'
     297          - db-type: 'mariadb'
     298            db-version: '8.4'
     299
     300    with:
     301      php: ${{ matrix.php }}
     302      db-version: ${{ matrix.db-version }}
     303      db-type: ${{ matrix.db-type }}
     304      memcached: ${{ matrix.memcached || false }}
     305      phpunit-test-groups: ${{ matrix.phpunit-test-groups || '' }}
     306
    249307  slack-notifications:
    250308    name: Slack Notifications
     
    253311      actions: read
    254312      contents: read
    255     needs: [ test-with-mysql, test-with-mariadb, test-innovation-releases, specific-test-groups ]
     313    needs: [ test-with-mysql, test-with-mariadb, test-innovation-releases, specific-test-groups, limited-matrix-for-forks ]
    256314    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    257315    with:
Note: See TracChangeset for help on using the changeset viewer.