From 8cf37e9e6c40da3274c65f24aecd89f11ef0b3c5 Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 5 Nov 2026 18:13:49 +0100 Subject: [PATCH] chore(ci): factorize the pnpm, Node.js and dependencies setup in a local action (AI-assisted) Add .github/actions/setup and use it in the read-only jobs. The pnpm store cache is opt-in. Dependabot must list the action directory, and the workflows with path filters also watch .github/actions. Co-Authored-By: Claude Opus 5.5 --- .github/actions/setup/action.yml | 36 ++++++++++++ .github/dependabot.yml | 3 +- .github/workflows/argos.yml | 18 +----- .github/workflows/build-blog-only.yml | 16 +----- .github/workflows/build-perf.yml | 17 ++---- .github/workflows/lint.yml | 16 +----- .github/workflows/showcase-test.yml | 16 +----- .github/workflows/tests-e2e.yml | 83 ++++++--------------------- .github/workflows/tests-swizzle.yml | 16 +----- .github/workflows/tests-windows.yml | 18 ++---- .github/workflows/tests.yml | 15 ++--- 11 files changed, 83 insertions(+), 171 deletions(-) create mode 100644 .github/actions/setup/action.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 000000000000..110b06f7be8f --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,36 @@ +name: Setup +description: Install pnpm, Node.js and the monorepo dependencies, after checking out the repository + +inputs: + node-version: + description: Node.js version to install + default: lts/* + cache: + description: Cache the pnpm store, off by default because a poisoned cache is a supply chain risk + default: 'false' + install: + description: Install the monorepo dependencies + default: 'true' + +runs: + using: composite + steps: + - name: Install pnpm + uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 + with: + # Only install pnpm: Node.js and dependencies are installed by later steps + install: false + node-version-file: false + + - name: Set up Node.js + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: ${{ inputs.node-version }} + check-latest: true + cache: ${{ inputs.cache == 'true' && 'pnpm' || '' }} + package-manager-cache: false + + - name: Install dependencies + if: inputs.install == 'true' + shell: bash + run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 307585e3bced..32c318dbcaa9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,8 @@ updates: ######################## # GITHUB ACTIONS UPDATES - package-ecosystem: github-actions - directory: '/' + # Composite actions must be listed: '/' only scans .github/workflows + directories: ['/', '/.github/actions/setup'] schedule: interval: weekly open-pull-requests-limit: 99 diff --git a/.github/workflows/argos.yml b/.github/workflows/argos.yml index 17af4de1bf76..ec0398c750fc 100644 --- a/.github/workflows/argos.yml +++ b/.github/workflows/argos.yml @@ -38,22 +38,10 @@ jobs: - name: Check out repository code uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 + - name: Set up pnpm, Node.js and dependencies + uses: ./.github/actions/setup with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - - name: Use Node.js - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - with: - node-version: lts/* - check-latest: true - cache: pnpm - - - name: Install dependencies - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + cache: true # Playwright is a dependency of the argos workspace package # With the pnpm isolated nodeLinker, its binary isn't available at the root diff --git a/.github/workflows/build-blog-only.yml b/.github/workflows/build-blog-only.yml index 0025d87fa2cf..1b16757f51b4 100644 --- a/.github/workflows/build-blog-only.yml +++ b/.github/workflows/build-blog-only.yml @@ -23,20 +23,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 + - name: Set up pnpm, Node.js and dependencies + uses: ./.github/actions/setup with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Set up Node - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - with: - node-version: lts/* - check-latest: true - cache: pnpm - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + cache: true - name: Build blog-only run: pnpm --filter website build:blogOnly env: diff --git a/.github/workflows/build-perf.yml b/.github/workflows/build-perf.yml index 666526a88180..4faca426868f 100644 --- a/.github/workflows/build-perf.yml +++ b/.github/workflows/build-perf.yml @@ -12,6 +12,7 @@ on: - docusaurus-v** paths: - .github/workflows/build-perf.yml + - .github/actions/** - package.json - pnpm-lock.yaml - packages/** @@ -87,20 +88,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 - with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Set up Node - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + - name: Set up pnpm, Node.js and dependencies + uses: ./.github/actions/setup with: - node-version: lts/* - check-latest: true - cache: pnpm - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + cache: true # Ensure build with a cold cache does not increase too much - name: Build (cold cache) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e31d3d496dc4..0c2dc41cc95a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,20 +21,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 + - name: Set up pnpm, Node.js and dependencies + uses: ./.github/actions/setup with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Set up Node - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - with: - node-version: lts/* - check-latest: true - cache: pnpm - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + cache: true - name: Check immutable pnpm-lock.yaml run: git diff --exit-code diff --git a/.github/workflows/showcase-test.yml b/.github/workflows/showcase-test.yml index eda683d053a7..a529e7242eba 100644 --- a/.github/workflows/showcase-test.yml +++ b/.github/workflows/showcase-test.yml @@ -23,19 +23,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 + - name: Set up pnpm, Node.js and dependencies + uses: ./.github/actions/setup with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Set up Node - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - with: - node-version: lts/* - check-latest: true - cache: pnpm - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + cache: true - name: Test run: pnpm test website/src/data/__tests__/user.test.ts diff --git a/.github/workflows/tests-e2e.yml b/.github/workflows/tests-e2e.yml index 30dc719e0326..9fbb6628cc2f 100644 --- a/.github/workflows/tests-e2e.yml +++ b/.github/workflows/tests-e2e.yml @@ -26,6 +26,7 @@ on: - admin/verdaccio.yaml - admin/scripts/test-release.sh - .github/workflows/tests-e2e.yml + - .github/actions/** concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -43,22 +44,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 - with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Use Node.js LTS - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - with: - node-version: lts/* - check-latest: true - # No pnpm cache on Windows on purpose: restoring it takes 20-80s, - # more than it saves on "pnpm install" - package-manager-cache: false - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + # No pnpm cache on Windows on purpose: restoring it takes 20-80s, + # more than it saves on "pnpm install" + - name: Set up pnpm, Node.js and dependencies + uses: ./.github/actions/setup - name: Generate test-website project against main branch # Not using test-release.sh => no verdaccio docker image on Windows # We have to generate the test website in workspace so that it uses @@ -103,19 +92,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 - with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + - name: Set up pnpm, Node.js ${{ matrix.node }} and dependencies + uses: ./.github/actions/setup with: node-version: ${{ matrix.node }} - cache: pnpm - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + cache: true - name: Generate test-website project against main branch run: pnpm test:build:website -s - name: Install test-website project with Yarn v1 @@ -150,20 +131,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 + - name: Set up pnpm, Node.js and dependencies + uses: ./.github/actions/setup with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Use Node.js LTS - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - with: - node-version: lts/* - check-latest: true - cache: pnpm - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + cache: true - name: Generate test-website project with ${{ matrix.variant }} against main branch run: pnpm test:build:website ${{ matrix.variant }} - name: Install test-website project with Yarn Berry and nodeLinker = ${{ matrix.nodeLinker }} @@ -236,20 +207,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 - with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Use Node.js LTS - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + - name: Set up pnpm, Node.js and dependencies + uses: ./.github/actions/setup with: - node-version: lts/* - check-latest: true - cache: pnpm - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + cache: true - name: Generate test-website project against main branch run: pnpm test:build:website -st - name: Install test-website project with npm @@ -283,20 +244,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 - with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Use Node.js LTS - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + - name: Set up pnpm, Node.js and dependencies + uses: ./.github/actions/setup with: - node-version: lts/* - check-latest: true - cache: pnpm - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + cache: true - name: Generate test-website project against main branch run: pnpm test:build:website -st - name: Install test-website project with pnpm diff --git a/.github/workflows/tests-swizzle.yml b/.github/workflows/tests-swizzle.yml index 3ad10f6ebba1..f052a2b8a06a 100644 --- a/.github/workflows/tests-swizzle.yml +++ b/.github/workflows/tests-swizzle.yml @@ -27,20 +27,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 + - name: Set up pnpm, Node.js and dependencies + uses: ./.github/actions/setup with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Set up Node LTS - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - with: - node-version: lts/* - check-latest: true - cache: pnpm - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + cache: true # Swizzle all the theme components - name: Swizzle (${{matrix.action}} - ${{matrix.variant}}) diff --git a/.github/workflows/tests-windows.yml b/.github/workflows/tests-windows.yml index c882e200e0eb..c52620ec0b2a 100644 --- a/.github/workflows/tests-windows.yml +++ b/.github/workflows/tests-windows.yml @@ -13,6 +13,7 @@ on: - packages/** - tsconfig.*.json - .github/workflows/tests-windows.yml + - .github/actions/** concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -34,21 +35,12 @@ jobs: run: git config --system core.longpaths true - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 - with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + # No pnpm cache on Windows on purpose: restoring it takes 20-80s, + # more than it saves on "pnpm install" + - name: Set up pnpm, Node.js ${{ matrix.node }} and dependencies + uses: ./.github/actions/setup with: node-version: ${{ matrix.node }} - # No pnpm cache on Windows on purpose: restoring it takes 20-80s, - # more than it saves on "pnpm install" - package-manager-cache: false - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile - name: Docusaurus Tests run: pnpm test - name: Create a deep path diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 54f8af98b3a6..311208dcb366 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,6 +13,7 @@ on: - packages/** - tsconfig.*.json - .github/workflows/tests.yml + - .github/actions/** concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -32,19 +33,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: Install pnpm - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2 - with: - # Only install pnpm: Node.js and dependencies are installed by later steps - install: false - node-version-file: false - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + - name: Set up pnpm, Node.js ${{ matrix.node }} and dependencies + uses: ./.github/actions/setup with: node-version: ${{ matrix.node }} - cache: pnpm - - name: Installation - run: pnpm install --frozen-lockfile || pnpm install --frozen-lockfile || pnpm install --frozen-lockfile + cache: true - name: Test run: pnpm test - name: TypeCheck tests