Skip to content

Commit 74ead27

Browse files
jonphippsclaude
andcommitted
feat: add comprehensive CI optimization with DTE and bundle analysis
- Add CI Distributed Task Execution (DTE) workflow for optimized parallel testing - Implement bundle size analysis and monitoring scripts - Configure Nx Cloud integration for enhanced caching and task distribution - Add environment.js for runtime configuration support - Update TypeScript and build configurations for better performance - Optimize theme package build process with improved tsup configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent a7ceddf commit 74ead27

File tree

9 files changed

+724
-7
lines changed

9 files changed

+724
-7
lines changed

.github/workflows/ci-dte.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: CI-DTE (Distributed Task Execution)
2+
# High-performance CI pipeline with Nx Cloud Distributed Task Execution
3+
4+
on:
5+
push:
6+
branches: [main, dev]
7+
pull_request:
8+
branches: [main, dev]
9+
workflow_dispatch:
10+
inputs:
11+
distribute:
12+
description: 'Enable distributed task execution'
13+
required: false
14+
default: 'true'
15+
type: boolean
16+
agents:
17+
description: 'Number of agents for DTE'
18+
required: false
19+
default: '4'
20+
type: choice
21+
options: ['2', '3', '4', '6', '8']
22+
23+
permissions:
24+
actions: read
25+
contents: read
26+
27+
env:
28+
NX_BRANCH: ${{ github.event.number || github.ref_name }}
29+
NX_RUN_GROUP: ${{ github.run_id }}
30+
HUSKY: 0
31+
# Environment detection matching your existing setup
32+
DOCS_ENV: ${{ github.event_name == 'pull_request' && 'preview' || github.ref_name == 'main' && 'production' || github.ref_name == 'dev' && 'development' || 'development' }}
33+
SITE_TITLE: IFLA Standards Portal
34+
SITE_TAGLINE: International Federation of Library Associations and Institutions
35+
# Secrets for integration tests
36+
GOOGLE_SHEETS_API_KEY: ${{ secrets.GOOGLE_SHEETS_API_KEY }}
37+
GSHEETS_SA_KEY: ${{ secrets.GSHEETS_SA_KEY }}
38+
39+
jobs:
40+
main:
41+
name: DTE CI Pipeline
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout [Pull Request]
45+
uses: actions/checkout@v4
46+
if: ${{ github.event_name == 'pull_request' }}
47+
with:
48+
ref: ${{ github.event.pull_request.head.sha }}
49+
token: ${{ secrets.GITHUB_TOKEN }}
50+
fetch-depth: 0
51+
filter: tree:0
52+
53+
- name: Checkout [Default Branch]
54+
uses: actions/checkout@v4
55+
if: ${{ github.event_name != 'pull_request' }}
56+
with:
57+
token: ${{ secrets.GITHUB_TOKEN }}
58+
fetch-depth: 0
59+
filter: tree:0
60+
61+
- name: Setup pnpm
62+
uses: pnpm/action-setup@v4
63+
with:
64+
run_install: false
65+
66+
# Enable Distributed Task Execution BEFORE dependencies
67+
- name: Start Nx Cloud DTE
68+
run: |
69+
AGENT_COUNT="${{ github.event.inputs.agents || '4' }}"
70+
pnpm dlx nx-cloud start-ci-run --distribute-on="${AGENT_COUNT} linux-medium-js" --stop-agents-after="e2e"
71+
if: github.event.inputs.distribute != 'false'
72+
73+
- name: Setup Node.js with Cache
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: '22'
77+
cache: 'pnpm'
78+
79+
- name: Install Dependencies
80+
run: pnpm install --frozen-lockfile
81+
82+
- name: Derive SHAs for Nx Affected
83+
uses: nrwl/nx-set-shas@v4
84+
85+
# TypeScript and Linting (Fast feedback)
86+
- name: TypeScript Check & Lint
87+
run: pnpm exec nx affected -t typecheck lint --parallel=8
88+
env:
89+
NODE_OPTIONS: '--max-old-space-size=8192'
90+
91+
# Unit & Integration Tests
92+
- name: Run Tests
93+
run: pnpm exec nx affected -t test --parallel=6
94+
env:
95+
NODE_OPTIONS: '--max-old-space-size=8192'
96+
97+
# Build All Affected Projects
98+
- name: Build Projects
99+
run: pnpm exec nx affected -t build --parallel=4
100+
env:
101+
NODE_OPTIONS: '--max-old-space-size=8192'
102+
103+
# Configuration Validation (matches your existing CI)
104+
- name: Validate Site Configurations
105+
run: node scripts/test-site-builds.js --site all --env $DOCS_ENV --skip-build
106+
if: success()
107+
108+
# E2E Tests (Distributed across agents)
109+
- name: Run E2E Tests
110+
run: pnpm exec nx affected -t e2e --parallel=3
111+
if: success()
112+
env:
113+
NODE_OPTIONS: '--max-old-space-size=8192'
114+
115+
# Summary
116+
- name: Nx Cloud Summary
117+
run: pnpm exec nx-cloud stop-all-agents
118+
if: always()

