Skip to content

Commit 806d449

Browse files
committed
fix(ci): allow sandbox network access for Algolia during SSR prerendering
origin's .bazelrc disables Bazel sandbox network access by default (--nosandbox_default_allow_network), which makes the adev SSR bundling step fail (RetryError: Unreachable hosts) because it needs to reach Algolia during prerendering. This is a known issue also hit by angular/angular-ja; this mirrors their fix. - CI: add --sandbox_default_allow_network and CI resource limits to the Bazel config in ci.yml and adev-staging-deploy.yml - Local: add a root .bazelrc (general Bazel diagnostics) and an optional .bazelrc.user.example (macOS network workaround via --spawn_strategy=local); tools/lib/common.mjs now propagates both into build/.bazelrc.user on every build, since Bazel only reads .bazelrc.user from its own workspace root - Bump actions/checkout, actions/setup-node, pnpm/action-setup, and bazel-contrib/setup-bazel to their first Node 24 releases, clearing the Node 20 deprecation warning on every run - Migrate deprecated --local_ram_resources/--local_cpu_resources to --local_resources=memory=/cpu=, and drop the _JAVA_OPTIONS env var since Bazel was silently ignoring it - Use a per-workflow disk-cache key (disk-cache: ${{ github.workflow }}) instead of one shared across workflows, matching angular-ja - Verified green in CI at memory=4096 (Bazel) + NODE_OPTIONS=4096 (Node), --jobs=2, all within the free ubuntu-latest runner's 7GB RAM; the earlier OOM-shaped failures at this same budget were during a documented GitHub-wide Actions outage, not a resource shortfall
1 parent 7daab57 commit 806d449

6 files changed

Lines changed: 70 additions & 20 deletions

File tree

.bazelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Print all the options that apply to the build.
2+
# This helps us diagnose which options override others
3+
# (e.g. /etc/bazel.bazelrc vs. tools/bazel.rc)
4+
build --announce_rc
5+
6+
# More details on failures
7+
build --verbose_failures=true
8+
9+
# CI supports colors but Bazel does not detect it.
10+
common --color=yes

.bazelrc.user.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Local development settings for macOS
2+
# Copy this file to .bazelrc.user to enable these settings.
3+
# macOS sandbox blocks network access during prerendering (Algolia API calls).
4+
# Use local spawn strategy to allow network access.
5+
build --spawn_strategy=local

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,39 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout Repository
16-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
1717
with:
1818
submodules: true
1919
- name: Setup Node JS
20-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
20+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
2121
with:
2222
node-version-file: '.node-version'
2323
- name: Setup pnpm
24-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # 4.1.0
24+
uses: pnpm/action-setup@b307475762933b98ed359c036b0e51f26b63b74b # v5.0.0
2525
with:
2626
version: 10.17.1
2727
- name: Setup Bazel
28-
uses: bazel-contrib/setup-bazel@4fd964a13a440a8aeb0be47350db2fc640f19ca8 # 0.15.0
28+
uses: bazel-contrib/setup-bazel@8cb04a772ab4c1eb984e9c1b493a182e96c5e425 # 0.19.0
2929
with:
3030
bazelisk-cache: true
31-
disk-cache: true
31+
disk-cache: ${{ github.workflow }}
3232
repository-cache: true
3333
bazelrc: |
34-
# Print all the options that apply to the build.
35-
# This helps us diagnose which options override others
36-
# (e.g. /etc/bazel.bazelrc vs. tools/bazel.rc)
37-
build --announce_rc
34+
# Limit resources for CI runners (ubuntu-latest: 7GB RAM, 2 CPUs)
35+
build --local_resources=memory=4096
36+
build --local_resources=cpu=2
37+
build --jobs=2
38+
build --discard_analysis_cache
39+
build --nokeep_state_after_build
3840
39-
# More details on failures
40-
build --verbose_failures=true
41-
42-
# CI supports colors but Bazel does not detect it.
43-
common --color=yes
41+
# Allow network access in sandbox for Algolia API calls during SSR prerendering.
42+
build --sandbox_default_allow_network
4443
- name: Install Dependencies
4544
run: npm ci
4645
- name: Build Docs
4746
run: npm run build
47+
env:
48+
NODE_OPTIONS: --max-old-space-size=4096
4849
- name: Deploy to Firebase Hosting
4950
uses: FirebaseExtended/action-hosting-deploy@v0
5051
with:

