Skip to content

Commit 4ff1295

Browse files
committed
improve order
1 parent 1e40e44 commit 4ff1295

1 file changed

Lines changed: 75 additions & 68 deletions

File tree

.github/workflows/pr-quality.yml

Lines changed: 75 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ env:
1616

1717
jobs:
1818
# ===========================================================================
19-
# JOB 1: INFRASTRUCTURE & BUILD
20-
# Checks: Linting, Typos, Build Compilation
19+
# JOB 1: INFRASTRUCTURE SETUP (Cache Warmer)
20+
# Installs dependencies & browsers so they are cached for subsequent jobs.
2121
# ===========================================================================
22-
infra-check:
23-
name: 🏗️ Infra & Build
22+
infra-setup:
23+
name: 🏗️ Infra Setup
2424
runs-on: self-hosted
2525
timeout-minutes: 10
2626
steps:
@@ -31,7 +31,7 @@ jobs:
3131
fetch-depth: 0
3232
clean: true
3333

34-
# --- CACHING SETUP ---
34+
# --- SETUP & CACHING ---
3535
- name: Install pnpm
3636
uses: pnpm/action-setup@v4
3737
with:
@@ -56,151 +56,158 @@ jobs:
5656
node-version: "20.x"
5757
cache-dependency-path: pnpm-lock.yaml
5858

59+
- name: Cache Playwright Browsers
60+
id: playwright-cache
61+
uses: actions/cache@v4
62+
with:
63+
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
64+
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
65+
restore-keys: ${{ runner.os }}-playwright-
66+
# -----------------------
67+
5968
- name: Configure pnpm settings
6069
run: pnpm config set side-effects-cache true
61-
# ---------------------
62-
63-
- name: Create Runtime Envs
64-
# Created BEFORE setup.sh so the script skips overwriting it
65-
run: |
66-
mkdir -p logs
67-
echo "NEXTAUTH_URL=http://127.0.0.1:3000" > .env.local
68-
echo "NEXTAUTH_SECRET=ci-secret" >> .env.local
6970

7071
- name: Run Setup Script
7172
run: |
7273
chmod +x ./scripts/setup.sh
7374
./scripts/setup.sh
74-
# Handles 'pnpm install' using the cache we restored above
75-
76-
- name: Lint Code
77-
run: pnpm run lint
75+
# Handles pnpm install and .env.local creation
7876

79-
- name: Verify Build
80-
run: pnpm run build
77+
- name: Install Playwright (Binary Only)
78+
if: steps.playwright-cache.outputs.cache-hit != 'true'
79+
run: pnpm exec playwright install chromium
8180

8281
# ===========================================================================
83-
# JOB 2: CORE LOGIC TESTS
84-
# Checks: Functional tests (API, Auth, State) - Skips visuals
85-
# DEPENDS ON: infra-check
82+
# JOB 2: QUALITY CHECKS & CORE TESTS
83+
# Runs Lint, Build, and Functional Logic Tests
84+
# DEPENDS ON: infra-setup
8685
# ===========================================================================
87-
core-tests:
88-
name: 🧪 Core Logic
89-
needs: infra-check
86+
quality-and-core:
87+
name: 🛡️ Quality & Core
88+
needs: infra-setup
9089
runs-on: self-hosted
9190
timeout-minutes: 15
9291
steps:
9392
- name: Checkout
9493
uses: actions/checkout@v4
9594
with:
9695
ref: ${{ inputs.branch || github.ref }}
96+
fetch-depth: 0
9797
clean: true
9898

99-
# --- CACHING SETUP ---
100-
- uses: pnpm/action-setup@v4
99+
# --- RESTORE CACHE ---
100+
- name: Install pnpm
101+
uses: pnpm/action-setup@v4
101102
with:
102103
run_install: false
103-
104-
- id: pnpm-cache
104+
105+
- name: Get pnpm store directory
106+
id: pnpm-cache
107+
shell: bash
105108
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
106-
107-
- uses: actions/cache@v4
109+
110+
- name: Setup pnpm cache
111+
uses: actions/cache@v4
108112
with:
109113
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
110114
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
111-
restore-keys: ${{ runner.os }}-pnpm-store-
112-
113-
- uses: actions/setup-node@v4
115+
restore-keys: |
116+
${{ runner.os }}-pnpm-store-
117+
118+
- name: Setup Node.js
119+
uses: actions/setup-node@v4
114120
with:
115121
node-version: "20.x"
116122
cache-dependency-path: pnpm-lock.yaml
117-
118-
- name: Cache Browsers
123+
124+
- name: Cache Playwright Browsers
119125
id: playwright-cache
120126
uses: actions/cache@v4
121127
with:
122128
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
123129
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
124130
restore-keys: ${{ runner.os }}-playwright-
125-
126-
- run: pnpm config set side-effects-cache true
127131
# ---------------------
128132

