Skip to content

Commit 67ccbec

Browse files
committed
job order
1 parent 4a342ce commit 67ccbec

1 file changed

Lines changed: 59 additions & 82 deletions

File tree

.github/workflows/pr-quality.yml

Lines changed: 59 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,30 @@ on:
1212

1313
env:
1414
FORCE_COLOR: 1
15-
# Global cache location for all jobs
15+
# The script will use this path if you update it to respect the env var,
16+
# otherwise it installs to the default location.
17+
# For the script provided earlier, it uses 'pnpm exec playwright install'
18+
# which defaults to ~/.cache/ms-playwright.
1619
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.cache/ms-playwright
1720

1821
jobs:
1922
# ===========================================================================
2023
# JOB 1: INFRASTRUCTURE & BUILD
21-
# Checks: Linting, Typos, Build Compilation, Commit Messages
24+
# Checks: Linting, Typos, Build Compilation (handled by setup.sh)
2225
# ===========================================================================
2326
infra-check:
2427
name: 🏗️ Infra & Build
2528
runs-on: self-hosted
26-
timeout-minutes: 10
29+
timeout-minutes: 15
2730
steps:
2831
- name: Checkout
2932
uses: actions/checkout@v4
30-
with:
31-
# FIXED: using block style to avoid YAML syntax error
32-
ref: ${{ inputs.branch || github.ref }}
33-
fetch-depth: 0
34-
clean: true
33+
with: { ref: ${{ inputs.branch || github.ref }}, fetch-depth: 0, clean: true }
3534

36-
# --- REPEATED SETUP ---
35+
# --- CI OPTIMIZATION (Runs BEFORE script) ---
3736
- name: Install pnpm
3837
uses: pnpm/action-setup@v4
39-
with:
40-
run_install: false
38+
with: { run_install: false }
4139

4240
- name: Get pnpm store directory
4341
id: pnpm-cache
@@ -49,150 +47,129 @@ jobs:
4947
with:
5048
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
5149
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
52-
restore-keys: |
53-
${{ runner.os }}-pnpm-store-
50+
restore-keys: ${{ runner.os }}-pnpm-store-
5451

5552
- name: Setup Node.js
5653
uses: actions/setup-node@v4
57-
with:
58-
node-version: "20.x"
59-
cache-dependency-path: pnpm-lock.yaml
54+
with: { node-version: "20.x", cache-dependency-path: pnpm-lock.yaml }
6055

61-
- name: Configure pnpm & Install
62-
run: |
63-
pnpm config set side-effects-cache true
64-
pnpm install --frozen-lockfile --prefer-offline
56+
- name: Cache Playwright Browsers
57+
id: playwright-cache
58+
uses: actions/cache@v4
59+
with:
60+
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
61+
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
62+
restore-keys: ${{ runner.os }}-playwright-
6563
# ---------------------------------------------
6664

67-
- name: Create Runtime Envs
65+
- name: Pre-configure CI Environment
6866
run: |
67+
# We create this first so setup.sh sees it and skips generating default placeholders
6968
mkdir -p logs
7069
echo "NEXTAUTH_URL=http://127.0.0.1:3000" > .env.local
7170
echo "NEXTAUTH_SECRET=ci-secret" >> .env.local
71+
echo "SPOTIFY_CLIENT_ID=mock_id" >> .env.local
72+
echo "SPOTIFY_CLIENT_SECRET=mock_secret" >> .env.local
73+
74+
- name: Run Setup Script
75+
run: |
76+
chmod +x ./scripts/setup.sh
77+
./scripts/setup.sh
78+
# This script runs:
79+
# 1. pnpm install (fast because of cache above)
80+
# 2. playwright install (fast because of cache above)
81+
# 3. pnpm run build (verifies compilation)
7282

7383
- name: Lint Code
7484
run: pnpm run lint
7585

76-
- name: Verify Build
77-
run: pnpm run build
78-
7986
# ===========================================================================
8087
# JOB 2: CORE LOGIC TESTS
81-
# Checks: Functional tests (API, Auth, State) - Skips visuals
8288
# ===========================================================================
8389
core-tests:
8490
name: 🧪 Core Logic
91+
needs: infra-check
8592
runs-on: self-hosted
8693
timeout-minutes: 15
8794
steps:
88-
- name: Checkout
89-
uses: actions/checkout@v4
90-
with:
91-
# FIXED: using block style
92-
ref: ${{ inputs.branch || github.ref }}
93-
clean: true
95+
- uses: actions/checkout@v4
96+
with: { ref: ${{ inputs.branch || github.ref }}, clean: true }
9497

