From f2f49f4ff9d09564ba4678d54a82df652f3e9a7f Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 5 Aug 2024 10:48:31 +0200 Subject: [PATCH 1/2] ci: Cache playwright separately --- .github/actions/install-playwright/action.yml | 28 +++++++++ .github/workflows/build.yml | 58 ++++++------------- .github/workflows/flaky-test-detector.yml | 22 +------ 3 files changed, 47 insertions(+), 61 deletions(-) create mode 100644 .github/actions/install-playwright/action.yml diff --git a/.github/actions/install-playwright/action.yml b/.github/actions/install-playwright/action.yml new file mode 100644 index 000000000000..29ecbcfbd2d1 --- /dev/null +++ b/.github/actions/install-playwright/action.yml @@ -0,0 +1,28 @@ +name: "Install Playwright dependencies" +description: "Installs Playwright dependencies and caches them." + +runs: + using: "composite" + steps: + - name: Get Playwright version + id: playwright-version + run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT + shell: bash + + - name: Cache playwright binaries + uses: actions/cache@v4 + id: playwright-cache + with: + path: | + ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} + + - name: Install Playwright dependencies (uncached) + run: npx playwright install chromium webkit firefox --with-deps + if: steps.playwright-cache.outputs.cache-hit != 'true' + shell: bash + + - name: Install Playwright system dependencies only (cached) + run: npx playwright install-deps chromium webkit firefox + if: steps.playwright-cache.outputs.cache-hit == 'true' + shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c160b8752a26..158a7a0cae79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,6 @@ env: ${{ github.workspace }}/node_modules ${{ github.workspace }}/packages/*/node_modules ${{ github.workspace }}/dev-packages/*/node_modules - ~/.cache/ms-playwright/ ~/.cache/mongodb-binaries/ # DEPENDENCY_CACHE_KEY: can't be set here because we don't have access to yarn.lock @@ -659,26 +658,10 @@ jobs: uses: ./.github/actions/restore-cache env: DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }} - - name: Get npm cache directory - id: npm-cache-dir - run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT - - name: Get Playwright version - id: playwright-version - run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Check if Playwright browser is cached - id: playwright-cache - with: - path: ${{ steps.npm-cache-dir.outputs.dir }} - key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}} - - name: Install Playwright browser if not cached - if: steps.playwright-cache.outputs.cache-hit != 'true' - run: npx playwright install --with-deps - env: - PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}} - - name: Install OS dependencies of Playwright if cache hit - if: steps.playwright-cache.outputs.cache-hit == 'true' - run: npx playwright install-deps + + - name: Install Playwright + uses: ./.github/actions/install-playwright + - name: Run Playwright tests env: PW_BUNDLE: ${{ matrix.bundle }} @@ -723,26 +706,10 @@ jobs: uses: ./.github/actions/restore-cache env: DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }} - - name: Get npm cache directory - id: npm-cache-dir - run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT - - name: Get Playwright version - id: playwright-version - run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Check if Playwright browser is cached - id: playwright-cache - with: - path: ${{ steps.npm-cache-dir.outputs.dir }} - key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}} - - name: Install Playwright browser if not cached - if: steps.playwright-cache.outputs.cache-hit != 'true' - run: npx playwright install --with-deps - env: - PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}} - - name: Install OS dependencies of Playwright if cache hit - if: steps.playwright-cache.outputs.cache-hit == 'true' - run: npx playwright install-deps + + - name: Install Playwright + uses: ./.github/actions/install-playwright + - name: Run Playwright Loader tests env: PW_BUNDLE: ${{ matrix.bundle }} @@ -1052,6 +1019,9 @@ jobs: path: ${{ github.workspace }}/packages/*/*.tgz key: ${{ env.BUILD_CACHE_TARBALL_KEY }} + - name: Install Playwright + uses: ./.github/actions/install-playwright + - name: Get node version id: versions run: | @@ -1146,6 +1116,9 @@ jobs: path: ${{ github.workspace }}/packages/*/*.tgz key: ${{ env.BUILD_CACHE_TARBALL_KEY }} + - name: Install Playwright + uses: ./.github/actions/install-playwright + - name: Get node version id: versions run: | @@ -1243,6 +1216,9 @@ jobs: key: ${{ env.BUILD_CACHE_TARBALL_KEY }} fail-on-cache-miss : true + - name: Install Playwright + uses: ./.github/actions/install-playwright + - name: Get node version id: versions run: | diff --git a/.github/workflows/flaky-test-detector.yml b/.github/workflows/flaky-test-detector.yml index 44edf51fd45d..d2238ce58e71 100644 --- a/.github/workflows/flaky-test-detector.yml +++ b/.github/workflows/flaky-test-detector.yml @@ -49,26 +49,8 @@ jobs: - name: Build packages run: yarn build - - name: Get npm cache directory - id: npm-cache-dir - run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT - - name: Get Playwright version - id: playwright-version - run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Check if Playwright browser is cached - id: playwright-cache - with: - path: ${{ steps.npm-cache-dir.outputs.dir }} - key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}} - - name: Install Playwright browser if not cached - if: steps.playwright-cache.outputs.cache-hit != 'true' - run: npx playwright install --with-deps - env: - PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}} - - name: Install OS dependencies of Playwright if cache hit - if: steps.playwright-cache.outputs.cache-hit == 'true' - run: npx playwright install-deps + - name: Install Playwright + uses: ./.github/actions/install-playwright - name: Determine changed tests uses: dorny/paths-filter@v3.0.1 From 3fab2bac1fc51cec25557aac69029a0b3f7850db Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 5 Aug 2024 11:32:18 +0200 Subject: [PATCH 2/2] add for remix --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 158a7a0cae79..647d08b3feff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -821,6 +821,8 @@ jobs: uses: ./.github/actions/restore-cache env: DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }} + - name: Install Playwright + uses: ./.github/actions/install-playwright - name: Run integration tests env: NODE_VERSION: ${{ matrix.node }}