Skip to content

Commit

Permalink
build: cache node_modules in CI
Browse files Browse the repository at this point in the history
I found that the `cache` I was using in setup-node job is not what I
though it is. I thought it caches the node_modules in CI so that they
can be then restored locally, but no no. It caches packages in a remote
global cache, which doesn't bring much benefit afaik.

Therefore, I use actions/cache now to have the local caching I
originally desired, and I don't use the setup-node cache until I find a
compelling reason for it.
  • Loading branch information
daelmaak committed Feb 20, 2024
1 parent 6fcdf96 commit 52238fe
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'yarn'
# cache: 'yarn'

- name: Cache
id: install-cache
uses: actions/cache@v4
with:
path: 'node_modules'
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}

# TODO cache
- name: Install
if: steps.install-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: Build
Expand All @@ -30,7 +37,6 @@ jobs:
- name: Lint
run: yarn lint

# TODO Run as separate job? Only when Install is cached
- name: Test
run: yarn test:ci

Expand Down

0 comments on commit 52238fe

Please sign in to comment.