Skip to content

Commit d41348b

Browse files
committed
use pnpm
1 parent 5bde60f commit d41348b

1 file changed

Lines changed: 86 additions & 40 deletions

File tree

.github/workflows/pr-quality.yml

Lines changed: 86 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,101 @@
11
name: PR Quality Gate
22

3-
# 🔒 SECURITY: Use manual trigger only for self-hosted runners
4-
# This prevents forks from automatically running code on your machine
53
on:
4+
pull_request:
5+
branches: [ "leader" ]
66
workflow_dispatch:
77
inputs:
88
branch:
99
description: 'Branch to check'
1010
required: true
11-
default: 'main'
11+
default: 'leader'
1212

1313
jobs:
14-
pr-quality:
14+
quality-gate:
1515
runs-on: self-hosted
16-
16+
timeout-minutes: 20
17+
18+
env:
19+
# Force color output for better readability in CI logs
20+
FORCE_COLOR: 1
21+
1722
steps:
18-
- name: Cleanup Workspace
19-
run: rm -rf ./*
23+
# 1. Clean Checkout & Runtime Prep
24+
# Mirroring: "Create necessary runtime directories"
25+
- name: Checkout & Prep
26+
uses: actions/checkout@v4
27+
with:
28+
ref: ${{ inputs.branch || github.ref }}
29+
fetch-depth: 0
30+
clean: true
2031

21-
- name: Checkout code
22-
uses: actions/checkout@v4
23-
with:
24-
ref: ${{ inputs.branch }}
25-
fetch-depth: 0
26-
27-
- name: Setup Node.js
28-
uses: actions/setup-node@v4
29-
with:
30-
node-version: "20.x"
31-
cache: "npm"
32-
33-
- name: Install dependencies (Safe Mode)
34-
# 🛡️ SECURITY: --ignore-scripts prevents malicious postinstall scripts
35-
# from executing on your local machine.
36-
run: npm ci --ignore-scripts
37-
38-
- name: Check for large files
39-
run: |
40-
echo "🔍 Scanning for large files (>1MB)..."
41-
find . -type f -size +1M -not -path "./node_modules/*" -not -path "./.git/*" | while read file; do
42-
echo "::warning::Large file detected: $file ($(du -h "$file" | cut -f1))"
43-
done
44-
45-
- name: Lint commit messages
46-
run: |
47-
echo "🔍 Verifying Conventional Commits..."
48-
if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
49-
git log --oneline HEAD~1..HEAD | while read line; do
50-
if [[ ! "$line" =~ ^[a-f0-9]+\ (feat|fix|docs|style|refactor|test|chore|perf|ci)(\(.+\))?: ]]; then
51-
echo "::warning::Invalid Commit Message: $line"
52-
echo "::warning::Format should be: type(scope): description"
32+
- name: Create Runtime Directories
33+
run: |
34+
mkdir -p logs
35+
echo "✅ Created 'logs' directory"
36+
37+
# 2. Configure Environment
38+
# Mirroring: "Configure Environment Variables"
39+
- name: Configure .env.local
40+
run: |
41+
echo "📝 Creating .env.local with development defaults..."
42+
cat > .env.local <<EOL
43+
# Auto-generated by CI
44+
NEXTAUTH_URL=http://127.0.0.1:3000
45+
NEXTAUTH_SECRET=jules-dev-environment-secret-123
46+
SPOTIFY_CLIENT_ID=placeholder_id
47+
SPOTIFY_CLIENT_SECRET=placeholder_secret
48+
EOL
49+
echo "✅ .env.local created"
50+
51+
# 3. Install pnpm
52+
# Mirroring: "Ensure pnpm is installed"
53+
# We use the official action for better caching and stability in CI
54+
- name: Install pnpm
55+
uses: pnpm/action-setup@v4
56+
with:
57+
version: 9
58+
run_install: false
59+
60+
- name: Setup Node.js
61+
uses: actions/setup-node@v4
62+
with:
63+
node-version: "20.x"
64+
cache: "pnpm"
65+
66+
# 4. Install Dependencies
67+
# Mirroring: "Install Node.js Dependencies" (pnpm install)
68+
- name: Install Dependencies
69+
run: pnpm install --frozen-lockfile
70+
71+
# 5. Install Playwright Browsers
72+
# Mirroring: "Install Playwright Chromium binary"
73+
- name: Install Playwright (Chromium)
74+
run: pnpm exec playwright install chromium --with-deps
75+
76+
# 6. Quality Checks & Build
77+
# Mirroring: "Verify Build & Types"
78+
- name: Lint Code
79+
run: pnpm run lint
80+
81+
- name: Verify Build
82+
run: pnpm run build
83+
84+
# 7. Optional: Run Tests (As referenced in your setup script echo)
85+
# Uncomment if you want actual test execution in this gate
86+
# - name: Run Core Tests
87+
# run: pnpm run test:core
88+
89+
# 8. Commit Message Linting (Your original requirement)
90+
- name: Lint commit messages
91+
run: |
92+
echo "🔍 Verifying Conventional Commits..."
93+
RANGE="origin/leader..HEAD"
94+
if ! git rev-parse --verify origin/leader >/dev/null 2>&1; then RANGE="HEAD"; fi
95+
96+
git log --format=%s $RANGE | while read line; do
97+
if [[ ! "$line" =~ ^(feat|fix|docs|style|refactor|test|chore|perf|ci)(\(.+\))?: ]]; then
98+
echo "::error::Invalid Commit Message: $line"
99+
exit 1
53100
fi
54101
done
55-
fi

0 commit comments

Comments
 (0)