add cache

This commit is contained in:
Baptiste Augrain 2021-03-10 18:58:36 +01:00
parent 78ba01d3a0
commit 2089830d92
4 changed files with 73 additions and 1 deletions
.github/workflows
build/azure-pipelines

View file

@ -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 }}

View file

@ -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 }}

View file

@ -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 }}

View file

@ -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'));