.github/workflows/ci.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,35 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout Repository
13-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
13+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
1414
with:
1515
submodules: true
1616
- name: Setup Node JS
17-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
17+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
1818
with:
1919
node-version-file: '.node-version'
2020
- name: Setup pnpm
21-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # 4.1.0
21+
uses: pnpm/action-setup@b307475762933b98ed359c036b0e51f26b63b74b # v5.0.0
2222
with:
2323
version: 10.17.1
2424
- name: Setup Bazel
25-
uses: bazel-contrib/setup-bazel@4fd964a13a440a8aeb0be47350db2fc640f19ca8 # 0.15.0
25+
uses: bazel-contrib/setup-bazel@8cb04a772ab4c1eb984e9c1b493a182e96c5e425 # 0.19.0
2626
with:
2727
bazelisk-cache: true
28-
disk-cache: true
28+
disk-cache: ${{ github.workflow }}
2929
repository-cache: true
30+
bazelrc: |
31+
# Limit resources for CI runners (ubuntu-latest: 7GB RAM, 2 CPUs)
32+
build --local_resources=memory=4096
33+
build --local_resources=cpu=2
34+
build --jobs=2
35+
build --discard_analysis_cache
36+
build --nokeep_state_after_build
37+
# Allow network access in sandbox for Algolia API calls during SSR prerendering.
38+
build --sandbox_default_allow_network
3039
- name: Install Dependencies
3140
run: npm ci
3241
- name: Build Docs
33-
run: npm run build
42+
run: npm run build
43+
env:
44+
NODE_OPTIONS: --max-old-space-size=4096

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
/build
33
/tmp
44

5+
# Personal local Bazel overrides (see .bazelrc.user.example)
6+
.bazelrc.user
7+
58
# Node
69
/node_modules
710
npm-debug.log

tools/lib/common.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { watch } from 'chokidar';
2+
import { appendFile, readFile } from 'node:fs/promises';
23
import { resolve } from 'node:path';
34
import { $, cd, chalk, glob, within } from 'zx';
45
import { initDir, cpRf, exists } from './fileutiles.mjs';
@@ -19,6 +20,25 @@ export async function resetBuildDir({ init = false }) {
1920
await initDir(outDir);
2021
console.log(chalk.cyan('copying origin files to build directory...'));
2122
await cpRf(resolve(rootDir, 'origin'), outDir);
23+
await applyRootBazelrc();
24+
}
25+
}
26+
27+
/**
28+
* Propagates this repo's own .bazelrc, plus the personal .bazelrc.user (see
29+
* .bazelrc.user.example) if present, into the build directory as .bazelrc.user.
30+
* Bazel only reads .bazelrc.user from its own workspace root (build/), not from this repo's
31+
* root, and build/ is recreated on every run, so both must be copied in each time.
32+
*/
33+
async function applyRootBazelrc() {
34+
const dest = resolve(outDir, '.bazelrc.user');
35+
await cpRf(resolve(rootDir, '.bazelrc'), dest);
36+
37+
const userBazelrc = resolve(rootDir, '.bazelrc.user');
38+
if (await exists(userBazelrc)) {
39+
console.log(chalk.cyan('applying local .bazelrc.user overrides...'));
40+
const content = await readFile(userBazelrc, 'utf-8');
41+
await appendFile(dest, '\n' + content);
2242
}
2343
}
2444

0 commit comments

Comments
 (0)