Skip to content

Commit e60b5e2

Browse files
committed
ref: extract playwright installation
1 parent 768f219 commit e60b5e2

File tree

4 files changed

+50
-105
lines changed

4 files changed

+50
-105
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Install playwright"
2+
description: "Installs & caches playwright."
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Get npm cache directory
8+
id: npm-cache-dir
9+
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
10+
shell: bash
11+
12+
- name: Get Playwright version
13+
id: playwright-version
14+
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
15+
shell: bash
16+
17+
- uses: actions/cache@v4
18+
name: Check if Playwright browser is cached
19+
id: playwright-cache
20+
with:
21+
path: ${{ steps.npm-cache-dir.outputs.dir }}
22+
key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}}
23+
24+
- name: Install Playwright browser if not cached
25+
if: steps.playwright-cache.outputs.cache-hit != 'true'
26+
run: npx playwright install --with-deps
27+
shell: bash
28+
env:
29+
PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}}
30+
31+
- name: Install OS dependencies of Playwright if cache hit
32+
if: steps.playwright-cache.outputs.cache-hit == 'true'
33+
run: npx playwright install-deps
34+
shell: bash

.github/workflows/build.yml

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -580,26 +580,10 @@ jobs:
580580
uses: ./.github/actions/restore-cache
581581
env:
582582
DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }}
583-
- name: Get npm cache directory
584-
id: npm-cache-dir
585-
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
586-
- name: Get Playwright version
587-
id: playwright-version
588-
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
589-
- uses: actions/cache@v4
590-
name: Check if Playwright browser is cached
591-
id: playwright-cache
592-
with:
593-
path: ${{ steps.npm-cache-dir.outputs.dir }}
594-
key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}}
595-
- name: Install Playwright browser if not cached
596-
if: steps.playwright-cache.outputs.cache-hit != 'true'
597-
run: npx playwright install --with-deps
598-
env:
599-
PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}}
600-
- name: Install OS dependencies of Playwright if cache hit
601-
if: steps.playwright-cache.outputs.cache-hit == 'true'
602-
run: npx playwright install-deps
583+
584+
- name: Install playwright
585+
uses: ./.github/actions/install-playwright
586+
603587
- name: Run tests
604588
env:
605589
NODE_VERSION: ${{ matrix.node }}
@@ -670,26 +654,10 @@ jobs:
670654
uses: ./.github/actions/restore-cache
671655
env:
672656
DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }}
673-
- name: Get npm cache directory
674-
id: npm-cache-dir
675-
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
676-
- name: Get Playwright version
677-
id: playwright-version
678-
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
679-
- uses: actions/cache@v4
680-
name: Check if Playwright browser is cached
681-
id: playwright-cache
682-
with:
683-
path: ${{ steps.npm-cache-dir.outputs.dir }}
684-
key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}}
685-
- name: Install Playwright browser if not cached
686-
if: steps.playwright-cache.outputs.cache-hit != 'true'
687-
run: npx playwright install --with-deps
688-
env:
689-
PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}}
690-
- name: Install OS dependencies of Playwright if cache hit
691-
if: steps.playwright-cache.outputs.cache-hit == 'true'
692-
run: npx playwright install-deps
657+
658+
- name: Install playwright
659+
uses: ./.github/actions/install-playwright
660+
693661
- name: Run Playwright tests
694662
env:
695663
PW_BUNDLE: ${{ matrix.bundle }}
@@ -733,26 +701,10 @@ jobs:
733701
uses: ./.github/actions/restore-cache
734702
env:
735703
DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }}
736-
- name: Get npm cache directory
737-
id: npm-cache-dir
738-
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
739-
- name: Get Playwright version
740-
id: playwright-version
741-
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
742-
- uses: actions/cache@v4
743-
name: Check if Playwright browser is cached
744-
id: playwright-cache
745-
with:
746-
path: ${{ steps.npm-cache-dir.outputs.dir }}
747-
key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}}
748-
- name: Install Playwright browser if not cached
749-
if: steps.playwright-cache.outputs.cache-hit != 'true'
750-
run: npx playwright install --with-deps
751-
env:
752-
PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}}
753-
- name: Install OS dependencies of Playwright if cache hit
754-
if: steps.playwright-cache.outputs.cache-hit == 'true'
755-
run: npx playwright install-deps
704+
705+
- name: Install playwright
706+
uses: ./.github/actions/install-playwright
707+
756708
- name: Run Playwright Loader tests
757709
env:
758710
PW_BUNDLE: ${{ matrix.bundle }}

.github/workflows/canary.yml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -130,31 +130,8 @@ jobs:
130130
timeout-minutes: 5
131131
run: yarn ${{ matrix.build-command }}
132132

133-
# Install Playwright
134-
- name: Get npm cache directory
135-
id: npm-cache-dir
136-
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
137-
138-
- name: Get Playwright version
139-
id: playwright-version
140-
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
141-
142-
- uses: actions/cache@v4
143-
name: Check if Playwright browser is cached
144-
id: playwright-cache
145-
with:
146-
path: ${{ steps.npm-cache-dir.outputs.dir }}
147-
key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}}
148-
149-
- name: Install Playwright browser if not cached
150-
if: steps.playwright-cache.outputs.cache-hit != 'true'
151-
run: npx playwright install --with-deps
152-
env:
153-
PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}}
154-
155-
- name: Install OS dependencies of Playwright if cache hit
156-
if: steps.playwright-cache.outputs.cache-hit == 'true'
157-
run: npx playwright install-deps
133+
- name: Install playwright
134+
uses: ./.github/actions/install-playwright
158135

159136
- name: Run E2E test
160137
working-directory: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}

.github/workflows/flaky-test-detector.yml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,8 @@ jobs:
4949
- name: Build packages
5050
run: yarn build
5151

52-
- name: Get npm cache directory
53-
id: npm-cache-dir
54-
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
55-
- name: Get Playwright version
56-
id: playwright-version
57-
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
58-
- uses: actions/cache@v4
59-
name: Check if Playwright browser is cached
60-
id: playwright-cache
61-
with:
62-
path: ${{ steps.npm-cache-dir.outputs.dir }}
63-
key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}}
64-
- name: Install Playwright browser if not cached
65-
if: steps.playwright-cache.outputs.cache-hit != 'true'
66-
run: npx playwright install --with-deps
67-
env:
68-
PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}}
69-
- name: Install OS dependencies of Playwright if cache hit
70-
if: steps.playwright-cache.outputs.cache-hit == 'true'
71-
run: npx playwright install-deps
52+
- name: Install playwright
53+
uses: ./.github/actions/install-playwright
7254

7355
- name: Determine changed tests
7456
uses: dorny/paths-filter@v3.0.1

0 commit comments

Comments
 (0)