wordpress/.github/workflows/test-npm.yml
Jonathan Desrosiers 7dfe7cc7e8 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.5 branch.
See #56095.

git-svn-id: https://develop.svn.wordpress.org/branches/4.5@53616 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-30 17:19:15 +00:00

138 lines
4.5 KiB
YAML

name: Test NPM
on:
push:
branches:
- trunk
- '3.[7-9]'
- '[4-9].[0-9]'
pull_request:
branches:
- trunk
- '3.[7-9]'
- '[4-9].[0-9]'
paths:
# These files configure NPM. Changes could affect the outcome.
- 'package*.json'
# JavaScript files are built using NPM.
- '**.js'
# CSS and SCSS files are built using NPM.
- '**.scss'
- '**.css'
# Changes to workflow files should always verify all workflows are successful.
- '.github/workflows/**.yml'
workflow_dispatch:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
jobs:
# Verifies that installing NPM dependencies and building WordPress works as expected.
#
# Performs the following steps:
# - Checks out the repository.
# - Logs debug information about the GitHub Action runner.
# - Installs NodeJS.
# _ Installs NPM dependencies.
# - Builds WordPress to run from the `build` directory.
# - Cleans up after building WordPress to the `build` directory.
test-npm:
name: Test NPM on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]
steps:
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Log debug information
run: |
npm --version
node --version
curl --version
git --version
svn --version
- name: Install NodeJS
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install Dependencies
run: npm ci
- name: Build WordPress
run: npm run build
- name: Clean after building
run: npm run grunt clean
# Verifies that installing NPM dependencies and building WordPress works as expected on MacOS.
#
# This is separate from the job above in order to use stricter conditions about when to run.
# This avoids unintentionally consuming excessive minutes, as MacOS jobs consume minutes at a 10x rate.
#
# Performs the following steps:
# - Checks out the repository.
# - Logs debug information about the GitHub Action runner.
# - Installs NodeJS.
# _ Installs NPM dependencies.
# - Builds WordPress to run from the `build` directory.
# - Cleans up after building WordPress to the `build` directory.
test-npm-macos:
name: Test NPM on MacOS
runs-on: macos-latest
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
steps:
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Log debug information
run: |
npm --version
node --version
curl --version
git --version
svn --version
- name: Install NodeJS
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install Dependencies
run: npm ci
- name: Build WordPress
run: npm run build
- name: Clean after building
run: npm run grunt clean
slack-notifications:
name: Slack Notifications
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
needs: [ test-npm, test-npm-macos ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
with:
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' }}
secrets:
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}