From 8c611b88ee5df6d0dc41b4422f55e97c338ae235 Mon Sep 17 00:00:00 2001
From: Ariya Hidayat <ariya@metabase.com>
Date: Mon, 6 Dec 2021 15:23:35 -0800
Subject: [PATCH] CI with GitHub Actions: cache node_modules (#19202)

---
 .github/workflows/docs.yml                |  5 +++++
 .github/workflows/frontend.yml            | 25 +++++++++++++++++++++++
 .github/workflows/fuzzing.yml             | 10 +++++++++
 .github/workflows/i18n.yml                |  5 +++++
 .github/workflows/percy-issue-comment.yml | 10 +++++++++
 .github/workflows/percy.yml               | 10 +++++++++
 .github/workflows/uberjar.yml             |  5 +++++
 .github/workflows/yaml.yml                |  5 +++++
 8 files changed, 75 insertions(+)

diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 43864fee752..af93908bc7c 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -28,6 +28,11 @@ jobs:
       with:
         path: ~/.cache/yarn
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+    - name: Get node_modules cache
+      uses: actions/cache@v2
+      with:
+        path: node_modules
+        key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
     - run: yarn install --frozen-lockfile --prefer-offline
     - run: yarn run lint-docs-links
       name: Run docs links checker
diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml
index 7420c13be91..32456e964b2 100644
--- a/.github/workflows/frontend.yml
+++ b/.github/workflows/frontend.yml
@@ -30,6 +30,11 @@ jobs:
       with:
         path: ~/.cache/yarn
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+    - name: Get node_modules cache
+      uses: actions/cache@v2
+      with:
+        path: node_modules
+        key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
     - run: yarn install --frozen-lockfile --prefer-offline
     - run: yarn run lint-prettier
       name: Run Prettier formatting linter
@@ -53,6 +58,11 @@ jobs:
       with:
         path: ~/.cache/yarn
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+    - name: Get node_modules cache
+      uses: actions/cache@v2
+      with:
+        path: node_modules
+        key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
     - run: yarn install --frozen-lockfile --prefer-offline
     - run: yarn run lint-eslint
       name: Run ESLint linter
@@ -71,6 +81,11 @@ jobs:
       with:
         path: ~/.cache/yarn
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+    - name: Get node_modules cache
+      uses: actions/cache@v2
+      with:
+        path: node_modules
+        key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
     - run: yarn install --frozen-lockfile --prefer-offline
     - run: yarn type-check
       name: Check types
@@ -94,6 +109,11 @@ jobs:
       with:
         path: ~/.cache/yarn
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+    - name: Get node_modules cache
+      uses: actions/cache@v2
+      with:
+        path: node_modules
+        key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
     - run: yarn install --frozen-lockfile --prefer-offline
     - run: yarn run test-unit --coverage --silent
       name: Run frontend unit tests
@@ -122,6 +142,11 @@ jobs:
       with:
         path: ~/.cache/yarn
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+    - name: Get node_modules cache
+      uses: actions/cache@v2
+      with:
+        path: node_modules
+        key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
     - run: yarn install --frozen-lockfile --prefer-offline
     - run: yarn run test-timezones
       name: Run frontend timezones tests
diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml
index f20d85d9e01..656b9026fe1 100644
--- a/.github/workflows/fuzzing.yml
+++ b/.github/workflows/fuzzing.yml
@@ -37,6 +37,11 @@ jobs:
       with:
         path: ~/.cache/yarn
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+    - name: Get node_modules cache
+      uses: actions/cache@v2
+      with:
+        path: node_modules
+        key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
     - run: yarn install --frozen-lockfile --prefer-offline
     - run: yarn test-unit frontend/test/metabase/lib/expressions/fuzz.tokenizer.unit.spec.js
       env:
@@ -62,6 +67,11 @@ jobs:
       with:
         path: ~/.cache/yarn
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+    - name: Get node_modules cache
+      uses: actions/cache@v2
+      with:
+        path: node_modules
+        key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
     - run: yarn install --frozen-lockfile --prefer-offline
     - run: yarn test-unit frontend/test/metabase/lib/expressions/fuzz.parser.unit.spec.js
       env:
diff --git a/.github/workflows/i18n.yml b/.github/workflows/i18n.yml
index 2f4ee2e8374..2a65ccf527c 100644
--- a/.github/workflows/i18n.yml
+++ b/.github/workflows/i18n.yml
@@ -28,6 +28,11 @@ jobs:
       with:
         path: ~/.cache/yarn
         key: ${{ runner.os }}-i18n-${{ hashFiles('**/yarn.lock') }}
+    - name: Get node_modules cache
+      uses: actions/cache@v2
+      with:
+        path: node_modules
+        key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
     - run: yarn install --frozen-lockfile --prefer-offline
 
     - run: sudo apt install gettext
diff --git a/.github/workflows/percy-issue-comment.yml b/.github/workflows/percy-issue-comment.yml
index acdf5c32871..4b13d93747e 100644
--- a/.github/workflows/percy-issue-comment.yml
+++ b/.github/workflows/percy-issue-comment.yml
@@ -68,6 +68,11 @@ jobs:
         with:
           path: ~/.cache/yarn
           key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+      - name: Get node_modules cache
+        uses: actions/cache@v2
+        with:
+          path: node_modules
+          key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
       - name: Get M2 cache
         uses: actions/cache@v2
         with:
@@ -126,6 +131,11 @@ jobs:
         with:
           path: ~/.cache/yarn
           key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+      - name: Get node_modules cache
+        uses: actions/cache@v2
+        with:
+          path: node_modules
+          key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
       - run: yarn install --frozen-lockfile --prefer-offline
 
       - uses: actions/download-artifact@v2
diff --git a/.github/workflows/percy.yml b/.github/workflows/percy.yml
index c3153fc2b68..bf5bb64b115 100644
--- a/.github/workflows/percy.yml
+++ b/.github/workflows/percy.yml
@@ -49,6 +49,11 @@ jobs:
         with:
           path: ~/.cache/yarn
           key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+      - name: Get node_modules cache
+        uses: actions/cache@v2
+        with:
+          path: node_modules
+          key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
       - name: Get M2 cache
         uses: actions/cache@v2
         with:
@@ -100,6 +105,11 @@ jobs:
         with:
           path: ~/.cache/yarn
           key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+      - name: Get node_modules cache
+        uses: actions/cache@v2
+        with:
+          path: node_modules
+          key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
       - run: yarn install --frozen-lockfile --prefer-offline
 
       - uses: actions/download-artifact@v2
diff --git a/.github/workflows/uberjar.yml b/.github/workflows/uberjar.yml
index 269f3da5715..c6b813d0294 100644
--- a/.github/workflows/uberjar.yml
+++ b/.github/workflows/uberjar.yml
@@ -46,6 +46,11 @@ jobs:
       with:
         path: ~/.cache/yarn
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+    - name: Get node_modules cache
+      uses: actions/cache@v2
+      with:
+        path: node_modules
+        key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
     - name: Get M2 cache
       uses: actions/cache@v2
       with:
diff --git a/.github/workflows/yaml.yml b/.github/workflows/yaml.yml
index 3f5f4a3b15a..7eafbed0f01 100644
--- a/.github/workflows/yaml.yml
+++ b/.github/workflows/yaml.yml
@@ -26,5 +26,10 @@ jobs:
       with:
         path: ~/.cache/yarn
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+    - name: Get node_modules cache
+      uses: actions/cache@v2
+      with:
+        path: node_modules
+        key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
     - run: yarn install --frozen-lockfile --prefer-offline
     - run: yarn run lint-yaml
-- 
GitLab