8000 ci: run the checks through Nx, and only for the projects a change affects by adeelahmad · Pull Request #303 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

ci: run the checks through Nx, and only for the projects a change affects - #303

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-dn8sba
Oct 10, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-dn8sba

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: every pull request ran the whole backend suite twice and the whole frontend build, whatever it changed, and each make target and CI step spelled out its own commands.

After: Nx is the monorepo's task runner. CI asks it which projects a change affects and runs only those: a docs-only PR builds the site and skips the backend and frontend jobs; a backend PR skips Next.js. make test-backend, make lint-frontend and friends run the same Nx targets as CI and replay from the local cache when nothing they read changed. make affected checks just what your branch touches.

  • Workspace: root package.json (Nx is its one dependency, pnpm like the frontend), nx.json (shared inputs, target defaults, neverConnectToCloud, analytics: false), and a project.json per project: backend (lint, format, typecheck, test with :ci and :server, openapi-check, openapi), frontend (lint, typecheck, test, build, generate-client), installer (test), docs (build, serve). The apps keep their own pyproject.toml/uv.lock and package.json/pnpm-lock.yaml; no lockfile moves, Dockerfiles untouched.
  • CI (ci.yml): a first job, Affected projects, uses nrwl/nx-set-shas (a PR is compared with the main it merges into, a push to main with main's last green run) and lists the affected projects in its summary. FastAPI (embedded SurrealDB), FastAPI (SurrealDB server) and Next.js keep their names and steps, run the project.json targets, and run only when their project is affected; a skipped job counts as passed, so they stay valid required checks. If the affected job itself fails, every job runs. A new Other projects job runs lint/typecheck/test/build for every other affected project, so the browser extensions and the desktop app join CI with just a project.json. A change to nx.json, root package.json or ci.yml affects everything; running CI by hand checks everything. CI skips Nx's cache (NX_SKIP_NX_CACHE), so every task runs fresh.
  • docs.yml now builds and publishes on main only; on PRs, Other projects builds the site with the same command and the same paths (docs/, mkdocs.yml, overrides/, README.md, CHANGELOG.md).
  • Dependabot watches the root package; docs/contributing.md has a new "Monorepo and CI (Nx)" section (projects, commands, how CI decides, how to add a project); AGENTS.md and CONTRIBUTING.md point at it.

Motivation and Context

Adeel asked to use Nx as the monorepo build system and CI. Several threads are adding projects in parallel (web clipper builds, desktop app); this lands the skeleton early so each one folds in with a project.json.

How

nx show projects --affected maps changed files to projects by folder, plus root files a target names in its inputs (checked locally: README.md → docs, nextjs-frontend/openapi.json → frontend and backend's openapi-check, ci.yml/nx.json/package.json → all, Makefile → none). Locally on this branch: backend lint, typecheck, openapi-check (and a failing run after editing openapi.json), backend tests (make affected, 3m49s), frontend lint, typecheck, test:ci (731 passed) and build, docs build, installer tests, and pre-commit run --all-files all pass through Nx.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests. (n/a for new test code: CI itself is the test; every target was run locally and this PR's own CI exercises the full path, since ci.yml changes affect every project.)
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md. (n/a: contributor tooling only.)

Done questions (AGENTS.md)

  • Goal: delivers what the user wanted, merged on green CI. (Merging on green.)
  • Agents: agents run make affected or pnpm exec nx …; non-TTY output is plain (TUI off), and AGENTS.md says so.
  • Zero setup: n/a for the product install (nothing in any image or install path changes). For contributors, make installs Nx on first use with the pnpm they already have.
  • Fewest clicks and keystrokes: make affected is one command; CI needs no change to pick up a new project.
  • Configurable: n/a, no product settings.
  • Light: n/a for the Pi install (Nx is dev/CI only, in no image). CI does less work per PR.
  • Private and secure: Nx Cloud never connected, Nx analytics off, cache stays in .nx/ on the machine. No new runtime surface; the threat model already scopes CI tooling out (.github/, ci/).
  • Cost: n/a for model calls; fewer CI minutes per PR.
  • User decides: existing make targets and check names unchanged; make test-backend etc. behave the same apart from the cache replay (--skip-nx-cache to force).
  • Upgrades: n/a, no stored data.
  • Honest: docs describe only what this PR adds.
  • Tests, docs and generated files updated (pnpm-lock.yaml from pnpm install).
  • Open standards; Nx and nx-set-shas are MIT.
  • Result reported with evidence; "refine later" below.

Refine later

🤖 Generated with Claude Code

https://claude.ai/code/session_018t1esJmuFFT1yrtmWSPHqz


Generated by Claude Code

…ects

Nx becomes the monorepo's task runner. The root package.json brings Nx (its
only dependency); nx.json holds the shared inputs and target defaults, and
each project has a project.json: backend (fastapi_backend), frontend
(nextjs-frontend), installer and docs. The apps keep their own package files.

CI's first job, Affected projects, asks Nx which projects a change affects
(nrwl/nx-set-shas picks the base: the main a PR merges into, or main's last
green run). The FastAPI and Next.js jobs keep their names and run only when
their project is affected; a skipped job counts as passed. A new Other
projects job runs the lint, typecheck, test and build targets of every other
affected project, so a new project.json is all a new project needs to join
CI; it now builds the docs site on pull requests in place of docs.yml.

The make targets wrap the same Nx targets and come back from Nx's local
cache when nothing changed; `make affected` checks only what changed. Nx
Cloud is never connected and Nx's analytics are off.

C
A1EE
o-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018t1esJmuFFT1yrtmWSPHqz
@adeelahmad adeelahmad self-assigned this Oct 10, 2026
@adeelahmad
adeelahmad merged commit 24bcf36 into main Oct 10, 2026
14 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-dn8sba branch October 10, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0