129-
- name: Create Runtime Envs
130-
run: |
131-
echo "NEXTAUTH_URL=http://127.0.0.1:3000" > .env.local
132-
echo "NEXTAUTH_SECRET=ci-secret" >> .env.local
133-
134-
- name: Run Setup Script
133+
- name: Fast Install (Restore from Cache)
135134
run: |
135+
pnpm config set side-effects-cache true
136136
chmod +x ./scripts/setup.sh
137137
./scripts/setup.sh
138138
139-
- name: Install Playwright (Binary Only)
139+
- name: Ensure Browsers Present
140140
if: steps.playwright-cache.outputs.cache-hit != 'true'
141141
run: pnpm exec playwright install chromium
142142

143+
- name: Lint Code
144+
run: pnpm run lint
145+
146+
- name: Verify Build
147+
run: pnpm run build
148+
143149
- name: Run Core Tests (Skip Visuals)
144150
run: pnpm exec playwright test --project=chromium --grep-invert "@visual"
145151

146152
# ===========================================================================
147153
# JOB 3: VISUAL REGRESSION TESTS
148-
# Checks: Screenshot comparisons
149-
# DEPENDS ON: core-tests
154+
# Runs Screenshot Comparisons
155+
# DEPENDS ON: quality-and-core
150156
# ===========================================================================
151157
visual-tests:
152158
name: 🎨 Visual Regression
153-
needs: core-tests
159+
needs: quality-and-core
154160
runs-on: self-hosted
155161
timeout-minutes: 15
156162
steps:
157163
- name: Checkout
158164
uses: actions/checkout@v4
159165
with:
160166
ref: ${{ inputs.branch || github.ref }}
167+
fetch-depth: 0
161168
clean: true
162169

163-
# --- CACHING SETUP ---
164-
- uses: pnpm/action-setup@v4
170+
# --- RESTORE CACHE ---
171+
- name: Install pnpm
172+
uses: pnpm/action-setup@v4
165173
with:
166174
run_install: false
167-
168-
- id: pnpm-cache
175+
176+
- name: Get pnpm store directory
177+
id: pnpm-cache
178+
shell: bash
169179
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
170-
171-
- uses: actions/cache@v4
180+
181+
- name: Setup pnpm cache
182+
uses: actions/cache@v4
172183
with:
173184
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
174185
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
175-
restore-keys: ${{ runner.os }}-pnpm-store-
176-
177-
- uses: actions/setup-node@v4
186+
restore-keys: |
187+
${{ runner.os }}-pnpm-store-
188+
189+
- name: Setup Node.js
190+
uses: actions/setup-node@v4
178191
with:
179192
node-version: "20.x"
180193
cache-dependency-path: pnpm-lock.yaml
181-
182-
- name: Cache Browsers
194+
195+
- name: Cache Playwright Browsers
183196
id: playwright-cache
184197
uses: actions/cache@v4
185198
with:
186199
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
187200
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
188201
restore-keys: ${{ runner.os }}-playwright-
189-
190-
- run: pnpm config set side-effects-cache true
191202
# ---------------------
192203

193-
- name: Create Runtime Envs
194-
run: |
195-
echo "NEXTAUTH_URL=http://127.0.0.1:3000" > .env.local
196-
echo "NEXTAUTH_SECRET=ci-secret" >> .env.local
197-
198-
- name: Run Setup Script
204+
- name: Fast Install (Restore from Cache)
199205
run: |
206+
pnpm config set side-effects-cache true
200207
chmod +x ./scripts/setup.sh
201208
./scripts/setup.sh
202209
203-
- name: Install Playwright (Binary Only)
210+
- name: Ensure Browsers Present
204211
if: steps.playwright-cache.outputs.cache-hit != 'true'
205212
run: pnpm exec playwright install chromium
206213

0 commit comments

Comments
 (0)