Make WordPress Core

Changeset 56660


Ignore:
Timestamp:
09/22/2023 02:28:01 PM (14 months ago)
Author:
desrosj
Message:

Build/Test Tools: Simplify some logic in GitHub Action workflows.

This simplifies the logic within the slack-notifications and failed-workflow steps in GitHub Action workflows to use the contains() function and object filtering.

This makes it simpler to perform the needed checks by removing the need to list out every single dependent job defined in needs.

See #58867.

Location:
trunk/.github/workflows
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/coding-standards.yml

    r56659 r56660  
    183183    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    184184    with:
    185       calling_status: ${{ needs.phpcs.result == 'success' && needs.jshint.result == 'success' && 'success' || ( needs.phpcs.result == 'cancelled' || needs.jshint.result == 'cancelled' ) && 'cancelled' || 'failure' }}
     185      calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
    186186    secrets:
    187187      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
     
    202202      github.run_attempt < 2 &&
    203203      (
    204         needs.phpcs.result == 'cancelled' || needs.phpcs.result == 'failure' ||
    205         needs.jshint.result == 'cancelled' || needs.jshint.result == 'failure'
     204        contains( needs.*.result, 'cancelled' ) ||
     205        contains( needs.*.result, 'failure' )
    206206      )
    207207
  • trunk/.github/workflows/javascript-tests.yml

    r56538 r56660  
    9898    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    9999    with:
    100       calling_status: ${{ needs.test-js.result == 'success' && 'success' || needs.test-js.result == 'cancelled' && 'cancelled' || 'failure' }}
     100      calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
    101101    secrets:
    102102      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
     
    117117      github.run_attempt < 2 &&
    118118      (
    119         needs.test-js.result == 'cancelled' || needs.test-js.result == 'failure'
     119        contains( needs.*.result, 'cancelled' ) ||
     120        contains( needs.*.result, 'failure' )
    120121      )
    121122
  • trunk/.github/workflows/performance.yml

    r56537 r56660  
    252252    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    253253    with:
    254       calling_status: ${{ needs.performance.result == 'success' && 'success' || needs.performance.result == 'cancelled' && 'cancelled' || 'failure' }}
     254      calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
    255255    secrets:
    256256      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
     
    271271      github.run_attempt < 2 &&
    272272      (
    273         needs.performance.result == 'cancelled' || needs.performance.result == 'failure'
     273        contains( needs.*.result, 'cancelled' ) ||
     274        contains( needs.*.result, 'failure' )
    274275      )
    275276
  • trunk/.github/workflows/php-compatibility.yml

    r56537 r56660  
    123123    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    124124    with:
    125       calling_status: ${{ needs.php-compatibility.result == 'success' && 'success' || needs.php-compatibility.result == 'cancelled' && 'cancelled' || 'failure' }}
     125      calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
    126126    secrets:
    127127      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
     
    142142      github.run_attempt < 2 &&
    143143      (
    144         needs.php-compatibility.result == 'cancelled' || needs.php-compatibility.result == 'failure'
     144        contains( needs.*.result, 'cancelled' ) ||
     145        contains( needs.*.result, 'failure' )
    145146      )
    146147
  • trunk/.github/workflows/phpunit-tests.yml

    r56498 r56660  
    137137    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    138138    with:
    139       calling_status: ${{ needs.test-with-mysql.result == 'success' && needs.test-with-mariadb.result == 'success' && 'success' || ( needs.test-with-mysql.result == 'cancelled' || needs.test-with-mariadb.result == 'cancelled' ) && 'cancelled' || 'failure' }}
     139      calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
    140140    secrets:
    141141      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
     
    156156      github.run_attempt < 2 &&
    157157      (
    158         needs.test-with-mysql.result == 'cancelled' || needs.test-with-mysql.result == 'failure' ||
    159         needs.test-with-mariadb.result == 'cancelled' || needs.test-with-mariadb.result == 'failure'
     158        contains( needs.*.result, 'cancelled' ) ||
     159        contains( needs.*.result, 'failure' )
    160160      )
    161161
  • trunk/.github/workflows/test-and-zip-default-themes.yml

    r56537 r56660  
    156156    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    157157    with:
    158       calling_status: ${{ needs.test-build-scripts.result == 'success' && needs.bundle-theme.result == 'success' && 'success' || ( needs.test-build-scripts.result == 'cancelled' || needs.bundle-theme.result == 'cancelled' ) && 'cancelled' || 'failure' }}
     158      calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
    159159    secrets:
    160160      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
     
    175175      github.run_attempt < 2 &&
    176176      (
    177         needs.test-build-scripts.result == 'cancelled' || needs.test-build-scripts.result == 'failure' ||
    178         needs.bundle-theme.result == 'cancelled' || needs.bundle-theme.result == 'failure'
     177        contains( needs.*.result, 'cancelled' ) ||
     178        contains( needs.*.result, 'failure' )
    179179      )
    180180
  • trunk/.github/workflows/test-coverage.yml

    r56659 r56660  
    184184    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    185185    with:
    186       calling_status: ${{ needs.test-coverage-report.result == 'success' && 'success' || needs.test-coverage-report.result == 'cancelled' && 'cancelled' || 'failure' }}
     186      calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
    187187    secrets:
    188188      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
     
    203203      github.run_attempt < 2 &&
    204204      (
    205         needs.test-coverage-report.result == 'cancelled' || needs.test-coverage-report.result == 'failure'
     205        contains( needs.*.result, 'cancelled' ) ||
     206        contains( needs.*.result, 'failure' )
    206207      )
    207208
  • trunk/.github/workflows/test-npm.yml

    r56659 r56660  
    185185    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    186186    with:
    187       calling_status: ${{ needs.test-npm.result == 'success' && needs.test-npm-macos.result == 'success' && 'success' || ( needs.test-npm.result == 'cancelled' || needs.test-npm-macos.result == 'cancelled' ) && 'cancelled' || 'failure' }}
     187      calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
    188188    secrets:
    189189      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
     
    204204      github.run_attempt < 2 &&
    205205      (
    206         needs.test-npm.result == 'cancelled' || needs.test-npm.result == 'failure' ||
    207         needs.test-npm-macos.result == 'cancelled' || needs.test-npm-macos.result == 'failure'
     206        contains( needs.*.result, 'cancelled' ) ||
     207        contains( needs.*.result, 'failure' )
    208208      )
    209209
  • trunk/.github/workflows/test-old-branches.yml

    r56388 r56660  
    107107    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    108108    with:
    109       calling_status: ${{ needs.dispatch-workflows-for-old-branches.result == 'success' && 'success' || needs.dispatch-workflows-for-old-branches.result == 'cancelled' && 'cancelled' || 'failure' }}
     109      calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
    110110    secrets:
    111111      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
Note: See TracChangeset for help on using the changeset viewer.