updating ci workflow #16
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |