From d3f110cc03bc43a63a6c7469e47a0c03904018f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Tue, 22 Oct 2024 18:34:38 +0200 Subject: [PATCH] perf(ci): Add CI checks to prevent memory, build-time and build-size regressions (#10601) --- .github/workflows/build-perf.yml | 22 ++++++++++++++++++++-- .github/workflows/tests-e2e.yml | 16 ++++++++++++---- .github/workflows/tests.yml | 6 ++++-- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-perf.yml b/.github/workflows/build-perf.yml index 24953c270808..ef5ad00d5aac 100644 --- a/.github/workflows/build-perf.yml +++ b/.github/workflows/build-perf.yml @@ -11,6 +11,7 @@ on: - main - docusaurus-v** paths: + - .github/workflows/build-perf.yml - package.json - yarn.lock - packages/** @@ -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 @@ -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 @@ -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 @@ -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? diff --git a/.github/workflows/tests-e2e.yml b/.github/workflows/tests-e2e.yml index db3e5b25533b..ef9feadcc813 100644 --- a/.github/workflows/tests-e2e.yml +++ b/.github/workflows/tests-e2e.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 145790cecd7a..0a4d3599521d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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