From b8fe41e59d019e4304808b04307f173a7e112955 Mon Sep 17 00:00:00 2001 From: Doyle <873891+chrisdoyle@users.noreply.github.com> Date: Mon, 10 Nov 2025 11:45:03 -0500 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=92=BE=20feat:=20Add=20Memory=20Confi?= =?UTF-8?q?guration=20Options=20for=20CI=20unit=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - configured GitHub Actions workflows with configurable Node.js heap allocation, defaults to 6144 MiB - added heap usage logging for memory monitoring and debugging - increased Docker frontend build memory allocation to ensure consistent memory limits - optimized Jest timeout for tokenSplit test --- .env.example | 8 ++++++++ .github/workflows/backend-review.yml | 1 + .github/workflows/build.yml | 2 +- .github/workflows/frontend-review.yml | 4 ++++ Dockerfile | 7 +++++-- Dockerfile.multi | 6 +++++- api/package.json | 2 +- api/test/.env.test.example | 2 ++ api/test/jestSetup.js | 2 ++ client/package.json | 2 +- packages/data-provider/package.json | 2 +- 11 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 799e44525b..7161eb1457 100644 --- a/.env.example +++ b/.env.example @@ -68,6 +68,14 @@ DEBUG_CONSOLE=false # UID=1000 # GID=1000 +#==============# +# Node Options # +#==============# + +# Used to adjust Node.js memory configuration (default: 6144 MiB) +# https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-mib +NODE_MAX_OLD_SPACE_SIZE=6144 + #===============# # Configuration # #===============# diff --git a/.github/workflows/backend-review.yml b/.github/workflows/backend-review.yml index 8375f398c3..2379b8fee7 100644 --- a/.github/workflows/backend-review.yml +++ b/.github/workflows/backend-review.yml @@ -24,6 +24,7 @@ jobs: BAN_DURATION: ${{ secrets.BAN_DURATION }} BAN_INTERVAL: ${{ secrets.BAN_INTERVAL }} NODE_ENV: CI + NODE_OPTIONS: '--max-old-space-size=${{ secrets.NODE_MAX_OLD_SPACE_SIZE || 6144 }}' steps: - uses: actions/checkout@v4 - name: Use Node.js 20.x diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2131c4b98..c44f00a3c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - run: | - docker build --build-arg RUNNER_VERSION=${{ env.RUNNER_VERSION }} -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/pwd9000-github-runner-lin:${{ env.RUNNER_VERSION }} . + docker build --build-arg RUNNER_VERSION=${{ env.RUNNER_VERSION }} --build-arg NODE_MAX_OLD_SPACE_SIZE=${{ secrets.NODE_MAX_OLD_SPACE_SIZE || 6144 }} -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/pwd9000-github-runner-lin:${{ env.RUNNER_VERSION }} . - name: 'Push container image to ACR' uses: azure/docker-login@v1 diff --git a/.github/workflows/frontend-review.yml b/.github/workflows/frontend-review.yml index 907d07d307..989e2e4abe 100644 --- a/.github/workflows/frontend-review.yml +++ b/.github/workflows/frontend-review.yml @@ -16,6 +16,8 @@ jobs: name: Run frontend unit tests on Ubuntu timeout-minutes: 60 runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max-old-space-size=${{ secrets.NODE_MAX_OLD_SPACE_SIZE || 6144 }}' steps: - uses: actions/checkout@v4 - name: Use Node.js 20.x @@ -38,6 +40,8 @@ jobs: name: Run frontend unit tests on Windows timeout-minutes: 60 runs-on: windows-latest + env: + NODE_OPTIONS: '--max-old-space-size=${{ secrets.NODE_MAX_OLD_SPACE_SIZE || 6144 }}' steps: - uses: actions/checkout@v4 - name: Use Node.js 20.x diff --git a/Dockerfile b/Dockerfile index 4b00949300..e382da466a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,9 @@ ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2 COPY --from=ghcr.io/astral-sh/uv:0.9.5-python3.12-alpine /usr/local/bin/uv /usr/local/bin/uvx /bin/ RUN uv --version +# Set configurable max-old-space-size with default +ARG NODE_MAX_OLD_SPACE_SIZE=6144 + RUN mkdir -p /app && chown node:node /app WORKDIR /app @@ -39,8 +42,8 @@ RUN \ COPY --chown=node:node . . RUN \ - # React client build - NODE_OPTIONS="--max-old-space-size=2048" npm run frontend; \ + # React client build with configurable memory + NODE_OPTIONS="--max-old-space-size=${NODE_MAX_OLD_SPACE_SIZE}" npm run frontend; \ npm prune --production; \ npm cache clean --force diff --git a/Dockerfile.multi b/Dockerfile.multi index c106b5e5fa..1e73e4ff2d 100644 --- a/Dockerfile.multi +++ b/Dockerfile.multi @@ -7,6 +7,10 @@ FROM node:20-alpine AS base-min RUN apk add --no-cache jemalloc # Set environment variable to use jemalloc ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2 + +# Set configurable max-old-space-size with default +ARG NODE_MAX_OLD_SPACE_SIZE=6144 + WORKDIR /app RUN apk --no-cache add curl RUN npm config set fetch-retry-maxtimeout 600000 && \ @@ -59,7 +63,7 @@ COPY client ./ COPY --from=data-provider-build /app/packages/data-provider/dist /app/packages/data-provider/dist COPY --from=client-package-build /app/packages/client/dist /app/packages/client/dist COPY --from=client-package-build /app/packages/client/src /app/packages/client/src -ENV NODE_OPTIONS="--max-old-space-size=2048" +ENV NODE_OPTIONS="--max-old-space-size=${NODE_MAX_OLD_SPACE_SIZE}" RUN npm run build # API setup (including client dist) diff --git a/api/package.json b/api/package.json index cdcb71e748..bbdd2f4472 100644 --- a/api/package.json +++ b/api/package.json @@ -7,7 +7,7 @@ "server-dev": "echo 'please run this from the root directory'", "test": "cross-env NODE_ENV=test jest", "b:test": "NODE_ENV=test bun jest", - "test:ci": "jest --ci", + "test:ci": "jest --ci --logHeapUsage", "add-balance": "node ./add-balance.js", "list-balances": "node ./list-balances.js", "user-stats": "node ./user-stats.js", diff --git a/api/test/.env.test.example b/api/test/.env.test.example index 9b7a75a996..31d5813e71 100644 --- a/api/test/.env.test.example +++ b/api/test/.env.test.example @@ -11,3 +11,5 @@ OPENAI_API_KEY=your-api-key BAN_VIOLATIONS=true BAN_DURATION=7200000 BAN_INTERVAL=20 + +NODE_MAX_OLD_SPACE_SIZE=6144 diff --git a/api/test/jestSetup.js b/api/test/jestSetup.js index d62b8467ed..506193b5e0 100644 --- a/api/test/jestSetup.js +++ b/api/test/jestSetup.js @@ -16,3 +16,5 @@ process.env.ALLOW_EMAIL_LOGIN = 'true'; // This can be overridden in individual tests if needed jest.setTimeout(30000); process.env.OPENAI_API_KEY = 'test'; + +process.env.NODE_MAX_OLD_SPACE_SIZE = '6144'; diff --git a/client/package.json b/client/package.json index 27224493ce..c9c323dd2a 100644 --- a/client/package.json +++ b/client/package.json @@ -12,7 +12,7 @@ "dev": "cross-env NODE_ENV=development vite", "preview-prod": "cross-env NODE_ENV=development vite preview", "test": "cross-env NODE_ENV=development jest --watch", - "test:ci": "cross-env NODE_ENV=development jest --ci", + "test:ci": "cross-env NODE_ENV=development jest --ci --logHeapUsage", "b:test": "NODE_ENV=test bunx jest --watch", "b:build": "NODE_ENV=production bun --bun vite build", "b:dev": "NODE_ENV=development bunx vite" diff --git a/packages/data-provider/package.json b/packages/data-provider/package.json index 4e5d0d5220..692d6b4f07 100644 --- a/packages/data-provider/package.json +++ b/packages/data-provider/package.json @@ -23,7 +23,7 @@ "build:watch": "rollup -c -w", "rollup:api": "npx rollup -c server-rollup.config.js --bundleConfigAsCjs", "test": "jest --coverage --watch", - "test:ci": "jest --coverage --ci", + "test:ci": "jest --coverage --ci --logHeapUsage", "verify": "npm run test:ci", "b:clean": "bun run rimraf dist", "b:build": "bun run b:clean && bun run rollup -c --silent --bundleConfigAsCjs" From ef8f27122e7a90bb5b171468debaffc45b7b23b5 Mon Sep 17 00:00:00 2001 From: Doyle <873891+chrisdoyle@users.noreply.github.com> Date: Fri, 12 Dec 2025 14:48:26 -0500 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=92=BE=20feat:=20Add=20Memory=20Confi?= =?UTF-8?q?guration=20Options=20for=20CI=20unit=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - responding to PR feedback from Copilot --- .env.example | 8 ++++++-- .github/workflows/build.yml | 2 +- Dockerfile.multi | 6 +++--- api/test/.env.test.example | 2 ++ api/test/jestSetup.js | 2 -- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 7161eb1457..52b172b72c 100644 --- a/.env.example +++ b/.env.example @@ -72,8 +72,12 @@ DEBUG_CONSOLE=false # Node Options # #==============# -# Used to adjust Node.js memory configuration (default: 6144 MiB) -# https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-mib +# NOTE: NODE_MAX_OLD_SPACE_SIZE is NOT recognized by Node.js directly. +# This variable is used as a build argument for Docker or CI/CD workflows, +# and is NOT used by Node.js to set the heap size at runtime. +# To configure Node.js memory, use NODE_OPTIONS, e.g.: +# NODE_OPTIONS="--max-old-space-size=6144" +# See: https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-mib NODE_MAX_OLD_SPACE_SIZE=6144 #===============# diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c44f00a3c9..a2131c4b98 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - run: | - docker build --build-arg RUNNER_VERSION=${{ env.RUNNER_VERSION }} --build-arg NODE_MAX_OLD_SPACE_SIZE=${{ secrets.NODE_MAX_OLD_SPACE_SIZE || 6144 }} -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/pwd9000-github-runner-lin:${{ env.RUNNER_VERSION }} . + docker build --build-arg RUNNER_VERSION=${{ env.RUNNER_VERSION }} -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/pwd9000-github-runner-lin:${{ env.RUNNER_VERSION }} . - name: 'Push container image to ACR' uses: azure/docker-login@v1 diff --git a/Dockerfile.multi b/Dockerfile.multi index 1e73e4ff2d..ac58aa21b6 100644 --- a/Dockerfile.multi +++ b/Dockerfile.multi @@ -1,6 +1,9 @@ # Dockerfile.multi # v0.8.1 +# Set configurable max-old-space-size with default +ARG NODE_MAX_OLD_SPACE_SIZE=6144 + # Base for all builds FROM node:20-alpine AS base-min # Install jemalloc @@ -8,9 +11,6 @@ RUN apk add --no-cache jemalloc # Set environment variable to use jemalloc ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2 -# Set configurable max-old-space-size with default -ARG NODE_MAX_OLD_SPACE_SIZE=6144 - WORKDIR /app RUN apk --no-cache add curl RUN npm config set fetch-retry-maxtimeout 600000 && \ diff --git a/api/test/.env.test.example b/api/test/.env.test.example index 31d5813e71..587a739cc3 100644 --- a/api/test/.env.test.example +++ b/api/test/.env.test.example @@ -12,4 +12,6 @@ BAN_VIOLATIONS=true BAN_DURATION=7200000 BAN_INTERVAL=20 +# NODE_MAX_OLD_SPACE_SIZE is only used as a Docker build argument. +# Node.js does NOT recognize this environment variable for heap size. NODE_MAX_OLD_SPACE_SIZE=6144 diff --git a/api/test/jestSetup.js b/api/test/jestSetup.js index 506193b5e0..d62b8467ed 100644 --- a/api/test/jestSetup.js +++ b/api/test/jestSetup.js @@ -16,5 +16,3 @@ process.env.ALLOW_EMAIL_LOGIN = 'true'; // This can be overridden in individual tests if needed jest.setTimeout(30000); process.env.OPENAI_API_KEY = 'test'; - -process.env.NODE_MAX_OLD_SPACE_SIZE = '6144';