From f40cc55497535779890e3eaf7a54c01068e3e2a8 Mon Sep 17 00:00:00 2001 From: robonen Date: Mon, 8 Jun 2026 16:50:34 +0700 Subject: [PATCH] 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). --- .github/workflows/ci.yaml | 63 ++++++++++++++++++++++++++++++++------- docs/package.json | 1 + 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6689a35..835c5d1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 \ No newline at end of file + run: pnpm --filter "${{ matrix.package }}" --if-present run test diff --git a/docs/package.json b/docs/package.json index 36b8d23..b121f4a 100644 --- a/docs/package.json +++ b/docs/package.json @@ -8,6 +8,7 @@ "scripts": { "lint:check": "eslint .", "lint:fix": "eslint . --fix", + "test": "vitest run", "dev": "nuxt dev", "build": "nuxt build", "generate": "nuxt generate",