From 52238fe7a82c32828fb162635c39129f79e04187 Mon Sep 17 00:00:00 2001 From: Daniel Macak Date: Tue, 20 Feb 2024 21:12:51 +0100 Subject: [PATCH] build: cache node_modules in CI 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. --- .github/workflows/build.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 204bfe9f..1ab5c67d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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