Skip to content

Commit 14bc19c

Browse files
committed
install and implement nx
1 parent dd223e5 commit 14bc19c

File tree

20 files changed

+1734
-9
lines changed

20 files changed

+1734
-9
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Nx Optimized CI
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
pull_request:
7+
branches: [main, dev]
8+
workflow_dispatch:
9+
10+
env:
11+
NX_CLOUD_DISTRIBUTED_EXECUTION: true
12+
NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT: 3
13+
NX_BRANCH: ${{ github.event.number || github.ref_name }}
14+
NX_RUN_GROUP: ${{ github.run_id }}
15+
HUSKY: 0
16+
17+
jobs:
18+
main:
19+
name: Nx Cloud - Main Job
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout [Pull Request]
23+
uses: actions/checkout@v4
24+
if: ${{ github.event_name == 'pull_request' }}
25+
with:
26+
ref: ${{ github.event.pull_request.head.sha }}
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
fetch-depth: 0
29+
30+
- name: Checkout [Default Branch]
31+
uses: actions/checkout@v4
32+
if: ${{ github.event_name != 'pull_request' }}
33+
with:
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
fetch-depth: 0
36+
37+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
38+
uses: nrwl/nx-set-shas@v4
39+
40+
- name: Setup pnpm
41+
uses: pnpm/action-setup@v4
42+
43+
- name: Setup Node.js
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: '22'
47+
cache: 'pnpm'
48+
49+
- name: Install dependencies
50+
run: pnpm install --no-frozen-lockfile
51+
52+
- name: Start CI run
53+
run: 'npx nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3'
54+
55+
- name: Run commands in parallel
56+
run: |
57+
pids=()
58+
59+
# Type checking
60+
npx nx affected --target=typecheck --parallel=3 --ci --verbose & pids+=($!)
61+
62+
# Linting
63+
npx nx affected --target=lint --parallel=3 --ci --verbose & pids+=($!)
64+
65+
# Unit tests
66+
npx nx affected --target=test --parallel=3 --ci --verbose & pids+=($!)
67+
68+
# Build affected projects
69+
npx nx affected --target=build --parallel=3 --ci --verbose & pids+=($!)
70+
71+
# Wait for all jobs to complete
72+
for pid in "${pids[@]}"; do
73+
wait $pid
74+
done
75+
76+
- name: Stop all running agents for this CI run
77+
if: ${{ always() }}
78+
run: npx nx-cloud stop-all-agents
79+
80+
agents:
81+
name: Nx Cloud - Agents
82+
runs-on: ubuntu-latest
83+
timeout-minutes: 60
84+
strategy:
85+
matrix:
86+
agent: [1, 2, 3]
87+
steps:
88+
- name: Checkout
89+
uses: actions/checkout@v4
90+
91+
- name: Setup pnpm
92+
uses: pnpm/action-setup@v4
93+
94+
- name: Setup Node.js
95+
uses: actions/setup-node@v4
96+
with:
97+
node-version: '22'
98+
cache: 'pnpm'
99+
100+
- name: Install dependencies
101+
run: pnpm install --no-frozen-lockfile
102+
103+
- name: Start Nx Agent ${{ matrix.agent }}
104+
run: npx nx-cloud start-agent
105+
env:
106+
NX_AGENT_NAME: ${{ matrix.agent }}

.husky/pre-push-nx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env sh
2+
# Nx-optimized pre-push hook for IFLA Standards project
3+
# Only tests and builds what's actually affected by changes
4+
5+
echo "⚡ Running Nx-optimized pre-push tests..."
6+
echo "💡 This will only test affected projects (much faster!)"
7+
8+
# Run the ultra-fast Nx pre-push script
9+
exec ./scripts/nx-pre-push-fast.sh

.husky/pre-push-original

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env sh
2+
# Pre-push hook for IFLA Standards project
3+
# Runs comprehensive build regression tests before pushing
4+
5+
echo "🚀 Running pre-push regression tests..."
6+
7+
# Get the current branch name
8+
BRANCH=$(git branch --show-current)
9+
echo "📋 Testing branch: $BRANCH"
10+
11+
# Check if we're pushing to main or dev (stricter testing)
12+
if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "dev" ]; then
13+
echo "🔒 Detected push to protected branch ($BRANCH) - running full test suite"
14+
15+
# 1. Full build regression test for critical sites
16+
echo "🏗️ Testing critical site builds..."
17+
node scripts/test-site-builds.js --site portal --env production
18+
if [ $? -ne 0 ]; then
19+
echo "❌ Portal build test failed."
20+
exit 1
21+
fi
22+
23+
node scripts/test-site-builds.js --site ISBDM --env production
24+
if [ $? -ne 0 ]; then
25+
echo "❌ ISBDM build test failed."
26+
exit 1
27+
fi
28+
29+
# 2. Portal end-to-end validation
30+
echo "🌐 Running portal E2E tests..."
31+
./scripts/test-portal-builds.sh
32+
if [ $? -ne 0 ]; then
33+
echo "❌ Portal E2E tests failed."
34+
exit 1
35+
fi
36+
37+
else
38+
echo "📝 Feature branch detected - running abbreviated tests"
39+
40+
# 1. Quick build test for all configurations
41+
echo "⚙️ Testing all site configurations..."
42+
node scripts/test-site-builds.js --site all --env localhost --skip-build
43+
if [ $? -ne 0 ]; then
44+
echo "❌ Site configuration tests failed."
45+
exit 1
46+
fi
47+
48+
# 2. Test one representative site build
49+
echo "🏗️ Testing representative site build..."
50+
node scripts/test-site-builds.js --site portal --env localhost
51+
if [ $? -ne 0 ]; then
52+
echo "❌ Representative build test failed."
53+
exit 1
54+
fi
55+
fi
56+
57+
echo "✅ All pre-push tests passed! Safe to push to $BRANCH."

0 commit comments

Comments
 (0)