-
Notifications
You must be signed in to change notification settings - Fork 7
116 lines (99 loc) · 3.73 KB
/
Copy pathpr-quality.yml
File metadata and controls
116 lines (99 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: PR Quality Gate
on:
pull_request:
branches: [ "leader" ]
workflow_dispatch:
inputs:
branch:
description: 'Branch to check'
required: true
default: 'leader'
jobs:
quality-gate:
runs-on: self-hosted
timeout-minutes: 20
env:
FORCE_COLOR: 1
# Recommended for caching consistency
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.cache/ms-playwright
steps:
- name: Checkout & Prep
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
fetch-depth: 0
clean: true
# 1. Setup pnpm (Package Manager)
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
# Version inferred from package.json "packageManager"
run_install: false
# 2. Setup Node.js with Dependency Caching
# 'cache: pnpm' automatically caches the pnpm store based on pnpm-lock.yaml
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache-dependency-path: pnpm-lock.yaml
cache: "pnpm"
# 3. Cache Next.js Build
# Caches the .next/cache folder to speed up 'pnpm run build'
- name: Cache Next.js
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
# 4. Cache Playwright Browsers
# Caches the large browser binaries to avoid downloading them every run
- name: Cache Playwright Browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Create Runtime Directories
run: |
mkdir -p logs
echo "✅ Created 'logs' directory"
- name: Configure .env.local
run: |
echo "📝 Creating .env.local with development defaults..."
cat > .env.local <<EOL
NEXTAUTH_URL=http://127.0.0.1:3000
NEXTAUTH_SECRET=jules-dev-environment-secret-123
SPOTIFY_CLIENT_ID=placeholder_id
SPOTIFY_CLIENT_SECRET=placeholder_secret
EOL
- name: Install Dependencies
run: pnpm install --frozen-lockfile
# 5. Install Playwright (Conditional)
# Only runs if cache missed. '--with-deps' ensures OS-level libs are present.
- name: Install Playwright Browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install chromium --with-deps
# 6. Install OS Dependencies (Always Needed)
# Even if binaries are cached, system libs might be missing on clean runners.
- name: Install Playwright OS Deps
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: pnpm exec playwright install-deps chromium
- name: Lint Code
run: pnpm run lint
- name: Verify Build
run: pnpm run build
- name: Lint commit messages
run: |
echo "🔍 Verifying Conventional Commits..."
RANGE="origin/leader..HEAD"
if ! git rev-parse --verify origin/leader >/dev/null 2>&1; then RANGE="HEAD"; fi
git log --format=%s $RANGE | while read line; do
if [[ ! "$line" =~ ^(feat|fix|docs|style|refactor|test|chore|perf|ci)(\(.+\))?: ]]; then
echo "::error::Invalid Commit Message: $line"
exit 1
fi
done