feat: complete SonarLint for VSCode integration to 100% #4
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
# ═══════════════════════════════════════════════════════════════════════════ | |
# AUTOMATED BUILD WORKFLOW | |
# ═══════════════════════════════════════════════════════════════════════════ | |
# | |
# Purpose: Provides comprehensive CI validation for pull requests to ensure | |
# code quality and prevent regressions before merging to main. | |
# | |
# Triggers: | |
# - Pull requests targeting the main branch | |
# | |
# Key Features: | |
# - Full monorepo build validation using pnpm | |
# - Environment setup with test credentials | |
# - Bundle size analysis with artifact upload | |
# - Test suite execution | |
# - Configurable linting and type checking (currently disabled) | |
# | |
# DX Benefits: | |
# - Early detection of build failures | |
# - Bundle size monitoring to prevent performance regressions | |
# - Consistent test environment across all PRs | |
# - Artifact preservation for debugging build issues | |
# ═══════════════════════════════════════════════════════════════════════════ | |
name: Build | |
on: | |
push: | |
branches: | |
- develop | |
pull_request: | |
branches: [main] | |
jobs: | |
# Main build job that validates the entire monorepo | |
# This job ensures the codebase builds correctly, passes tests, and meets quality standards | |
# It serves as a quality gate before code can be merged to the main branch | |
build: | |
runs-on: ubuntu-latest | |
# Skip CI execution when commit messages contain 'ci skip' or 'skip ci' | |
# This allows for documentation-only changes to bypass the build process | |
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')" | |
steps: | |
# Step 1: Check out the repository code with full history | |
# This step clones the repository code to the GitHub Actions runner | |
# We set fetch-depth: 0 to get the complete history for versioning tools | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for all branches and tags | |
# Step 2: Fetch tags for versioning | |
# This ensures all tags are available for versioning tools | |
- name: Prepare repository | |
run: git fetch --tags | |
# Step 3: Set up pnpm package manager | |
# Using pnpm for faster, more efficient dependency management in the monorepo | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
run_install: false # We'll install dependencies after caching | |
# Step 4: Set up Node.js environment with caching | |
# Using Node.js 20 for modern features and performance | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm # Enable built-in caching for pnpm | |
# Step 5: Configure pnpm store path for caching | |
# This improves build performance by reusing the pnpm store across runs | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
# Step 6: Set up caching for pnpm dependencies | |
# This significantly speeds up builds by reusing previously downloaded packages | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
# Step 7: Install all project dependencies | |
# Using pnpm for efficient installation in the monorepo structure | |
- name: Install dependencies | |
run: pnpm install | |
# Step 8: Create environment configuration for the app | |
# Sets up mock environment variables for CI testing | |
# These values are non-sensitive placeholders for third-party services | |
- name: Create .env.local file | |
run: | | |
touch apps/app/.env.local | |
# Authentication configuration (Clerk) | |
echo "CLERK_SECRET_KEY=sk_test_JA==" >> apps/app/.env.local | |
echo "CLERK_WEBHOOK_SECRET=whsec_test" >> apps/app/.env.local | |
echo "NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_JA==" >> apps/app/.env.local | |
echo "NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in" >> apps/app/.env.local | |
echo "NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up" >> apps/app/.env.local | |
echo "NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/" >> apps/app/.env.local | |
echo "NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/" >> apps/app/.env.local | |
# Email service (Resend) | |
echo "RESEND_FROM=test@test.com" >> apps/app/.env.local | |
echo "RESEND_TOKEN=re_test" >> apps/app/.env.local | |
# Database connection | |
echo "DATABASE_URL=postgresql://test:test@localhost:5432/test" >> apps/app/.env.local | |
# Payment processing (Stripe) | |
echo "STRIPE_SECRET_KEY=sk_test" >> apps/app/.env.local | |
echo "STRIPE_WEBHOOK_SECRET=whsec_test" >> apps/app/.env.local | |
# Monitoring and observability | |
echo "BETTERSTACK_API_KEY=test" >> apps/app/.env.local | |
echo "BETTERSTACK_URL=https://test.com" >> apps/app/.env.local | |
# Feature flags | |
echo "FLAGS_SECRET=FcnUGt7tT-4cOw-D_1GoXAH1bU7ljDBr01F5w4dxrdQ" >> apps/app/.env.local | |
# Security and API services | |
echo "ARCJET_KEY=ajkey_test" >> apps/app/.env.local | |
echo "SVIX_TOKEN=testsk_test" >> apps/app/.env.local | |
echo "LIVEBLOCKS_SECRET=sk_test" >> apps/app/.env.local | |
# CMS integration (using actual token from secrets) | |
echo "BASEHUB_TOKEN=${{ secrets.BASEHUB_TOKEN }}" >> apps/app/.env.local | |
# Deployment URLs | |
echo "VERCEL_PROJECT_PRODUCTION_URL=http://localhost:3002" >> apps/app/.env.local | |
# Notifications (Knock) | |
echo "KNOCK_API_KEY=test" >> apps/app/.env.local | |
echo "KNOCK_FEED_CHANNEL_ID=test" >> apps/app/.env.local | |
# Analytics configuration | |
echo "NEXT_PUBLIC_GA_MEASUREMENT_ID=G-test" >> apps/app/.env.local | |
echo "NEXT_PUBLIC_POSTHOG_KEY=phc_test" >> apps/app/.env.local | |
echo "NEXT_PUBLIC_POSTHOG_HOST=https://test.com" >> apps/app/.env.local | |
# Application URLs for cross-service communication | |
echo "NEXT_PUBLIC_APP_URL=http://localhost:3000" >> apps/app/.env.local | |
echo "NEXT_PUBLIC_WEB_URL=http://localhost:3001" >> apps/app/.env.local | |
echo "NEXT_PUBLIC_DOCS_URL=http://localhost:3004" >> apps/app/.env.local | |
# Step 9: Copy environment configuration to other apps | |
# Ensures consistent environment across all applications in the monorepo | |
- name: Copy .env.local file | |
run: | | |
cp apps/app/.env.local apps/web/.env.local | |
cp apps/app/.env.local apps/api/.env.local | |
# Step 10: Create database-specific environment file | |
# Required for the database package to connect to the test database | |
- name: Create specific Database .env file | |
run: | | |
touch packages/database/.env | |
echo "DATABASE_URL=postgresql://test:test@localhost:5432/test" >> packages/database/.env | |
# Step 11: Create CMS-specific environment file | |
# Required for the CMS package to connect to BaseHub | |
- name: Create specific CMS .env file | |
run: | | |
touch packages/cms/.env.local | |
echo "BASEHUB_TOKEN=${{ secrets.BASEHUB_TOKEN }}" >> packages/cms/.env.local | |
# Step 12: Build the project with bundle analysis enabled | |
# This generates bundle size reports for performance monitoring | |
- name: Build with bundle analysis | |
run: pnpm analyze | |
# Step 13: Upload bundle analysis reports as artifacts | |
# These HTML reports can be downloaded to analyze bundle sizes | |
# and identify optimization opportunities | |
- name: Upload bundle analysis artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bundle-analysis | |
path: apps/**/.next/analyze/*.html |