]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
ci: add cypress & playwright binary caches
authorHaoqun Jiang <haoqunjiang@gmail.com>
Tue, 28 Feb 2023 11:28:20 +0000 (19:28 +0800)
committerHaoqun Jiang <haoqunjiang@gmail.com>
Tue, 28 Feb 2023 11:28:20 +0000 (19:28 +0800)
.github/workflows/ci.yml

index 915d37ff5eb8c86e732f1988543d636d8ceaf495..55ae34695cd35e1d4a56c864f6f0cc85154b805b 100644 (file)
@@ -113,11 +113,39 @@ jobs:
           path: outfile.cjs
           key: ${{ github.sha }}-${{ hashFiles('pnpm-lock.yaml') }}
       - name: Build the package on cache miss
-        if: steps.cache.outputs.cache-hit != 'true'
+        if: steps.cache-restore.outputs.cache-hit != 'true'
         run: pnpm install && pnpm build
         env:
+          # The main project doesn't need Cypress binaries
           CYPRESS_INSTALL_BINARY: 0
 
+      # https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml#L62
+      # Install playwright's binary under custom directory to cache
+      - name: Set Playwright & Cypress path
+        if: runner.os != 'Windows'
+        run: |
+          echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
+          echo "CYPRESS_CACHE_FOLDER=$HOME/.cache/cypress-bin" >> $GITHUB_ENV
+      - name: Set Playwright & Cypress path (windows)
+        if: runner.os == 'Windows'
+        run: |
+          echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
+          echo "CYPRESS_CACHE_FOLDER=$HOME\.cache\cypress-bin" >> $env:GITHUB_ENV
+
+      - name: Cache Cypress binaries
+        uses: actions/cache@v3
+        with:
+          key: ${{ runner.os }}-cypress-bin
+          path: ${{ env.CYPRESS_CACHE_FOLDER }}
+
+      - name: Cache Playwright's binary
+        uses: actions/cache@v3
+        with:
+          # Playwright removes unused browsers automatically
+          # So does not need to add playwright version to key
+          key: ${{ runner.os }}-playwright-bin-v1
+          path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
+
       - if: ${{ (contains(env.FEATURE_FLAGS, '--')) }}
         name: Create the sample project with feature flags
         run: node ./outfile.cjs sample-project ${{ env.FEATURE_FLAGS }}
@@ -142,6 +170,7 @@ jobs:
         working-directory: ../sample-project
         run: pnpm build
 
+
       - if: ${{ contains(matrix.flag-for-e2e, '--playwright') }}
         name: Install Playwright dependencies
         working-directory: ../sample-project