From 6465be819aee8ce7f1bf09ef1cd6343b5c2469e2 Mon Sep 17 00:00:00 2001 From: Derek Slenk Date: Fri, 18 Jul 2025 00:09:25 -0400 Subject: [PATCH] Optimize CI workflows for faster execution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Performance improvements: - Cache node_modules in addition to ~/.npm to skip dependency installation - Add TypeScript incremental compilation caching with tsBuildInfoFile - Parallelize lint and typecheck steps to run concurrently - Add performance flags: --prefer-offline, --no-audit, --no-fund for npm ci - Increase Node.js memory limit to 4GB and thread pool size - Cache build output directory for faster rebuilds - Upgrade TypeScript target to ES2020 for faster compilation - Disable Next.js telemetry to reduce overhead Expected reduction: 5+ minutes → 2-3 minutes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .forgejo/workflows/ci.yml | 40 +++++++++++++++++++++++++++-------- .forgejo/workflows/deploy.yml | 26 ++++++++++++++++++++--- tsconfig.json | 3 ++- 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 1243f0a..f0e056b 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -20,7 +20,9 @@ jobs: - name: Cache dependencies uses: actions/cache@v3 with: - path: ~/.npm + path: | + ~/.npm + node_modules key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- @@ -28,22 +30,42 @@ jobs: - name: Cache Next.js build uses: actions/cache@v3 with: - path: ${{ github.workspace }}/.next/cache + path: | + ${{ github.workspace }}/.next/cache + ${{ github.workspace }}/out key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.[jt]s', '**/*.[jt]sx') }} restore-keys: | ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- + ${{ runner.os }}-nextjs- + + - name: Cache TypeScript + uses: actions/cache@v3 + with: + path: | + tsconfig.tsbuildinfo + .next/types + key: ${{ runner.os }}-tsc-${{ hashFiles('tsconfig.json', 'src/**/*.ts', 'src/**/*.tsx') }} + restore-keys: | + ${{ runner.os }}-tsc- - name: Install dependencies - run: npm ci + run: npm ci --prefer-offline --no-audit --no-fund + env: + NODE_OPTIONS: '--max-old-space-size=4096' + UV_THREADPOOL_SIZE: 16 - - name: Run linting - run: npm run lint - - - name: Run type checking - run: npm run typecheck + - name: Run linting and type checking in parallel + run: | + npm run lint & + npm run typecheck & + wait + env: + NODE_OPTIONS: '--max-old-space-size=4096' - name: Build application run: npm run build env: # Use empty string for YOUTUBE_API_KEY during CI build - YOUTUBE_API_KEY: "" \ No newline at end of file + YOUTUBE_API_KEY: "" + NODE_OPTIONS: '--max-old-space-size=4096' + NEXT_TELEMETRY_DISABLED: 1 \ No newline at end of file diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 4705775..4478ec4 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -19,7 +19,9 @@ jobs: - name: Cache dependencies uses: actions/cache@v3 with: - path: ~/.npm + path: | + ~/.npm + node_modules key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- @@ -27,19 +29,37 @@ jobs: - name: Cache Next.js build uses: actions/cache@v3 with: - path: ${{ github.workspace }}/.next/cache + path: | + ${{ github.workspace }}/.next/cache + ${{ github.workspace }}/out key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.[jt]s', '**/*.[jt]sx') }} restore-keys: | ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- + ${{ runner.os }}-nextjs- + + - name: Cache TypeScript + uses: actions/cache@v3 + with: + path: | + tsconfig.tsbuildinfo + .next/types + key: ${{ runner.os }}-tsc-${{ hashFiles('tsconfig.json', 'src/**/*.ts', 'src/**/*.tsx') }} + restore-keys: | + ${{ runner.os }}-tsc- - name: Install dependencies - run: npm ci + run: npm ci --prefer-offline --no-audit --no-fund + env: + NODE_OPTIONS: '--max-old-space-size=4096' + UV_THREADPOOL_SIZE: 16 - name: Build application run: npm run build env: # Access YouTube API key from repository secrets YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }} + NODE_OPTIONS: '--max-old-space-size=4096' + NEXT_TELEMETRY_DISABLED: 1 - name: Deploy to S3 (if configured) run: | diff --git a/tsconfig.json b/tsconfig.json index c133409..9aed7fb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ES2017", + "target": "ES2020", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, @@ -13,6 +13,7 @@ "isolatedModules": true, "jsx": "preserve", "incremental": true, + "tsBuildInfoFile": ".next/types/tsbuildinfo", "plugins": [ { "name": "next"