Skip to content

Build production regression prevention framework #5274

Build production regression prevention framework

Build production regression prevention framework #5274

Workflow file for this run

name: TypeScript Type Check
on:
pull_request:
push:
branches:
- main
- master
- develop
jobs:
typecheck:
name: Nx affected typecheck
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Required for `nx affected --base/--head` on PRs; shallow clones can miss the base SHA.
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Cache Nx computation cache
uses: actions/cache@v4
with:
path: .nx/cache
key: nx-cache-${{ runner.os }}-${{ hashFiles('package-lock.json', 'nx.json', 'tsconfig.base.json', '**/project.json') }}
restore-keys: |
nx-cache-${{ runner.os }}-
- name: Upgrade npm to version 11
run: npm install -g npm@11
- name: Install dependencies
run: |
if ! npm ci; then
echo "npm ci failed; attempting npm install fallback to regenerate lock data"
npm install --legacy-peer-deps
fi
- name: Determine Nx base/head
shell: bash
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "NX_BASE=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
echo "NX_HEAD=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
else
echo "NX_BASE=${{ github.event.before }}" >> $GITHUB_ENV
echo "NX_HEAD=${{ github.sha }}" >> $GITHUB_ENV
fi
# ubuntu-latest runners have 16 GB RAM. The `server` (and `sebastian-ee`) app
# typechecks pull in the whole type graph and each need ~10-14 GB on their own,
# so they cannot share the runner with any other concurrent tsc. Running the full
# `nx affected` set in parallel let two heavy typechecks overlap and OOM-killed the
# runner ("received a shutdown signal" / "operation was canceled"), even though the
# typecheck itself had no errors. We split into two passes:
# 1. All libraries in parallel (capped heap × parallelism stays under 16 GB).
# 2. The heavy apps serially, each with the whole box to itself.
# Pass 2 re-evaluates `affected` but the libraries are instant Nx cache hits from
# pass 1, so it only does real work for the apps — and only when they are affected.
- name: Nx affected typecheck (libraries, parallel)
run: npx nx affected -t typecheck --base=$NX_BASE --head=$NX_HEAD --output-style=static --parallel=2 --exclude=server,sebastian-ee
env:
NX_DAEMON: 'false'
# 2 concurrent × 6 GB = 12 GB, leaving headroom for the runner.
NODE_OPTIONS: '--max-old-space-size=6144'
- name: Nx affected typecheck (apps, isolated & serial)
run: npx nx affected -t typecheck --base=$NX_BASE --head=$NX_HEAD --output-style=static --parallel=1
env:
NX_DAEMON: 'false'
# Each app runs alone with the whole box; 14 GB leaves headroom for the runner.
NODE_OPTIONS: '--max-old-space-size=14336'