Skip to content

fix: prevent Bazel OOM crash on CI runners #226

fix: prevent Bazel OOM crash on CI runners

fix: prevent Bazel OOM crash on CI runners #226

# This workflow builds the previews for pull requests when a certain label is applied.
# The actual deployment happens as part of a dedicated second workflow to avoid security
# issues where the building would otherwise occur in an authorized context where secrets
# could be leaked. More details can be found here:
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
name: Build adev for preview deployment
on:
pull_request:
types: [synchronize, labeled]
permissions: read-all
jobs:
adev-build:
runs-on: ubuntu-latest
if: |
(github.event.action == 'labeled' && github.event.label.name == 'adev: preview') ||
(github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'adev: preview'))
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
- name: setup pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # 4.1.0
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: '.node-version'
cache: pnpm
- uses: bazel-contrib/setup-bazel@4fd964a13a440a8aeb0be47350db2fc640f19ca8 # 0.15.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
bazelrc: |
# Limit resources for CI runners (ubuntu-latest: 7GB RAM, 2 CPUs)
build --local_ram_resources=4096
build --local_cpu_resources=2
build --jobs=2
build --discard_analysis_cache
build --nokeep_state_after_build
- run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
env:
_JAVA_OPTIONS: -Xms512m -Xmx2g
NODE_OPTIONS: --max-old-space-size=4096
- uses: angular/dev-infra/github-actions/previews/pack-and-upload-artifact@0512a5b9381ccff00c278d7b4b6ee38e5c09654d
with:
workflow-artifact-name: 'adev-preview'
pull-number: '${{ github.event.pull_request.number }}'
artifact-build-revision: '${{github.event.pull_request.head.sha}}'
deploy-directory: './build/dist/bin/adev/dist/browser'