Build/Test Tools: Use install-changed
to install NPM dependencies in GitHub Action workflows.
The `install-changed` package records a hash of the `package.json` file locally in a text file and only runs `npm install` when there are changes to account for. This builds on [47497], which only hashes the `package.json` file after a Grunt task is called. By using `npx install-changed` within the workflow files, the package is hashed before the first Grunt task is run. Props ocean90. See #50401, #49594. git-svn-id: https://develop.svn.wordpress.org/trunk@49369 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
df716454a3
commit
886a9ddaa4
4
.github/workflows/coding-standards.yml
vendored
4
.github/workflows/coding-standards.yml
vendored
@ -79,7 +79,7 @@ jobs:
|
|||||||
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `.nvmrc` file to support older branches)
|
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `.nvmrc` file to support older branches)
|
||||||
# - Sets up caching for NPM.
|
# - Sets up caching for NPM.
|
||||||
# - Logs updated debug information.
|
# - Logs updated debug information.
|
||||||
# _ Installs NPM dependencies.
|
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
|
||||||
# - Run the WordPress JSHint checks.
|
# - Run the WordPress JSHint checks.
|
||||||
# - todo: Configure Slack notifications for failing tests.
|
# - todo: Configure Slack notifications for failing tests.
|
||||||
jshint:
|
jshint:
|
||||||
@ -120,7 +120,7 @@ jobs:
|
|||||||
node --version
|
node --version
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npx install-changed --install-command="npm ci"
|
||||||
|
|
||||||
- name: Run JSHint
|
- name: Run JSHint
|
||||||
run: npm run grunt jshint
|
run: npm run grunt jshint
|
||||||
|
4
.github/workflows/end-to-end-tests.yml
vendored
4
.github/workflows/end-to-end-tests.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
|||||||
# - Logs debug information about the runner container.
|
# - Logs debug information about the runner container.
|
||||||
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `.nvmrc` file to support older branches)
|
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `.nvmrc` file to support older branches)
|
||||||
# - Sets up caching for NPM.
|
# - Sets up caching for NPM.
|
||||||
# _ Installs NPM dependencies.
|
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
|
||||||
# - Builds WordPress to run from the `build` directory.
|
# - Builds WordPress to run from the `build` directory.
|
||||||
# - Starts the WordPress Docker container.
|
# - Starts the WordPress Docker container.
|
||||||
# - Logs general debug information.
|
# - Logs general debug information.
|
||||||
@ -77,7 +77,7 @@ jobs:
|
|||||||
${{ runner.os }}-npm-
|
${{ runner.os }}-npm-
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npx install-changed --install-command="npm ci"
|
||||||
|
|
||||||
- name: Build WordPress
|
- name: Build WordPress
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
4
.github/workflows/javascript-tests.yml
vendored
4
.github/workflows/javascript-tests.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
|||||||
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `.nvmrc` file to support older branches)
|
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `.nvmrc` file to support older branches)
|
||||||
# - Sets up caching for NPM.
|
# - Sets up caching for NPM.
|
||||||
# - Logs updated debug information.
|
# - Logs updated debug information.
|
||||||
# _ Installs NPM dependencies.
|
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
|
||||||
# - Run the WordPress QUnit tests.
|
# - Run the WordPress QUnit tests.
|
||||||
# - todo: Configure Slack notifications for failing tests.
|
# - todo: Configure Slack notifications for failing tests.
|
||||||
test-js:
|
test-js:
|
||||||
@ -62,7 +62,7 @@ jobs:
|
|||||||
node --version
|
node --version
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npx install-changed --install-command="npm ci"
|
||||||
|
|
||||||
- name: Run QUnit tests
|
- name: Run QUnit tests
|
||||||
run: npm run grunt qunit:compiled
|
run: npm run grunt qunit:compiled
|
||||||
|
12
.github/workflows/phpunit-tests.yml
vendored
12
.github/workflows/phpunit-tests.yml
vendored
@ -28,7 +28,7 @@ jobs:
|
|||||||
# - Logs debug information about the runner container.
|
# - Logs debug information about the runner container.
|
||||||
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `.nvmrc` file to support older branches)
|
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `.nvmrc` file to support older branches)
|
||||||
# - Sets up caching for NPM.
|
# - Sets up caching for NPM.
|
||||||
# _ Installs NPM dependencies.
|
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
|
||||||
# - Builds WordPress to run from the `build` directory.
|
# - Builds WordPress to run from the `build` directory.
|
||||||
# - Creates a ZIP file of compiled WordPress
|
# - Creates a ZIP file of compiled WordPress
|
||||||
# - Uploads ZIP file as an artifact.
|
# - Uploads ZIP file as an artifact.
|
||||||
@ -51,6 +51,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Log debug information
|
- name: Log debug information
|
||||||
run: |
|
run: |
|
||||||
|
echo "$GITHUB_REF"
|
||||||
|
echo "$GITHUB_EVENT_NAME"
|
||||||
npm --version
|
npm --version
|
||||||
node --version
|
node --version
|
||||||
curl --version
|
curl --version
|
||||||
@ -77,7 +79,7 @@ jobs:
|
|||||||
${{ runner.os }}-npm-
|
${{ runner.os }}-npm-
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npx install-changed --install-command="npm ci"
|
||||||
|
|
||||||
- name: Build WordPress
|
- name: Build WordPress
|
||||||
run: npm run build
|
run: npm run build
|
||||||
@ -86,7 +88,7 @@ jobs:
|
|||||||
uses: thedoctor0/zip-release@0.4.1
|
uses: thedoctor0/zip-release@0.4.1
|
||||||
with:
|
with:
|
||||||
filename: built-wp-${{ github.sha }}.zip
|
filename: built-wp-${{ github.sha }}.zip
|
||||||
exclusions: '/*node_modules/*'
|
exclusions: '*.git* /*node_modules/* packagehash.txt'
|
||||||
|
|
||||||
- name: Upload build artifact
|
- name: Upload build artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
@ -104,7 +106,7 @@ jobs:
|
|||||||
# - Unzips the artifact.
|
# - Unzips the artifact.
|
||||||
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `nvmrc` file to support older branches)
|
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `nvmrc` file to support older branches)
|
||||||
# - Sets up caching for NPM.
|
# - Sets up caching for NPM.
|
||||||
# _ Installs NPM dependencies.
|
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
|
||||||
# - Configures caching for Composer.
|
# - Configures caching for Composer.
|
||||||
# _ Installs Composer dependencies (if desired)
|
# _ Installs Composer dependencies (if desired)
|
||||||
# - Logs Docker debug information (about both the Docker installation within the runner)
|
# - Logs Docker debug information (about both the Docker installation within the runner)
|
||||||
@ -172,7 +174,7 @@ jobs:
|
|||||||
${{ runner.os }}-npm-
|
${{ runner.os }}-npm-
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npx install-changed --install-command="npm ci"
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
|
4
.github/workflows/verify-npm-on-windows.yml
vendored
4
.github/workflows/verify-npm-on-windows.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
# - Logs debug information about the runner container.
|
# - Logs debug information about the runner container.
|
||||||
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `.nvmrc` file to support older branches)
|
# - Installs NodeJS 12 (todo: install the version of NPM specified in the `.nvmrc` file to support older branches)
|
||||||
# - Sets up caching for NPM.
|
# - Sets up caching for NPM.
|
||||||
# _ Installs NPM dependencies.
|
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
|
||||||
# - Builds WordPress to run from the `build` directory.
|
# - Builds WordPress to run from the `build` directory.
|
||||||
test-npm:
|
test-npm:
|
||||||
name: Tests NPM on Windows
|
name: Tests NPM on Windows
|
||||||
@ -62,7 +62,7 @@ jobs:
|
|||||||
${{ runner.os }}-npm-
|
${{ runner.os }}-npm-
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npx install-changed --install-command="npm ci"
|
||||||
|
|
||||||
- name: Build WordPress
|
- name: Build WordPress
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
Loading…
Reference in New Issue
Block a user