4545 run : |
4646 # Create a temporary directory for build logs
4747 mkdir -p /tmp/build_logs
48- npm install -g eslint
48+ npm install -g eslint > /dev/null
4949
5050 # Function to build a single file
5151 build_file() {
@@ -63,19 +63,35 @@ jobs:
6363 echo "Build Path $file"
6464
6565 # Run the build script for the current language, passing the project directory and extra path
66- echo "::group::$file"
67- if ../scripts/build-${language}.sh "$file" > "$log_file" 2>&1; then
68- echo "::endgroup::"
69- return 0
66+ echo "::group::Building $file"
67+ # Run the build command and capture output to both the log file and stdout
68+ ../scripts/build-${language}.sh "$file" 2>&1 | tee "$log_file"
69+ local exit_code=${PIPESTATUS[0]}
70+
71+ if [ $exit_code -eq 0 ]; then
72+ echo "✅ Build succeeded for $file"
73+
74+ # Clean up node_modules and cdk.out for this project immediately after successful build
75+ echo "Cleaning up build artifacts for $(dirname "$file")"
76+ local project_dir=$(dirname "$file")
77+
78+ # Remove node_modules directory if it exists
79+ if [ -d "$project_dir/node_modules" ]; then
80+ echo "Removing $project_dir/node_modules"
81+ rm -rf "$project_dir/node_modules"
82+ fi
83+
84+ # Remove cdk.out directory if it exists
85+ if [ -d "$project_dir/cdk.out" ]; then
86+ echo "Removing $project_dir/cdk.out"
87+ rm -rf "$project_dir/cdk.out"
88+ fi
7089 else
71- local exit_code=$?
72- echo "::endgroup::"
73- echo "::group::Error details for $file"
74- cat "$log_file"
75- echo "::endgroup::"
90+ echo "❌ Build failed for $file with exit code $exit_code"
7691 echo "::error::Build failed for $file with exit code $exit_code"
77- return $exit_code
7892 fi
93+ echo "::endgroup::"
94+ return $exit_code
7995 }
8096
8197 # Export the build_file function for use in parallel
@@ -122,28 +138,18 @@ jobs:
122138
123139 # Run the build_file function in parallel for each project to be built
124140 # Halt the execution if any of the build_file invocations fail
141+ echo "::group::Build Output"
142+ echo "Starting builds for all projects..."
125143 parallel --keep-order --halt-on-error 2 build_file ::: "${apps_to_build[@]}"
144+ echo "::endgroup::"
126145
127146 # Check the exit status of parallel
128147 parallel_exit=$?
129148
130- # If parallel succeeded, clean up node_modules and cdk.out to save space
131- if [ $parallel_exit -eq 0 ]; then
132- echo "::group::Cleaning up build artifacts"
133- # Find all node_modules directories within the language directory and remove them
134- echo "Removing node_modules directories..."
135- find ./ -name "node_modules" -type d -prune -exec rm -rf {} \; 2>/dev/null || true
136-
137- # Find all cdk.out directories within the language directory and remove them
138- echo "Removing cdk.out directories..."
139- find ./ -name "cdk.out" -type d -prune -exec rm -rf {} \; 2>/dev/null || true
140-
141- echo "Cleanup completed"
142- echo "::endgroup::"
143- fi
144-
145149 # If parallel failed, make sure the workflow fails too
146150 if [ $parallel_exit -ne 0 ]; then
147- echo "::error::One or more builds failed. See error details above."
151+ echo "::error::One or more builds failed. See build output above for details ."
148152 exit $parallel_exit
153+ else
154+ echo "✅ All builds completed successfully!"
149155 fi
0 commit comments