Skip to content

Commit 5be9352

Browse files
authored
feat: Make optimization happen (#510)
Integrates optimization updates for build and test: * Consolidates testing into a single playwright.yml * Removes old e2e.yml * Removes unused example.spec.ts * Updates playwright.yml to contain all testing functionality, and to test only changed projects. * feat: Update release.yml * TEMPORARILY replaces deployment command with staging deploy command (that way we don't break prod) ln. 100
1 parent 540a033 commit 5be9352

File tree

4 files changed

+152
-168
lines changed

4 files changed

+152
-168
lines changed

.github/workflows/e2e.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

.github/workflows/playwright.yml

Lines changed: 146 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Copyright 2025 Google LLC
32
#
43
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,37 +12,168 @@
1312
# See the License for the specific language governing permissions and
1413
# limitations under the License.
1514

16-
name: Test
15+
name: Playwright Tests
16+
1717
on:
18-
push:
19-
branches: [ main ]
2018
pull_request:
21-
branches: [ main ]
19+
branches:
20+
- main
2221
types: [opened, synchronize, edited]
2322
paths:
2423
- 'samples/**'
24+
- 'e2e/samples.spec.ts'
25+
- 'playwright.config.ts'
26+
- 'package.json'
27+
paths-ignore:
28+
- '.github/dependabot.yml'
29+
- 'package-lock.json'
30+
push:
31+
branches:
32+
- main
33+
paths:
34+
- 'samples/**'
35+
- 'e2e/samples.spec.ts'
36+
- 'playwright.config.ts'
37+
- 'package.json'
38+
paths-ignore:
39+
- '.github/dependabot.yml'
40+
- 'package-lock.json'
41+
schedule:
42+
- cron: "0 12 * * *"
43+
2544
concurrency:
26-
group: test-${{ github.ref }}
45+
group: ${{ github.workflow }}-${{ github.ref }}
2746
cancel-in-progress: true
47+
2848
jobs:
29-
test:
30-
if: github.event.pull_request.merged == false
49+
pr_and_push_tests:
50+
name: Playwright PR/Push Tests
51+
if: |
52+
(github.event_name == 'pull_request' && github.event.pull_request.merged == false) ||
53+
(github.event_name == 'push' && !contains(github.event.head_commit.message, 'chore: update dist folder'))
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
with:
58+
lfs: true
59+
60+
- name: Get Affected Workspaces
61+
id: get_workspaces
62+
run: bash samples/find-changes.sh ${{ github.event_name == 'pull_request' && github.base_ref || 'origin/main' }}
63+
64+
- name: Setup Node.js
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: '20'
68+
69+
- name: Cache npm dependencies
70+
uses: actions/cache@v4
71+
with:
72+
path: ~/.npm
73+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
74+
restore-keys: |
75+
${{ runner.os }}-node-
76+
77+
- name: Cache Playwright browsers
78+
uses: actions/cache@v4
79+
with:
80+
path: ~/.cache/ms-playwright
81+
key: ${{ runner.os }}-playwright-${{ hashFiles('playwright.config.ts', 'package.json') }}
82+
restore-keys: |
83+
${{ runner.os }}-playwright-
84+
85+
- name: Install dependencies
86+
run: npm ci
87+
88+
- name: Build Affected Projects
89+
if: steps.get_workspaces.outputs.affected_workspaces != ''
90+
run: |
91+
IFS=$'\n'
92+
AFFECTED_WORKSPACES_ARRAY=(${{ steps.get_workspaces.outputs.affected_workspaces }})
93+
94+
echo "Building affected workspaces:"
95+
for workspace in "${AFFECTED_WORKSPACES_ARRAY[@]}"; do
96+
echo " - samples/$workspace"
97+
npm run build --workspace=samples/$workspace
98+
done
99+
100+
- name: Generate Index (Run Once After Builds)
101+
run: bash samples/generate-index.sh
102+
# Consider adding an 'if' condition if it only needs to run when 'samples/' changed at all.
103+
# if: |
104+
# steps.get_workspaces.outputs.affected_workspaces != '' || # If any workspace built
105+
# contains(github.event.pull_request.paths.*, 'samples/generate-index.sh') # Or if the script itself changed
106+
107+
- name: Install Playwright browsers and system dependencies
108+
run: |
109+
npx playwright install-deps
110+
npx playwright install
111+
112+
- name: Run All Playwright Tests
113+
run: npx playwright test e2e/samples.spec.ts
114+
env:
115+
CI: true
116+
117+
- name: Upload Test Report Artifact
118+
uses: actions/upload-artifact@v4
119+
if: failure()
120+
with:
121+
name: Test Results
122+
path: test-results/
123+
124+
scheduled_full_test:
125+
name: Scheduled Full E2E Tests
126+
if: github.event_name == 'schedule'
31127
runs-on: ubuntu-latest
32128
steps:
33129
- uses: actions/checkout@v4
34-
if: github.actor != 'dependabot[bot]'
35-
- uses: actions/cache@v4
130+
with:
131+
lfs: true
132+
133+
- name: Setup Node.js
134+
uses: actions/setup-node@v4
135+
with:
136+
node-version: '20'
137+
138+
- name: Cache npm dependencies
139+
uses: actions/cache@v4
36140
with:
37141
path: ~/.npm
38142
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
39143
restore-keys: |
40-
${{ runner.os }}-node
41-
- uses: actions/cache@v4 # Cache Playwright browsers
144+
${{ runner.os }}-node-
145+
146+
- name: Cache Playwright browsers
147+
uses: actions/cache@v4
42148
with:
43149
path: ~/.cache/ms-playwright
44-
key: ${{ runner.os }}-playwright-${{ hashFiles('playwright.config.ts', 'package.json') }} # Cache key based on config files
150+
key: ${{ runner.os }}-playwright-${{ hashFiles('playwright.config.ts', 'package.json') }}
45151
restore-keys: |
46152
${{ runner.os }}-playwright-
47-
- run: npm i
48-
- run: npx playwright install
49-
- run: npx playwright test
153+
154+
- name: Install dependencies
155+
run: npm ci
156+
157+
- name: Build All Projects
158+
run: npm run build-all
159+
160+
- name: Generate Index (Run Once After Full Builds)
161+
run: bash generate-index.sh
162+
163+
- name: Install Playwright system dependencies
164+
run: npx playwright install-deps
165+
166+
- name: Install Playwright browsers
167+
run: npx playwright install
168+
169+
- name: Run Full E2E Tests (Scheduled)
170+
run: npx playwright test e2e/samples.spec.ts
171+
env:
172+
CI: true
173+
174+
- name: Upload Test Report Artifact
175+
uses: actions/upload-artifact@v4
176+
if: failure()
177+
with:
178+
name: Test Results
179+
path: test-results/

.github/workflows/release.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ jobs:
6868
echo "Building affected workspaces:"
6969
for workspace in "${AFFECTED_WORKSPACES_ARRAY[@]}"; do
7070
echo " - samples/$workspace"
71-
71+
(cd samples/ && npm run build --workspace=$workspace)
7272
done
7373
74-
- run: npm run build-all
75-
7674
- name: Get Deleted Workspaces
7775
id: get_deleted
7876
run: bash samples/find-deleted-subfolders.sh ${{ github.event.before }}
@@ -85,7 +83,11 @@ jobs:
8583
echo: "Removing deleted project output:"
8684
for workspace in "${DELETED_WORKSPACES_ARRAY[@]}"; do
8785
echo " - samples/$workspace"
86+
rm -rf dist/samples/$workspace
8887
done
88+
89+
- name: Generate Index
90+
run: bash samples/generate-index.sh
8991

9092
- uses: google-github-actions/auth@v1
9193
with:
@@ -95,7 +97,7 @@ jobs:
9597
run: npm install -g firebase-tools
9698

9799
- name: Deploy to Firebase Hosting
98-
run: firebase deploy --only hosting
100+
run: firebase hosting:channel:deploy staging-preview
99101

100102
- name: Create temporary branch
101103
run: git checkout -b temp-build-branch

e2e/example.spec.ts

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)