diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.yml index d90c21004..372157b02 100644 --- a/.github/workflows/code-check.yml +++ b/.github/workflows/code-check.yml @@ -4,6 +4,10 @@ on: pull_request: branches: ["*"] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: lint: runs-on: ubuntu-latest @@ -151,6 +155,41 @@ jobs: - run: pnpm registry-deps:check + build: + runs-on: ubuntu-latest + name: pnpm build + steps: + - uses: actions/checkout@v6 + + # pnpm must be installed before setup-node so its built-in pnpm cache works + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + version: 9.15.0 + run_install: false + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: Restore Next.js build cache + uses: actions/cache@v4 + with: + path: apps/www/.next/cache + key: ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('apps/www/**/*.[jt]s', 'apps/www/**/*.[jt]sx', 'apps/www/**/*.mdx') }} + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}- + + - name: Build + run: pnpm build + env: + NEXT_PUBLIC_APP_URL: https://magicui.design + registry-drift: runs-on: ubuntu-latest name: registry artifact drift check diff --git a/apps/www/.prettierignore b/apps/www/.prettierignore index de9bec424..4bbbe0809 100644 --- a/apps/www/.prettierignore +++ b/apps/www/.prettierignore @@ -1 +1,4 @@ registry/__index__.tsx +registry.json +public/registry.json +public/r/ diff --git a/lefthook.yml b/lefthook.yml index b2fedf9eb..f1f257c64 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -3,21 +3,31 @@ pre-commit: commands: build:registry: glob: "**/registry/**/*.{ts,tsx}" - run: pnpm build:registry && git add --all - stage_fixed: true - typecheck: - glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}" - run: pnpm typecheck - stage_fixed: true + # www-scoped script only (the root build:registry also runs a + # whole-project lint:fix + format:fix). Stage generated artifacts + # by explicit path — never `git add --all`. CI's registry-drift job + # checks these same paths, so a new artifact path can't slip through. + run: > + pnpm --filter=www build:registry && + git add apps/www/registry.json apps/www/registry/__index__.tsx + apps/www/public/registry.json apps/www/public/r + apps/www/public/llms.txt apps/www/public/llms-full.txt lint:fix: - glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}" - run: pnpm lint:fix + root: "apps/www/" + glob: "*.{js,ts,cjs,mjs,jsx,tsx}" + run: pnpm exec eslint --fix --no-warn-ignored {staged_files} stage_fixed: true - format:fix:silent: - glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}" - run: pnpm format:fix:silent + format:fix: + root: "apps/www/" + glob: "*.{js,ts,cjs,mjs,jsx,tsx,json,jsonc,mdx}" + run: pnpm exec prettier --log-level silent --write --cache {staged_files} stage_fixed: true +pre-push: + commands: + typecheck: + run: pnpm typecheck + commit-msg: commands: "lint commit message":