Skip to content

Commit

Permalink
ci: cache cypress, playwright, puppeteer (#2676)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Jan 19, 2023
1 parent 26f915a commit 3d8ef76
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 24 deletions.
63 changes: 63 additions & 0 deletions .github/actions/setup-and-cache/action.yml
@@ -0,0 +1,63 @@
name: Setup and cache
description: Setup for node, pnpm and cache for browser testing binaries
inputs:
node-version:
required: false
description: Node version for setup-node
default: 18.x

runs:
using: composite

steps:
- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node version to ${{ inputs.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}

- name: Resolve package versions
id: resolve-package-versions
shell: bash
run: >
echo "$(
node -e "
const fs = require('fs');
const lockfile = fs.readFileSync('./pnpm-lock.yaml', 'utf8');
const cypressVersion = lockfile.match(/cypress: (\d+\.\d+\.\d+)/)[1];
const playwrightVersion = lockfile.match(/playwright: (\d+\.\d+\.\d+)/)[1];
const puppeteerVersion = lockfile.match(/puppeteer: (\d+\.\d+\.\d+)/)[1];
console.log('CYPRESS_VERSION=' + cypressVersion);
console.log('PLAYWRIGHT_VERSION=' + playwrightVersion);
console.log('PUPPETEER_VERSION=' + puppeteerVersion);
"
)" >> $GITHUB_OUTPUT
- name: Cache Cypress v${{ steps.resolve-package-versions.outputs.CYPRESS_VERSION }}
uses: actions/cache@v3
id: cypress-cache
with:
path: ${{ env.CYPRESS_CACHE_FOLDER }}
key: ${{ runner.os }}-cypress-${{ steps.resolve-package-versions.outputs.CYPRESS_VERSION }}
restore-keys: |
${{ runner.os }}-cypress-
- name: Cache Playwright v${{ steps.resolve-package-versions.outputs.PLAYWRIGHT_VERSION }}
uses: actions/cache@v3
id: playwright-cache
with:
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
key: ${{ runner.os }}-playwright-${{ steps.resolve-package-versions.outputs.PLAYWRIGHT_VERSION }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Cache Puppeteer v${{ steps.resolve-package-versions.outputs.PUPPETEER_VERSION }}
uses: actions/cache@v3
id: puppeteer-cache
with:
path: ${{ env.PUPPETEER_DOWNLOAD_PATH }}
key: ${{ runner.os }}-puppeteer-${{ steps.resolve-package-versions.outputs.PUPPETEER_VERSION }}
restore-keys: |
${{ runner.os }}-puppeteer-
31 changes: 7 additions & 24 deletions .github/workflows/ci.yml
Expand Up @@ -15,20 +15,17 @@ concurrency:

env:
VITEST_SEGFAULT_RETRY: 3
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.cache/ms-playwright
CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/.cache/Cypress
PUPPETEER_DOWNLOAD_PATH: ${{ github.workspace }}/.cache/Puppeteer

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node
uses: actions/setup-node@v3
with:
node-version: 18.x
- uses: ./.github/actions/setup-and-cache

- name: Install
run: pnpm i
Expand All @@ -41,13 +38,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node
uses: actions/setup-node@v3
with:
node-version: 18.x
- uses: ./.github/actions/setup-and-cache

- name: Install
run: pnpm i
Expand Down Expand Up @@ -77,11 +68,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node version to ${{ matrix.node_version }}
uses: actions/setup-node@v3
- uses: ./.github/actions/setup-and-cache
with:
node-version: ${{ matrix.node_version }}

Expand All @@ -105,11 +92,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node
uses: actions/setup-node@v3
- uses: ./.github/actions/setup-and-cache
with:
node-version: 16.16

Expand Down

0 comments on commit 3d8ef76

Please sign in to comment.