ci: run build, lint and test in parallel per package
Replace the single monorepo CI job with a dynamic matrix: a discover job enumerates workspace packages, then one job per package builds it (with its workspace deps), lints and tests in parallel (fail-fast: false). Chromium is installed only for the browser-mode suites (primitives, editor). Adds a 'test' script to @robonen/docs so its suite runs under the per-package model (the root vitest projects list isn't used by CI anymore).
This commit is contained in:
+52
-11
@@ -5,16 +5,21 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
NODE_VERSION: 24.x
|
||||
|
||||
jobs:
|
||||
code-quality:
|
||||
name: Code quality checks
|
||||
# Enumerate the workspace packages so the matrix below fans out one job per
|
||||
# package (kept dynamic so new packages are picked up automatically).
|
||||
discover:
|
||||
name: Discover packages
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
outputs:
|
||||
packages: ${{ steps.list.outputs.packages }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
@@ -31,14 +36,50 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: List workspace packages
|
||||
id: list
|
||||
run: echo "packages=$(pnpm -r ls --depth -1 --json | jq -c '[.[] | select(.name != "tools") | .name]')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# One job per package — build (with its workspace deps), lint and test run in
|
||||
# parallel across packages. fail-fast: false so every package is reported.
|
||||
check:
|
||||
name: ${{ matrix.package }}
|
||||
needs: discover
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
package: ${{ fromJSON(needs.discover.outputs.packages) }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6
|
||||
with:
|
||||
run_install: false
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
# Build the package and the workspace deps it relies on (incl. @robonen/eslint,
|
||||
# which every package's lint config imports from its built dist).
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
run: pnpm --filter "${{ matrix.package }}..." --if-present run build
|
||||
|
||||
- name: Lint
|
||||
run: pnpm lint:check
|
||||
|
||||
- name: Install Playwright browser
|
||||
# Only the browser-mode test suites (vitest `instances: chromium`) need a browser.
|
||||
- name: Install Playwright Chromium
|
||||
if: matrix.package == '@robonen/primitives' || matrix.package == '@robonen/editor'
|
||||
run: pnpm exec playwright install --with-deps chromium
|
||||
|
||||
- name: Lint
|
||||
run: pnpm --filter "${{ matrix.package }}" --if-present run lint:check
|
||||
|
||||
- name: Test
|
||||
run: pnpm test
|
||||
run: pnpm --filter "${{ matrix.package }}" --if-present run test
|
||||
|
||||
Reference in New Issue
Block a user