Skip to content

Commit 5425300

Browse files
committed
updating ci workflow
1 parent dfd3eef commit 5425300

3 files changed

Lines changed: 113 additions & 99 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ name: CI/CD Pipeline
22

33
on:
44
push:
5-
branches: [leader, main]
5+
branches: [leader]
66
pull_request:
7-
branches: [leader, main]
7+
branches: [leader]
88

99
jobs:
1010
# 1. Fast, parallel validation for linting and unit tests
1111
unit_tests:
12-
runs-on: ubuntu-latest # 2-core runner is sufficient for fast tests
12+
runs-on: self-hosted# 2-core runner is sufficient for fast tests
1313
strategy:
1414
matrix:
1515
node-version: [18.x, 20.x]
@@ -48,7 +48,7 @@ jobs:
4848
needs: [unit_tests]
4949
# For self-hosted or larger runners, specify here:
5050
# runs-on: self-hosted-8core
51-
runs-on: ubuntu-latest # Consider upgrading this to ubuntu-latest-8-cores for speed
51+
runs-on: self-hosted # Consider upgrading this to ubuntu-latest-8-cores for speed
5252

5353
# We only need the latest, validated Node version here.
5454
steps:
@@ -113,7 +113,7 @@ jobs:
113113
114114
# 3. Security remains separate
115115
security:
116-
runs-on: ubuntu-latest
116+
runs-on: self-hosted
117117
steps:
118118
- name: Checkout code
119119
uses: actions/checkout@v4
@@ -150,4 +150,4 @@ jobs:
150150
# path: .
151151

152152
# - name: Deploy Notification
153-
# run: echo "Deployment would happen here, using the downloaded build artifact."
153+
# run: echo "Deployment would happen here, using the downloaded build artifact."

.github/workflows/pr-quality.yml

Lines changed: 107 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,116 @@
11
name: PR Quality Gate
22

33
on:
4+
pull_request:
5+
branches: [ "leader" ]
46
workflow_dispatch:
7+
inputs:
8+
branch:
9+
description: 'Branch to check'
10+
required: true
11+
default: 'leader'
512

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

.github/workflows/security-scan.yml

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

0 commit comments

Comments
 (0)