Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Cache node_modules between workflows #6404

Merged
merged 24 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c871b91
Running actions
alexflorisca May 11, 2022
b406bf6
Cache node_modules
alexflorisca May 12, 2022
d680ee7
Correct cache-name-prop
alexflorisca May 12, 2022
85d53fd
rejig if statements
alexflorisca May 12, 2022
3793cd8
cache node_modules everywhere
alexflorisca May 12, 2022
b907d1c
Simplify unit test action
alexflorisca May 12, 2022
d20dca2
Add checkout action back into other unit test action steps
alexflorisca May 12, 2022
814eb17
Share node_modules and build assets between jobs
alexflorisca May 12, 2022
96d9aac
Cache node_modules between jobs
alexflorisca May 12, 2022
7b097b4
Fix github error
alexflorisca May 12, 2022
c2ac2ae
Tidy up
alexflorisca May 12, 2022
382979d
Change wp-env-with-gutenberg to support multiple plugins
alexflorisca May 12, 2022
fe36c9e
Fix permissions issue
alexflorisca May 12, 2022
266af07
Remove chmod
alexflorisca May 12, 2022
6eee6f7
Pass woocommerce.zip as a string
alexflorisca May 12, 2022
0e7e284
Revert change to plugins override in unit test workflow
alexflorisca May 12, 2022
ffb4307
Revert wp-env-with-gutenberg change
alexflorisca May 12, 2022
8f997db
Revert wp-env-with-gutenberg change
alexflorisca May 12, 2022
6bd2555
Revert wp-env-with-gutenberg change
alexflorisca May 12, 2022
116b3d8
Merge branch 'trunk' into fix/cache-node_modules
alexflorisca May 13, 2022
1ec2c60
Merge branch 'trunk' into fix/cache-node_modules
alexflorisca May 20, 2022
7036ac3
Refactor check-modified-assets workflow
alexflorisca May 24, 2022
2ce4e63
Fix missed dependency
alexflorisca May 24, 2022
f2273e9
Revert breaking the check-modified-assets.yml
alexflorisca May 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions .github/workflows/check-modified-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,28 @@ jobs:
- uses: actions/checkout@v3
with:
ref: trunk
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version and npm cache
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
tarhi-saad marked this conversation as resolved.
Show resolved Hide resolved
- name: npm install and build
run: |
npm ci --no-optional
npm run build:check-assets

- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --no-optional

- name: Build Assets
run: npm run build:check-assets

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
Expand All @@ -30,15 +43,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version and npm cache
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: npm install
run: |
npm ci --no-optional
npm run build:check-assets

- name: Build Assets
run: npm run build:check-assets

- name: Download assets (trunk)
uses: actions/download-artifact@v3
with:
Expand Down
45 changes: 36 additions & 9 deletions .github/workflows/js-css-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,24 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version and npm cache
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install Node dependencies

- name: Install Node Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --no-optional

JSLintingCheck:
Expand All @@ -28,13 +40,21 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Setup node version and npm cache

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install Node dependencies
run: npm ci --no-optional
tarhi-saad marked this conversation as resolved.
Show resolved Hide resolved

- name: Save code linting report JSON
run: npm run lint:js:report
# Continue to the next step even if this fails
Expand All @@ -57,12 +77,19 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Setup node version and npm cache
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install Node dependencies
run: npm ci --no-optional
tarhi-saad marked this conversation as resolved.
Show resolved Hide resolved

- name: Lint CSS
run: npm run lint:css
43 changes: 35 additions & 8 deletions .github/workflows/php-js-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version and npm cache
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Npm install and build
run: |
npm ci --no-optional
FORCE_REDUCED_MOTION=true npm run build:e2e-test

- name: Install Node Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --no-optional

- name: Build Assets
run: FORCE_REDUCED_MOTION=true npm run build:e2e-test

- name: blocks.ini setup
run: |
echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini
Expand Down Expand Up @@ -64,15 +78,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version and npm cache
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Npm install and build
run: |
npm ci --no-optional
FORCE_REDUCED_MOTION=true npm run build:e2e-test

- name: Install Node Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --no-optional
tarhi-saad marked this conversation as resolved.
Show resolved Hide resolved

- name: Build Assets
run: FORCE_REDUCED_MOTION=true npm run build:e2e-test
tarhi-saad marked this conversation as resolved.
Show resolved Hide resolved

- name: blocks.ini setup
run: |
Expand Down
84 changes: 62 additions & 22 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,38 @@ jobs:
name: Setup
steps:
- uses: actions/checkout@v3

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version and npm cache
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Npm install and build
run: |
npm ci --no-optional
FORCE_REDUCED_MOTION=true npm run build:e2e-test

- name: Install Node Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --no-optional

- name: Build Assets
run: FORCE_REDUCED_MOTION=true npm run build:e2e-test

- name: Store Build Assets
uses: actions/upload-artifact@v3
with:
name: build-assets
path: build/

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
Expand All @@ -40,8 +58,7 @@ jobs:
tools: composer

- name: Composer install
run: |
composer install
run: composer install

PHPUnitTests:
name: PHP Unit Tests
Expand All @@ -50,23 +67,38 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version and npm cache
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Npm install #build is not needed
run: |
npm ci --no-optional
tarhi-saad marked this conversation as resolved.
Show resolved Hide resolved

- name: Download Build Assets
uses: actions/download-artifact@v3
with:
name: build-assets

- name: blocks.ini setup
run: |
echo 'woocommerce_blocks_phase = 3' > blocks.ini
run: echo 'woocommerce_blocks_phase = 3' > blocks.ini

- name: Setup Environment
run: |
chmod -R 767 ./ #TODO: Might get implemented in wp-env
npm run wp-env start

- name: Run PHPUnit tests
run: npm run test:php

- name: Run PHPUnit tests (WooCommerce Development Version)
run: |
JSON='{"plugins": [".","https://downloads.wordpress.org/plugin/woocommerce.zip"]}'
Expand All @@ -78,23 +110,31 @@ jobs:
name: JS Unit Tests
needs: Setup
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version and npm cache
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Npm install and build
run: |
npm ci --no-optional
FORCE_REDUCED_MOTION=true npm run build:e2e-test
tarhi-saad marked this conversation as resolved.
Show resolved Hide resolved

- name: Download Build Assets
uses: actions/download-artifact@v3
with:
name: build-assets

- name: blocks.ini setup
run: |
echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini
run: echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini

- name: Run JavaScript Unit tests
run: |
npm run test
run: npm run test