Skip to content

Commit

Permalink
perf(ci): Add CI checks to prevent memory, build-time and build-size …
Browse files Browse the repository at this point in the history
…regressions (#10601)
  • Loading branch information
slorber authored Oct 22, 2024
1 parent dbdd254 commit d3f110c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/build-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- main
- docusaurus-v**
paths:
- .github/workflows/build-perf.yml
- package.json
- yarn.lock
- packages/**
Expand All @@ -25,6 +26,7 @@ permissions:
contents: read

jobs:
# Posts a PR comment with build size differences from PR vs main branches
build-size:
permissions:
checks: write # for preactjs/compressed-size-action to create and update the checks
Expand All @@ -34,6 +36,9 @@ jobs:
name: Build Size Report
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
matrix:
DOCUSAURUS_INFRA: ['SLOWER', 'FASTER']
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -54,10 +59,18 @@ jobs:
strip-hash: '\.([^;]\w{7})\.'
minimum-change-threshold: 30
compression: none
comment-key: DOCUSAURUS_INFRA_${{ secrets.DOCUSAURUS_INFRA }}
env:
DOCUSAURUS_SLOWER: ${{ matrix.DOCUSAURUS_INFRA == 'SLOWER' && 'true' || 'false' }}

# Ensures build times stay under reasonable thresholds
build-time:
name: Build Time Perf
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
matrix:
DOCUSAURUS_INFRA: ['SLOWER', 'FASTER']
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -72,10 +85,15 @@ jobs:
# Ensure build with a cold cache does not increase too much
- name: Build (cold cache)
run: yarn build:website:fast
timeout-minutes: 8
timeout-minutes: ${{ matrix.DOCUSAURUS_INFRA == 'SLOWER' && 3 || 1 }}
env:
DOCUSAURUS_SLOWER: ${{ matrix.DOCUSAURUS_INFRA == 'SLOWER' && 'true' || 'false' }}

# Ensure build with a warm cache does not increase too much
- name: Build (warm cache)
run: yarn build:website:fast
timeout-minutes: 2
timeout-minutes: 1
env:
DOCUSAURUS_SLOWER: ${{ matrix.DOCUSAURUS_INFRA == 'SLOWER' && 'true' || 'false' }}

# TODO post a GitHub comment with build with perf warnings?
16 changes: 12 additions & 4 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ jobs:
env:
E2E_TEST: true
- name: Build test-website project
run: yarn build
# We build 2 locales to ensure a localized site doesn't leak memory
# See https://github.com/facebook/docusaurus/pull/10599
run: yarn build --locale en --locale fr
env:
# Our website should build even with limited memory
# See https://github.com/facebook/docusaurus/pull/10590
Expand Down Expand Up @@ -133,7 +135,9 @@ jobs:
yarn typecheck
- name: Build test-website project
run: yarn build
# We build 2 locales to ensure a localized site doesn't leak memory
# See https://github.com/facebook/docusaurus/pull/10599
run: yarn build --locale en --locale fr
env:
# Our website should build even with limited memory
# See https://github.com/facebook/docusaurus/pull/10590
Expand Down Expand Up @@ -168,7 +172,9 @@ jobs:
env:
E2E_TEST: true
- name: Build test-website project
run: npm run build
# We build 2 locales to ensure a localized site doesn't leak memory
# See https://github.com/facebook/docusaurus/pull/10599
run: npm run build -- --locale en --locale fr
env:
# Our website should build even with limited memory
# See https://github.com/facebook/docusaurus/pull/10590
Expand Down Expand Up @@ -206,7 +212,9 @@ jobs:
env:
E2E_TEST: true
- name: Build test-website project
run: pnpm run build
# We build 2 locales to ensure a localized site doesn't leak memory
# See https://github.com/facebook/docusaurus/pull/10599
run: pnpm run build --locale en --locale fr
env:
# Our website should build even with limited memory
# See https://github.com/facebook/docusaurus/pull/10590
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ jobs:
- name: Remove Theme Internal Re-export
run: yarn workspace @docusaurus/theme-common removeThemeInternalReexport
- name: Docusaurus Build
run: yarn build:website:fast
# We build 2 locales to ensure a localized site doesn't leak memory
# See https://github.com/facebook/docusaurus/pull/10599
run: yarn build:website:fast --locale en --locale fr
env:
# Our website should build even with limited memory
# See https://github.com/facebook/docusaurus/pull/10590
NODE_OPTIONS: '--max-old-space-size=350'
NODE_OPTIONS: '--max-old-space-size=400'
DOCUSAURUS_PERF_LOGGER: 'true'
- name: Docusaurus site CSS order
run: yarn workspace website test:css-order
Expand Down

0 comments on commit d3f110c

Please sign in to comment.