Make WordPress Core


Ignore:
Timestamp:
06/30/2022 05:18:38 PM (3 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], [50796], [50930], [51341], [51355], [51498], [51511], [51535], [51924], [51925], [51937], [52002], [52130], [52183], [52233], [53112], [53581], [53582], [53592] to the 4.6 branch.
See #56095.

Location:
branches/4.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

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

    r50637 r53615  
    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.
    52   # - Sets up caching for NPM.
    53   # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
     41  # - Logs debug information about the GitHub Action runner.
     42  # - Installs NodeJS.
     43  # _ Installs NPM dependencies.
    5444  # - Builds WordPress to run from the `build` directory.
    5545  # - Cleans up after building WordPress to the `build` directory.
     
    5949    name: Test NPM on ${{ matrix.os }}
    6050    runs-on: ${{ matrix.os }}
     51    timeout-minutes: 20
    6152    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
    62     needs: prepare-workflow
    6353    strategy:
    6454      fail-fast: false
     
    6858    steps:
    6959      - name: Checkout repository
    70         uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
     60        uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
    7161
    7262      - name: Log debug information
     
    7969
    8070      - name: Install NodeJS
    81         uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
     71        uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
    8272        with:
    83           node-version: 14
     73          node-version-file: '.nvmrc'
     74          cache: npm
    8475
    85       - name: Cache NodeJS modules (Ubuntu & MacOS)
    86         uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    87         if: ${{ matrix.os != 'windows-latest' }}
     76      - name: Install Dependencies
     77        run: npm ci
     78
     79      - name: Build WordPress
     80        run: npm run build
     81
     82      - name: Clean after building
     83        run: npm run grunt clean
     84
     85      - name: Build WordPress in /src
     86        run: npm run build:dev
     87
     88      - name: Clean after building in /src
     89        run: npm run grunt clean -- --dev
     90
     91  # Verifies that installing NPM dependencies and building WordPress works as expected on MacOS.
     92  #
     93  # This is separate from the job above in order to use stricter conditions about when to run.
     94  # This avoids unintentionally consuming excessive minutes, as MacOS jobs consume minutes at a 10x rate.
     95  #
     96  # Performs the following steps:
     97  # - Checks out the repository.
     98  # - Logs debug information about the GitHub Action runner.
     99  # - Installs NodeJS.
     100  # _ Installs NPM dependencies.
     101  # - Builds WordPress to run from the `build` directory.
     102  # - Cleans up after building WordPress to the `build` directory.
     103  # - Builds WordPress to run from the `src` directory.
     104  # - Cleans up after building WordPress to the `src` directory.
     105  test-npm-macos:
     106    name: Test NPM on MacOS
     107    runs-on: macos-latest
     108    if: ${{ github.repository == 'WordPress/wordpress-develop' }}
     109    steps:
     110      - name: Checkout repository
     111        uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
     112
     113      - name: Log debug information
     114        run: |
     115          npm --version
     116          node --version
     117          curl --version
     118          git --version
     119          svn --version
     120
     121      - name: Install NodeJS
     122        uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
    88123        with:
    89           path: ~/.npm
    90           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    91 
    92       - name: Get NPM cache directory (Windows only)
    93         if: ${{ matrix.os == 'windows-latest' }}
    94         id: npm-cache
    95         run: echo "::set-output name=dir::$(npm config get cache)"
    96 
    97       - name: Cache NodeJS modules (Windows only)
    98         uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    99         if: ${{ matrix.os == 'windows-latest' }}
    100         with:
    101           path: ${{ steps.npm-cache.outputs.dir }}
    102           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
     124          node-version-file: '.nvmrc'
     125          cache: npm
    103126
    104127      - name: Install Dependencies
     
    117140        run: npm run grunt clean --dev
    118141
    119   # Verifies that installing NPM dependencies and building WordPress works as expected on MacOS.
    120   #
    121   # This is a separate job in order to that more strict conditions can be used.
    122   #
    123   # Performs the following steps:
    124   # - Checks out the repository.
    125   # - Logs debug information about the runner container.
    126   # - Installs NodeJS 14.
    127   # - Sets up caching for NPM.
    128   # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
    129   # - Builds WordPress to run from the `build` directory.
    130   # - Cleans up after building WordPress to the `build` directory.
    131   # - Builds WordPress to run from the `src` directory.
    132   # - Cleans up after building WordPress to the `src` directory.
    133   test-npm-macos:
    134     name: Test NPM on MacOS
    135     runs-on: macos-latest
    136     if: ${{ github.repository == 'WordPress/wordpress-develop' }}
    137     needs: prepare-workflow
    138     steps:
    139       - name: Checkout repository
    140         uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    141 
    142       - name: Log debug information
    143         run: |
    144           npm --version
    145           node --version
    146           curl --version
    147           git --version
    148           svn --version
    149 
    150       - name: Install NodeJS
    151         uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
    152         with:
    153           node-version: 14
    154 
    155       - name: Cache NodeJS modules
    156         uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    157         if: ${{ matrix.os != 'windows-latest' }}
    158         with:
    159           path: ~/.npm
    160           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    161 
    162       - name: Install Dependencies
    163         run: npm ci
    164 
    165       - name: Build WordPress
    166         run: npm run build
    167 
    168       - name: Clean after building
    169         run: npm run grunt clean
    170 
    171       - name: Build WordPress in /src
    172         run: npm run build:dev
    173 
    174       - name: Clean after building in /src
    175         run: npm run grunt clean --dev
     142  slack-notifications:
     143    name: Slack Notifications
     144    uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
     145    needs: [ test-npm, test-npm-macos ]
     146    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
     147    with:
     148      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' }}
     149    secrets:
     150      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
     151      SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
     152      SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
     153      SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
Note: See TracChangeset for help on using the changeset viewer.