From f7614081dd37dc118e988d80b7ff40e897ff137a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Thu, 25 Mar 2021 17:30:49 +0100 Subject: [PATCH] ci(v2): fail CI if build takes too much time (#4516) * remove the .cache folder so that it removes both webpack cache-loader-v4/persistent-cache-v5 + webpack terser cache * Add GH action to track build time perf with a timeout * Add GH action to track build time perf with a timeout --- .github/workflows/v2-build-blog-only.yml | 2 +- .github/workflows/v2-build-time-perf.yml | 35 +++++++++++++++++++++++ packages/docusaurus/src/commands/clear.ts | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/v2-build-time-perf.yml diff --git a/.github/workflows/v2-build-blog-only.yml b/.github/workflows/v2-build-blog-only.yml index d7faa1ffee1c..9ba3644979f4 100644 --- a/.github/workflows/v2-build-blog-only.yml +++ b/.github/workflows/v2-build-blog-only.yml @@ -9,7 +9,7 @@ on: - 'packages/docusaurus/**' jobs: - lint: + build: timeout-minutes: 30 runs-on: ubuntu-latest steps: diff --git a/.github/workflows/v2-build-time-perf.yml b/.github/workflows/v2-build-time-perf.yml new file mode 100644 index 000000000000..5bb609134610 --- /dev/null +++ b/.github/workflows/v2-build-time-perf.yml @@ -0,0 +1,35 @@ +name: V2 Build Time Perf + +on: + pull_request: + branches: + - master + paths-ignore: + - 'website/docs/**' + - 'website-1.x/**' + - 'packages/docusaurus-1.x/**' + - 'packages/docusaurus-init-1.x/**' + +jobs: + build: + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + - name: Installation + uses: bahmutov/npm-install@v1 + with: + install-command: yarn + + # Ensure build with a cold cache does not increase too much + - name: Build (cold cache) + run: yarn workspace docusaurus-2-website build + timeout-minutes: 10 + + # Ensure build with a warm cache does not increase too much + - name: Build (warm cache) + run: yarn workspace docusaurus-2-website build + timeout-minutes: 10 + + # TODO post a Github comment with build with perf warnings? diff --git a/packages/docusaurus/src/commands/clear.ts b/packages/docusaurus/src/commands/clear.ts index 84634f3031fe..03389606659d 100644 --- a/packages/docusaurus/src/commands/clear.ts +++ b/packages/docusaurus/src/commands/clear.ts @@ -25,6 +25,6 @@ export default async function clear(siteDir: string): Promise { return Promise.all([ removePath(path.join(siteDir, GENERATED_FILES_DIR_NAME)), removePath(path.join(siteDir, DEFAULT_BUILD_DIR_NAME)), - removePath(path.join(siteDir, 'node_modules/.cache/cache-loader')), + removePath(path.join(siteDir, 'node_modules', '.cache')), ]); }