Browse Source

Add node module caching

Alexandru Dima 4 years ago
parent
commit
b08878cbb3
1 changed files with 50 additions and 7 deletions
  1. 50 7
      .github/workflows/ci.yml

+ 50 - 7
.github/workflows/ci.yml

@@ -11,25 +11,64 @@ on:
 jobs:
 jobs:
   build:
   build:
     name: Smoke Test
     name: Smoke Test
-    # This job runs on Linux
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
+    env:
+      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
     steps:
     steps:
-      - uses: actions/checkout@v1
+      - uses: actions/checkout@v2
+
       - uses: microsoft/playwright-github-action@v1
       - uses: microsoft/playwright-github-action@v1
-      - name: Set up Node.js
-        uses: actions/setup-node@v1
+
+      - uses: actions/setup-node@v2
         with:
         with:
-          node-version: 10.x
+          node-version: 12
+
       - name: Checkout VS Code
       - name: Checkout VS Code
         run: git clone --depth 1 https://github.com/microsoft/vscode vscode
         run: git clone --depth 1 https://github.com/microsoft/vscode vscode
-      - name: VS Code yarn & Editor Distro
+
+      - name: Compute VS Code node modules cache key
+        id: nodeModulesCacheKey
+        working-directory: ./vscode
+        run: echo "::set-output name=value::$(node build/azure-pipelines/common/computeNodeModulesCacheKey.js)"
+
+      - name: Cache VS Code node modules
+        id: cacheNodeModules
+        uses: actions/cache@v2
+        with:
+          path: "vscode/**/node_modules"
+          key: ${{ runner.os }}-cacheNodeModules-${{ steps.nodeModulesCacheKey.outputs.value }}
+          restore-keys: ${{ runner.os }}-cacheNodeModules-
+
+      - name: Get yarn cache directory path
+        id: yarnCacheDirPath
+        if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
+        run: echo "::set-output name=dir::$(yarn cache dir)"
+
+      - name: Cache yarn directory
+        if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
+        uses: actions/cache@v2
+        with:
+          path: ${{ steps.yarnCacheDirPath.outputs.dir }}
+          key: ${{ runner.os }}-yarnCacheDir-${{ steps.nodeModulesCacheKey.outputs.value }}
+          restore-keys: ${{ runner.os }}-yarnCacheDir-
+
+      - name: Execute yarn
+        if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
+        env:
+          PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
+          ELECTRON_SKIP_BINARY_DOWNLOAD: 1
+        working-directory: ./vscode
+        run: yarn --frozen-lockfile --network-timeout 180000
+
+      - name: Editor Distro
         working-directory: ./vscode
         working-directory: ./vscode
         run: |
         run: |
-          yarn
           yarn gulp editor-distro
           yarn gulp editor-distro
+
       - name: Typings validation prep
       - name: Typings validation prep
         run: |
         run: |
           mkdir typings-test
           mkdir typings-test
+
       - name: Typings validation
       - name: Typings validation
         working-directory: ./typings-test
         working-directory: ./typings-test
         run: |
         run: |
@@ -38,13 +77,17 @@ jobs:
           yarn tsc --init
           yarn tsc --init
           echo "import '../vscode/out-monaco-editor-core';" > a.ts
           echo "import '../vscode/out-monaco-editor-core';" > a.ts
           yarn tsc --noEmit
           yarn tsc --noEmit
+
       - name: NPM Install
       - name: NPM Install
         run: npm install
         run: npm install
+
       - name: Webpack Bundle
       - name: Webpack Bundle
         run: |
         run: |
           npm run bundle
           npm run bundle
+
       - name: Build Tests
       - name: Build Tests
         run: npm run build-test
         run: npm run build-test
+
       - name: Run Smoke Test
       - name: Run Smoke Test
         run: |
         run: |
           npm run ciserver &
           npm run ciserver &