diff --git a/.github/actions/setup-and-cache/action.yml b/.github/actions/setup-and-cache/action.yml new file mode 100644 index 000000000000..9ab880d42a8f --- /dev/null +++ b/.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- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75f93f2b63d3..46f16d9b33db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,9 @@ 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: @@ -22,13 +25,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 @@ -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 @@ -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 }} @@ -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