Skip to content

Commit 2dd0f47

Browse files
committed
fix: prevent Bazel OOM crash on CI runners
- Add resource limits to all CI workflows' bazelrc configuration: - Limit RAM to 6GB (GitHub Actions ubuntu-latest has 7GB) - Limit CPUs to 2 - Limit parallel jobs to 4 - Reduce JVM heap to 2GB max - Discard analysis cache after build to reduce memory pressure - Add build output verification in adev.ts to detect silent failures when Bazel server is killed mid-build
1 parent 7eda322 commit 2dd0f47

4 files changed

Lines changed: 35 additions & 21 deletions

File tree

.github/workflows/adev-preview-build.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@ jobs:
3535
disk-cache: ${{ github.workflow }}
3636
repository-cache: true
3737
bazelrc: |
38-
# Print all the options that apply to the build.
39-
# This helps us diagnose which options override others
40-
# (e.g. /etc/bazel.bazelrc vs. tools/bazel.rc)
41-
build --announce_rc
42-
43-
# More details on failures
44-
build --verbose_failures=true
45-
46-
# CI supports colors but Bazel does not detect it.
47-
common --color=yes
38+
# Limit resources for CI runners (ubuntu-latest: 7GB RAM, 2 CPUs)
39+
build --local_ram_resources=6144
40+
build --local_cpu_resources=2
41+
build --jobs=4
42+
startup --host_jvm_args=-Xms512m
43+
startup --host_jvm_args=-Xmx2g
44+
build --discard_analysis_cache
45+
build --nokeep_state_after_build
4846
- run: pnpm install --frozen-lockfile
4947
- run: pnpm run build
5048
- uses: angular/dev-infra/github-actions/previews/pack-and-upload-artifact@0512a5b9381ccff00c278d7b4b6ee38e5c09654d

.github/workflows/adev-production-deploy.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@ jobs:
2727
disk-cache: ${{ github.workflow }}
2828
repository-cache: true
2929
bazelrc: |
30-
# Print all the options that apply to the build.
31-
# This helps us diagnose which options override others
32-
# (e.g. /etc/bazel.bazelrc vs. tools/bazel.rc)
33-
build --announce_rc
34-
35-
# More details on failures
36-
build --verbose_failures=true
37-
38-
# CI supports colors but Bazel does not detect it.
39-
common --color=yes
30+
# Limit resources for CI runners (ubuntu-latest: 7GB RAM, 2 CPUs)
31+
build --local_ram_resources=6144
32+
build --local_cpu_resources=2
33+
build --jobs=4
34+
startup --host_jvm_args=-Xms512m
35+
startup --host_jvm_args=-Xmx2g
36+
build --discard_analysis_cache
37+
build --nokeep_state_after_build
4038
- run: pnpm install --frozen-lockfile
4139
- run: pnpm run build
4240
- name: Deploy to Firebase Hosting

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ jobs:
3838
bazelisk-cache: true
3939
disk-cache: ${{ github.workflow }}
4040
repository-cache: true
41+
bazelrc: |
42+
# Limit resources for CI runners (ubuntu-latest: 7GB RAM, 2 CPUs)
43+
build --local_ram_resources=6144
44+
build --local_cpu_resources=2
45+
build --jobs=4
46+
startup --host_jvm_args=-Xms512m
47+
startup --host_jvm_args=-Xmx2g
48+
build --discard_analysis_cache
49+
build --nokeep_state_after_build
4150
- run: pnpm install
4251
- run: pnpm run build
4352
# build-windows:

tools/lib/adev.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { consola } from 'consola';
22
import { $ } from 'execa';
3-
import { buildDir } from './workspace';
3+
import { existsSync } from 'node:fs';
4+
import { buildDir, buildOutputDir } from './workspace';
45

56
const $$ = $({
67
stdin: 'inherit',
@@ -13,6 +14,14 @@ export async function buildAdev() {
1314
const sh = $$({ cwd: buildDir });
1415
await sh`pnpm install --frozen-lockfile`;
1516
await sh`pnpm bazel build //adev:build.production --config=release`;
17+
18+
// Verify build output exists - Bazel may exit with code 0 even when interrupted
19+
if (!existsSync(buildOutputDir)) {
20+
throw new Error(
21+
`Build output directory not found: ${buildOutputDir}\n` +
22+
'Bazel build may have been interrupted or failed silently.'
23+
);
24+
}
1625
}
1726

1827
export function serveAdev() {

0 commit comments

Comments
 (0)