nx.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@
3737
"{projectRoot}/src/**/*",
3838
"{projectRoot}/static/**/*"
3939
],
40-
"sharedGlobals": ["{workspaceRoot}/.github/workflows/ci.yml"]
40+
"sharedGlobals": [
41+
"{workspaceRoot}/.github/workflows/ci.yml",
42+
"{workspaceRoot}/package.json",
43+
"{workspaceRoot}/pnpm-lock.yaml",
44+
"{workspaceRoot}/tsconfig.json",
45+
"{workspaceRoot}/.github/workflows/ci-dte.yml"
46+
]
4147
},
4248
"targetDefaults": {
4349
"build": {
@@ -92,6 +98,11 @@
9298
"dependsOn": ["^build"],
9399
"inputs": ["production", "^production"]
94100
},
101+
"build:tsc": {
102+
"cache": true,
103+
"dependsOn": ["^build"],
104+
"inputs": ["production", "^production"]
105+
},
95106
"e2e": {
96107
"cache": true,
97108
"dependsOn": ["build"],
@@ -124,6 +135,13 @@
124135
"{workspaceRoot}/vite.config.ts",
125136
"{workspaceRoot}/vitest.config.*"
126137
]
138+
},
139+
"clean": {
140+
"cache": false
141+
},
142+
"prepare": {
143+
"cache": true,
144+
"dependsOn": ["^build"]
127145
}
128146
},
129147
"plugins": [
@@ -156,6 +174,6 @@
156174
"cli": {
157175
"analytics": false
158176
},
159-
"parallel": 6,
177+
"parallel": 8,
160178
"cacheDirectory": ".nx/cache"
161179
}

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@
117117
"nx:performance": "node scripts/nx-performance-check.js",
118118
"nx:graph": "nx graph",
119119
"nx:affected": "nx affected --target=build --dry-run",
120+
"nx:monitor": "node scripts/nx-cloud-monitor.js",
121+
"nx:monitor:cache": "node scripts/nx-cloud-monitor.js cache",
122+
"nx:monitor:test": "node scripts/nx-cloud-monitor.js test",
123+
"nx:monitor:links": "node scripts/nx-cloud-monitor.js links",
124+
"analyze:bundles": "node scripts/analyze-bundle-sizes.js",
125+
"analyze:bundles:sizes": "node scripts/analyze-bundle-sizes.js bundles",
126+
"analyze:bundles:source": "node scripts/analyze-bundle-sizes.js source",
120127
"test:visual-regression": "playwright test --config=playwright-snapshots.config.ts",
121128
"test:regression:optimized": "node scripts/test-site-builds-optimized.js --mode smart",
122129
"test:regression:fast": "node scripts/test-site-builds-optimized.js --mode fast --skip-build",

packages/theme/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@ifla/theme",
33
"version": "0.0.0",
4+
"sideEffects": false,
45
"files": [
56
"LICENSE",
67
"README.md",

packages/theme/tsup.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ export default defineConfig({
1515
format: ['esm', 'cjs'],
1616
// Disable built-in DTS generation due to TypeScript project conflicts
1717
dts: false,
18-
splitting: false, // Disable code splitting to avoid bundling issues
18+
splitting: true, // Enable code splitting for better optimization
1919
sourcemap: true,
2020
clean: true, // Clean output directory before build
2121
outDir: 'dist',
2222
target: 'es2020', // Or your desired target
2323
platform: 'neutral', // Use neutral to avoid bundling platform-specific modules
2424
esbuildOptions(options) {
2525
options.jsx = 'automatic';
26+
options.treeShaking = true;
27+
options.minify = true;
2628
return options;
2729
},
2830
external: [

0 commit comments

Comments
 (0)