diff --git a/.github/workflows/client-build.yml b/.github/workflows/client-build.yml
index a6c040cdad02..0ffac844d51e 100644
--- a/.github/workflows/client-build.yml
+++ b/.github/workflows/client-build.yml
@@ -135,12 +135,14 @@ jobs:
# Install all the dependencies
- name: Install dependencies
if: steps.run_result.outputs.run_result != 'success' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule')
- run: yarn install --immutable
+ run: |
+ /usr/bin/time -v yarn install --immutable 2> install_mem.txt
# Type checking before starting the build
- name: Run type check
if: steps.run_result.outputs.run_result != 'success' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule')
- run: yarn run check-types
+ run: |
+ /usr/bin/time -v yarn run check-types 2> typecheck_mem.txt
- name: Set the build environment based on the branch
if: steps.run_result.outputs.run_result != 'success' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule')
@@ -174,7 +176,7 @@ jobs:
REACT_APP_FUSIONCHARTS_LICENSE_KEY=${{ secrets.APPSMITH_FUSIONCHARTS_LICENSE_KEY }} \
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \
REACT_APP_VERSION_EDITION="Community" \
- yarn build
+ /usr/bin/time -v yarn build 2> build_mem.txt
# Saving the cache to use it in subsequent runs
- name: Save Yarn cache
@@ -222,6 +224,83 @@ jobs:
git lfs pull ./build.tar
mv ./build.tar ../../../../../build.tar
+ # Gather and report memory usage information
+ - name: Gather memory usage info
+ if: github.event_name == 'pull_request'
+ id: gather_memory
+ run: |
+ # Create output directory if it doesn't exist
+ mkdir -p memory_stats
+
+ # Parse peak memory usage from each stage
+ echo "Memory usage summary:" > memory_stats/memory_summary.txt
+ echo "===================" >> memory_stats/memory_summary.txt
+
+ # Function to extract peak memory
+ get_peak_memory() {
+ if [ -f "$1" ]; then
+ grep "Maximum resident set size" "$1" | awk '{print $6}' || echo "0"
+ else
+ echo "0"
+ fi
+ }
+
+ # Function to convert kB to GB with 2 decimal places
+ convert_to_gb() {
+ local kb=$1
+ if [ "$kb" = "0" ]; then
+ echo "0.00"
+ else
+ echo "scale=2; $kb / 1048576" | bc
+ fi
+ }
+
+ # Get peak memory for each stage
+ PEAK_INSTALL=$(get_peak_memory install_mem.txt)
+ PEAK_TYPECHECK=$(get_peak_memory typecheck_mem.txt)
+ PEAK_BUILD=$(get_peak_memory build_mem.txt)
+
+ # Convert to GB
+ PEAK_INSTALL_GB=$(convert_to_gb $PEAK_INSTALL)
+ PEAK_TYPECHECK_GB=$(convert_to_gb $PEAK_TYPECHECK)
+ PEAK_BUILD_GB=$(convert_to_gb $PEAK_BUILD)
+
+ # Find overall peak (excluding zero values)
+ echo "$PEAK_INSTALL" > memory_stats/all_peaks.txt
+ echo "$PEAK_TYPECHECK" >> memory_stats/all_peaks.txt
+ echo "$PEAK_BUILD" >> memory_stats/all_peaks.txt
+ OVERALL_PEAK=$(sort -n memory_stats/all_peaks.txt | grep -v "^0$" | tail -1 || echo "0")
+ OVERALL_PEAK_GB=$(convert_to_gb $OVERALL_PEAK)
+
+ # Create summary
+ echo "Install Dependencies Peak: $PEAK_INSTALL_GB GB ($PEAK_INSTALL kB)" >> memory_stats/memory_summary.txt
+ echo "Type Checking Peak: $PEAK_TYPECHECK_GB GB ($PEAK_TYPECHECK kB)" >> memory_stats/memory_summary.txt
+ echo "Build Peak: $PEAK_BUILD_GB GB ($PEAK_BUILD kB)" >> memory_stats/memory_summary.txt
+ echo "Overall Peak: $OVERALL_PEAK_GB GB ($OVERALL_PEAK kB)" >> memory_stats/memory_summary.txt
+
+ cat memory_stats/memory_summary.txt
+
+ # Post memory usage as PR comment
+ - name: Comment PR with memory usage
+ if: github.event_name == 'pull_request'
+ uses: actions/github-script@v7
+ with:
+ script: |
+ const fs = require('fs');
+ const path = require('path');
+ try {
+ const memoryStats = fs.readFileSync(path.join(process.env.GITHUB_WORKSPACE, 'app/client/memory_stats/memory_summary.txt'), 'utf8');
+ await github.rest.issues.createComment({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ body: `## 📊 Client Build Memory Usage Report\n\`\`\`\n${memoryStats}\n\`\`\``
+ });
+ } catch (error) {
+ console.error('Failed to read memory stats:', error);
+ core.warning('Memory usage report could not be generated');
+ }
+
# Upload the build artifact so that it can be used by the test & deploy job in the workflow
- name: Upload react build bundle
uses: actions/upload-artifact@v4
diff --git a/app/client/README.md b/app/client/README.md
index 97738e1dee06..ea6bbdd52b6a 100755
--- a/app/client/README.md
+++ b/app/client/README.md
@@ -3,3 +3,6 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo
For details on setting up your development machine, please refer to the [Setup Guide](../../contributions/ClientSetup.md)
+## Build Process
+The client build process is monitored for memory usage. Peak memory consumption during installation, type checking, and build phases is tracked and reported on pull requests to help maintain optimal resource utilization.
+