[wp-trac] [WordPress Trac] #52660: Check the NPM cache configuration on GitHub Actions

WordPress Trac noreply at wordpress.org
Thu Feb 25 20:14:18 UTC 2021


#52660: Check the NPM cache configuration on GitHub Actions
------------------------------+------------------------------
 Reporter:  johnbillion       |       Owner:  (none)
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  dev-feedback      |     Focuses:
------------------------------+------------------------------

Old description:

> It appears that the cache configuration for NPM on GitHub Actions isn't
> having any effect. Running `npx install-changed` both without and without
> the cache in place runs in the same time, approximately 1 minute.
>
> Needs investigation.
>
> Ref: https://github.com/WordPress/wordpress-
> develop/blob/f2b56883f099b971ebde6c60f32ef9c66f90e78a/.github/workflows
> /phpunit-tests.yml#L75-L87
>
> Testing: https://github.com/WordPress/wordpress-
> develop/blob/75af85ce86404b6a1487637edd741f522026fa50/.github/workflows
> /phpunit-tests.yml#L55-L63

New description:

 It appears that the cache configuration for NPM on GitHub Actions isn't
 having any effect. Running `npx install-changed` both with and without the
 cache in place runs in the same time, approximately 1 minute.

 Needs investigation.

 Ref: https://github.com/WordPress/wordpress-
 develop/blob/f2b56883f099b971ebde6c60f32ef9c66f90e78a/.github/workflows
 /phpunit-tests.yml#L75-L87

 Testing: https://github.com/WordPress/wordpress-
 develop/blob/75af85ce86404b6a1487637edd741f522026fa50/.github/workflows
 /phpunit-tests.yml#L55-L63

--

Comment (by desrosj):

 I did some testing in my fork and here's what I found.

 When the `restore-keys` are removed as suggested in the article, the cache
 size is cut by roughly 40%. The [https://github.com/WordPress/wordpress-
 develop/runs/1979629032?check_suite_focus=true#step:6:10 last successful
 build in `trunk`] showed the cache was `~119MB`,
 [https://github.com/desrosj/wordpress-
 develop/runs/1982001589?check_suite_focus=true#step:6:8 my PR] (with no
 prior caching) shows `~73MB`.

 I think this is a big thumbs up change.

 Next I did some testing switching out `npx install-changed` with `npm ci`.

 For the JavaScript coding standards job:

 Using `npx install-changed`
 ||= Step =|| Time ||
 || Install dependencies || 54s ||
 || Run JSHint || 9s ||

 Using `npm ci`
 ||= Step =|| Time ||
 || Install dependencies || 26s ||
 || Run JSHint || 28s ||

 For the E2E testing job

 Using `npx install-changed`
 ||= Step =|| Time ||
 || Install dependencies || 1m 17s ||
 || Build WordPress || 1m 34s ||

 Using `npm ci`
 ||= Step =|| Time ||
 || Install dependencies || 37s ||
 || Build WordPress || 1m 48s ||

 I was trying to recall my reasoning for using `npx install-changed
 --install-command="npm ci"` instead of just `npm ci`. When switching the
 two out, it seems that `npm ci` is slightly faster. But, it is a bit
 misleading to only look at the "Install Dependencies" steps because time
 shifts between two of the steps.

 When Grunt related tasks are run for the first time, `install-changed` is
 run to check for the `packagehash.txt` file, and if one is not present (or
 the hashes do not match), `npm install` is run again. By running `install
 changed` in the first step, it prevents install from running twice (even
 if partially).

 I don't feel strongly either way on this switch.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52660#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list