Skip to content

Commit 6de269c

Browse files
authored
fix: Tweaks playwright.yml (#548)
1 parent 55f2add commit 6de269c

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

.github/workflows/playwright.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ jobs:
5454

5555
- name: Get Affected Workspaces
5656
id: get_workspaces
57-
run: bash samples/find-changes.sh ${{ github.event_name == 'pull_request' && github.base_ref || 'origin/main' }}
57+
# For PRs, compare against the origin's version of the base branch.
58+
# For pushes, compare against the commit before the push.
59+
run: bash samples/find-changes.sh ${{ github.event_name == 'pull_request' && format('origin/{0}', github.base_ref) || github.event.before }}
5860

5961
- name: Setup Node.js
6062
uses: actions/setup-node@v4
@@ -72,10 +74,11 @@ jobs:
7274
- name: Cache Playwright browsers
7375
uses: actions/cache@v4
7476
with:
75-
path: ~/.cache/ms-playwright
76-
key: ${{ runner.os }}-playwright-${{ hashFiles('playwright.config.ts', 'package.json') }}
77+
path: ~/.cache/ms-playwright # Default Playwright cache path
78+
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('playwright.config.ts') }}
7779
restore-keys: |
78-
${{ runner.os }}-playwright-
80+
${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}- # Fallback for lock file changes
81+
${{ runner.os }}-playwright- # Broader fallback
7982
8083
- name: Install dependencies
8184
run: npm ci
@@ -107,8 +110,8 @@ jobs:
107110
- name: Run All Playwright Tests
108111
run: npx playwright test e2e/samples.spec.ts
109112
env:
110-
# Pass the correct base reference for find-changes.sh
111-
GIT_BASE_REF: ${{ github.event_name == 'pull_request' && github.base_ref || 'origin/main' }}
113+
# Pass the correct base reference for find-changes.sh when called by samples.spec.ts
114+
GIT_BASE_REF: ${{ github.event_name == 'pull_request' && format('origin/{0}', github.base_ref) || github.event.before }}
112115
CI: true
113116

114117
- name: Upload Test Report Artifact
@@ -143,10 +146,11 @@ jobs:
143146
- name: Cache Playwright browsers
144147
uses: actions/cache@v4
145148
with:
146-
path: ~/.cache/ms-playwright
147-
key: ${{ runner.os }}-playwright-${{ hashFiles('playwright.config.ts', 'package.json') }}
149+
path: ~/.cache/ms-playwright # Default Playwright cache path
150+
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('playwright.config.ts') }}
148151
restore-keys: |
149-
${{ runner.os }}-playwright-
152+
${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}- # Fallback for lock file changes
153+
${{ runner.os }}-playwright- # Broader fallback
150154
151155
- name: Install dependencies
152156
run: npm ci

0 commit comments

Comments
 (0)