Kaynağa Gözat

chore: Cache node_modules folders for CI

Michael Bromley 4 yıl önce
ebeveyn
işleme
75bec95c08

+ 15 - 27
.github/workflows/build_and_test.yml

@@ -25,22 +25,18 @@ jobs:
       uses: actions/setup-node@v1
       with:
         node-version: ${{ env.node }}
-    - name: Get yarn cache directory path
-      id: yarn-cache-dir-path
-      run: echo "::set-output name=dir::$(yarn cache dir)"
     - uses: actions/cache@v2
       id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
       with:
-        path: |
-          node_modules
-          packages/*/node_modules
-          ${{ steps.yarn-cache-dir-path.outputs.dir }}
+        path: '**/node_modules'
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
         restore-keys: |
           ${{ runner.os }}-yarn-
-    - name: Install & build
+    - name: Yarn install
+      if: steps.yarn-cache.outputs.cache-hit != 'true'
+      run: yarn install
+    - name: Build
       run: |
-        yarn install --prefer-offline
         yarn bootstrap
         yarn build
   unit-tests:
@@ -52,22 +48,18 @@ jobs:
         uses: actions/setup-node@v1
         with:
           node-version: ${{ env.node }}
-      - name: Get yarn cache directory path
-        id: yarn-cache-dir-path
-        run: echo "::set-output name=dir::$(yarn cache dir)"
       - uses: actions/cache@v2
         id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
         with:
-          path: |
-            node_modules
-            packages/*/node_modules
-            ${{ steps.yarn-cache-dir-path.outputs.dir }}
+          path: '**/node_modules'
           key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
           restore-keys: |
             ${{ runner.os }}-yarn-
-      - name: Install & build
+      - name: Yarn install
+        if: steps.yarn-cache.outputs.cache-hit != 'true'
+        run: yarn install --prefer-offline
+      - name: Build
         run: |
-          yarn install --prefer-offline
           yarn bootstrap
           yarn lerna run ci
       - name: Unit tests
@@ -124,22 +116,18 @@ jobs:
         uses: actions/setup-node@v1
         with:
           node-version: ${{ env.node }}
-      - name: Get yarn cache directory path
-        id: yarn-cache-dir-path
-        run: echo "::set-output name=dir::$(yarn cache dir)"
       - uses: actions/cache@v2
         id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
         with:
-          path: |
-            node_modules
-            packages/*/node_modules
-            ${{ steps.yarn-cache-dir-path.outputs.dir }}
+          path: '**/node_modules'
           key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
           restore-keys: |
             ${{ runner.os }}-yarn-
-      - name: Install & build
+      - name: Yarn install
+        if: steps.yarn-cache.outputs.cache-hit != 'true'
+        run: yarn install --prefer-offline
+      - name: Build
         run: |
-          yarn install --prefer-offline
           yarn bootstrap
           yarn lerna run ci
       - name: df

+ 7 - 5
.github/workflows/publish_and_install.yml

@@ -48,18 +48,20 @@ jobs:
     - uses: actions/cache@v2
       id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
       with:
-        path: |
-          node_modules
-          packages/*/node_modules
+        path: '**/node_modules'
           ${{ steps.yarn-cache-dir-path.outputs.dir }}
         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
         restore-keys: |
           ${{ runner.os }}-yarn-
-    - name: Install & bootstrap
+    - name: Yarn install
+      if: steps.yarn-cache.outputs.cache-hit != 'true'
       run: |
         yarn config set unsafe-perm true
         yarn install --network-timeout 1000000 --prefer-offline
-        yarn bootstrap
+      env:
+        CI: true
+    - name: Bootstrap
+      run: yarn bootstrap
       env:
         CI: true
     - name: Publish to Verdaccio