Baptiste Augrain 4 lat temu
rodzic
commit
2089830d92

+ 16 - 0
.github/workflows/linux.yml

@@ -54,6 +54,22 @@ jobs:
         run: ./check_tags.sh
         if: env.SHOULD_DEPLOY == 'yes'
 
+      - name: Compute cache key
+        id: yarnCacheKey
+        run: echo "::set-output name=value::$(node build/azure-pipelines/computeYarnCacheKey.js)"
+
+      - name: Get yarn cache directory path
+        id: yarnCacheDirPath
+        run: echo "::set-output name=dir::$(yarn cache dir)"
+
+      - name: Cache yarn directory
+        uses: actions/cache@v2
+        with:
+          path: ${{ steps.yarnCacheDirPath.outputs.dir }}
+          key: ${{ runner.os }}-yarnCacheDir-${{ steps.yarnCacheKey.outputs.value }}
+          restore-keys: ${{ runner.os }}-yarnCacheDir-
+        if: env.SHOULD_BUILD == 'yes'
+
       - name: Build
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

+ 17 - 1
.github/workflows/macos.yml

@@ -35,7 +35,23 @@ jobs:
         run: |
           . check_tags.sh
         if: env.SHOULD_DEPLOY == 'yes'
-          
+
+      - name: Compute cache key
+        id: yarnCacheKey
+        run: echo "::set-output name=value::$(node build/azure-pipelines/computeYarnCacheKey.js)"
+
+      - name: Get yarn cache directory path
+        id: yarnCacheDirPath
+        run: echo "::set-output name=dir::$(yarn cache dir)"
+
+      - name: Cache yarn directory
+        uses: actions/cache@v2
+        with:
+          path: ${{ steps.yarnCacheDirPath.outputs.dir }}
+          key: ${{ runner.os }}-yarnCacheDir-${{ steps.yarnCacheKey.outputs.value }}
+          restore-keys: ${{ runner.os }}-yarnCacheDir-
+        if: env.SHOULD_BUILD == 'yes'
+
       - name: Build
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

+ 16 - 0
.github/workflows/windows.yml

@@ -49,6 +49,22 @@ jobs:
         shell: bash
         if: env.SHOULD_DEPLOY == 'yes'
 
+      - name: Compute cache key
+        id: yarnCacheKey
+        run: echo "::set-output name=value::$(node build/azure-pipelines/computeYarnCacheKey.js)"
+
+      - name: Get yarn cache directory path
+        id: yarnCacheDirPath
+        run: echo "::set-output name=dir::$(yarn cache dir)"
+
+      - name: Cache yarn directory
+        uses: actions/cache@v2
+        with:
+          path: ${{ steps.yarnCacheDirPath.outputs.dir }}
+          key: ${{ runner.os }}-yarnCacheDir-${{ steps.yarnCacheKey.outputs.value }}
+          restore-keys: ${{ runner.os }}-yarnCacheDir-
+        if: env.SHOULD_BUILD == 'yes'
+
       - name: Build
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

+ 24 - 0
build/azure-pipelines/computeYarnCacheKey.js

@@ -0,0 +1,24 @@
+const fs = require("fs");
+const crypto = require("crypto");
+const path = require("path");
+const { dirs } = require('../../vscode/build/npm/dirs');
+
+const ROOT = path.join(__dirname, '../../vscode');
+
+const shasum = crypto.createHash('sha1');
+
+shasum.update(fs.readFileSync(path.join(ROOT, '.yarnrc')));
+shasum.update(fs.readFileSync(path.join(ROOT, 'remote/.yarnrc')));
+
+// Add `yarn.lock` files
+for (let dir of dirs) {
+    const yarnLockPath = path.join(ROOT, dir, 'yarn.lock');
+    shasum.update(fs.readFileSync(yarnLockPath));
+}
+
+// Add any other command line arguments
+for (let i = 2; i < process.argv.length; i++) {
+    shasum.update(process.argv[i]);
+}
+
+process.stdout.write(shasum.digest('hex'));