Make WordPress Core


Ignore:
Timestamp:
06/30/2022 05:29:14 PM (2 years ago)
Author:
desrosj
Message:

Build/Test Tools: Use the Slack notifications workflow as a reusable one.

This backports several changesets that are required to remove the reliance on the workflow_run event for posting Slack notifications.

The Slack notification workflow will now be called as a reusable one, which has several benefits (see [53591]).

Several other minor GitHub Actions related updates are also being backported in this commit to maintain tooling consistency across branches that still receive security updates as a courtesy when necessary.

Workflows that are not relevant to this branch that were mistakenly backported are also being deleted.

Merges [50473], [50704], [50930], [51341], [51355], [51498], [51511], [51535], [51924], [51925], [51937], [52002], [52130], [52183], [52233], [53112], [53581], [53582], [53592] to the 4.0 branch.
See #56095.

Location:
branches/4.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0

  • branches/4.0/.github/workflows/test-npm.yml

    r50644 r53621  
    44  push:
    55    branches:
    6       - master
    76      - trunk
    87      - '3.[7-9]'
     
    109  pull_request:
    1110    branches:
    12       - master
    1311      - trunk
    1412      - '3.[7-9]'
     
    2624  workflow_dispatch:
    2725
     26# Cancels all previous workflow runs for pull requests that have not completed.
     27concurrency:
     28    # The concurrency group contains the workflow name and the branch name for pull requests
     29    # or the commit hash for any other events.
     30  group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
     31  cancel-in-progress: true
     32
    2833env:
    2934  PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
    3035
    3136jobs:
    32   # Prepares the workflow.
    33   #
    34   # Performs the following steps:
    35   # - Cancels all previous workflow runs for pull requests that have not completed.
    36   prepare-workflow:
    37     name: Prepare the workflow
    38     runs-on: ubuntu-latest
    39     if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
    40 
    41     steps:
    42       - name: Cancel previous runs of this workflow (pull requests only)
    43         if: ${{ github.event_name == 'pull_request' }}
    44         uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0
    45 
    4637  # Verifies that installing NPM dependencies and building WordPress works as expected.
    4738  #
    4839  # Performs the following steps:
    4940  # - Checks out the repository.
    50   # - Logs debug information about the runner container.
    51   # - Installs NodeJS 14.
     41  # - Logs debug information about the GitHub Action runner.
     42  # - Installs NodeJS.
    5243  # - Sets up caching for NPM.
    53   # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
     44  # _ Installs NPM dependencies.
    5445  # - Builds WordPress to run from the `build` directory.
    5546  # - Cleans up after building WordPress to the `build` directory.
     
    5748    name: Test NPM on ${{ matrix.os }}
    5849    runs-on: ${{ matrix.os }}
     50    timeout-minutes: 20
    5951    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
    60     needs: prepare-workflow
    6152    strategy:
    6253      matrix:
     
    6556    steps:
    6657      - name: Checkout repository
    67         uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
     58        uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
    6859
    6960      - name: Log debug information
     
    7667
    7768      - name: Install NodeJS
    78         uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
     69        uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
    7970        with:
    80           node-version: 14
    81 
    82       - name: Cache NodeJS modules (Ubuntu & MacOS)
    83         uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    84         if: ${{ matrix.os != 'windows-latest' }}
    85         with:
    86           path: ~/.npm
    87           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    88 
    89       - name: Get NPM cache directory (Windows only)
    90         if: ${{ matrix.os == 'windows-latest' }}
    91         id: npm-cache
    92         run: echo "::set-output name=dir::$(npm config get cache)"
    93 
    94       - name: Cache NodeJS modules (Windows only)
    95         uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    96         if: ${{ matrix.os == 'windows-latest' }}
    97         with:
    98           path: ${{ steps.npm-cache.outputs.dir }}
    99           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
     71          node-version-file: '.nvmrc'
     72          cache: npm
    10073
    10174      - name: Install Dependencies
     
    11083  # Verifies that installing NPM dependencies and building WordPress works as expected on MacOS.
    11184  #
    112   # This is a separate job in order to that more strict conditions can be used.
     85  # This is separate from the job above in order to use stricter conditions about when to run.
     86  # This avoids unintentionally consuming excessive minutes, as MacOS jobs consume minutes at a 10x rate.
    11387  #
    11488  # Performs the following steps:
    11589  # - Checks out the repository.
    116   # - Logs debug information about the runner container.
    117   # - Installs NodeJS 14.
    118   # - Sets up caching for NPM.
    119   # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
     90  # - Logs debug information about the GitHub Action runner.
     91  # - Installs NodeJS.
     92  # _ Installs NPM dependencies.
    12093  # - Builds WordPress to run from the `build` directory.
    12194  # - Cleans up after building WordPress to the `build` directory.
     
    12497    runs-on: macos-latest
    12598    if: ${{ github.repository == 'WordPress/wordpress-develop' }}
    126     needs: prepare-workflow
    12799    steps:
    128100      - name: Checkout repository
    129         uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
     101        uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
    130102
    131103      - name: Log debug information
     
    138110
    139111      - name: Install NodeJS
    140         uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
     112        uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
    141113        with:
    142           node-version: 14
    143 
    144       - name: Cache NodeJS modules
    145         uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    146         if: ${{ matrix.os != 'windows-latest' }}
    147         with:
    148           path: ~/.npm
    149           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
     114          node-version-file: '.nvmrc'
     115          cache: npm
    150116
    151117      - name: Install Dependencies
     
    157123      - name: Clean after building
    158124        run: npm run grunt clean
     125
     126  slack-notifications:
     127    name: Slack Notifications
     128    uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
     129    needs: [ test-npm, test-npm-macos ]
     130    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
     131    with:
     132      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' }}
     133    secrets:
     134      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
     135      SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
     136      SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
     137      SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
Note: See TracChangeset for help on using the changeset viewer.