95-
# --- REPEATED SETUP ---
98+
# --- CI OPTIMIZATION ---
9699
- uses: pnpm/action-setup@v4
97-
with:
98-
run_install: false
99-
100+
with: { run_install: false }
100101
- id: pnpm-cache
101102
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
102-
103103
- uses: actions/cache@v4
104104
with:
105105
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
106106
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
107107
restore-keys: ${{ runner.os }}-pnpm-store-
108-
109108
- uses: actions/setup-node@v4
110-
with:
111-
node-version: "20.x"
112-
cache-dependency-path: pnpm-lock.yaml
113-
114-
- name: Cache Browsers
109+
with: { node-version: "20.x", cache-dependency-path: pnpm-lock.yaml }
110+
- uses: actions/cache@v4
115111
id: playwright-cache
116-
uses: actions/cache@v4
117112
with:
118113
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
119114
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
120115
restore-keys: ${{ runner.os }}-playwright-
116+
# -----------------------
121117

122-
- run: |
123-
pnpm config set side-effects-cache true
124-
pnpm install --frozen-lockfile --prefer-offline
125-
126-
- name: Install Playwright (Binary Only)
127-
if: steps.playwright-cache.outputs.cache-hit != 'true'
128-
run: pnpm exec playwright install chromium
129-
# ----------------------
130-
131-
- name: Create Runtime Envs
118+
- name: Pre-configure CI Environment
132119
run: |
133120
echo "NEXTAUTH_URL=http://127.0.0.1:3000" > .env.local
134121
echo "NEXTAUTH_SECRET=ci-secret" >> .env.local
135122
123+
- name: Run Setup Script
124+
run: |
125+
chmod +x ./scripts/setup.sh
126+
./scripts/setup.sh
127+
136128
- name: Run Core Tests (Skip Visuals)
137129
run: pnpm exec playwright test --project=chromium --grep-invert "@visual"
138130

139131
# ===========================================================================
140132
# JOB 3: VISUAL REGRESSION TESTS
141-
# Checks: Screenshot comparisons
142133
# ===========================================================================
143134
visual-tests:
144135
name: 🎨 Visual Regression
136+
needs: core-tests
145137
runs-on: self-hosted
146138
timeout-minutes: 15
147139
steps:
148-
- name: Checkout
149-
uses: actions/checkout@v4
150-
with:
151-
# FIXED: using block style
152-
ref: ${{ inputs.branch || github.ref }}
153-
clean: true
140+
- uses: actions/checkout@v4
141+
with: { ref: ${{ inputs.branch || github.ref }}, clean: true }
154142

155-
# --- REPEATED SETUP ---
143+
# --- CI OPTIMIZATION ---
156144
- uses: pnpm/action-setup@v4
157-
with:
158-
run_install: false
159-
145+
with: { run_install: false }
160146
- id: pnpm-cache
161147
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
162-
163148
- uses: actions/cache@v4
164149
with:
165150
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
166151
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
167152
restore-keys: ${{ runner.os }}-pnpm-store-
168-
169153
- uses: actions/setup-node@v4
170-
with:
171-
node-version: "20.x"
172-
cache-dependency-path: pnpm-lock.yaml
173-
174-
- name: Cache Browsers
154+
with: { node-version: "20.x", cache-dependency-path: pnpm-lock.yaml }
155+
- uses: actions/cache@v4
175156
id: playwright-cache
176-
uses: actions/cache@v4
177157
with:
178158
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
179159
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
180160
restore-keys: ${{ runner.os }}-playwright-
161+
# -----------------------
181162

182-
- run: |
183-
pnpm config set side-effects-cache true
184-
pnpm install --frozen-lockfile --prefer-offline
185-
186-
- name: Install Playwright (Binary Only)
187-
if: steps.playwright-cache.outputs.cache-hit != 'true'
188-
run: pnpm exec playwright install chromium
189-
# ----------------------
190-
191-
- name: Create Runtime Envs
163+
- name: Pre-configure CI Environment
192164
run: |
193165
echo "NEXTAUTH_URL=http://127.0.0.1:3000" > .env.local
194166
echo "NEXTAUTH_SECRET=ci-secret" >> .env.local
195167
168+
- name: Run Setup Script
169+
run: |
170+
chmod +x ./scripts/setup.sh
171+
./scripts/setup.sh
172+
196173
- name: Run Visual Tests
197174
run: pnpm exec playwright test --project=chromium --grep "@visual"
198175

0 commit comments

Comments
 (0)