🐛 Fix library checks in local CI

Build the library bundle before running its tests so changes cannot pass
against stale output. Use the package's format command for fix mode and
cover both commands in the orchestrator tests.

AI-assisted-by: gpt-6.1-terra
This commit is contained in:
Andrey Antukh 2026-11-23 22:17:26 +00:00
parent 048bb28744
commit f5430134e6
4 changed files with 17 additions and 5 deletions

View File

@ -3,5 +3,5 @@
- `library/` exposes a JS builder for in-memory files and `.penpot` exports. Start at `library/src/lib/builder.cljs` for the JS boundary, `app.common.files.builder` for state changes, and `library/src/lib/export.cljs` for the archive. Usage is in `library/README.md`; commands are in `package.json`.
- The builder carries a current file, page and parent stack: add a file before a page and close nested boards or groups in order. Closing a group requires children and computes its geometry; a masked group uses its first child as the mask. `addBool` transforms an existing group rather than creating a separate object. See `app.common.files.builder` for the change records and compatibility feature defaults.
- Export writes ZIP entries sequentially, realizing delayed JSON or blob data as each entry is written. Preserve that ordering and laziness when changing progress or adding entries; `on-progress` follows each completed entry. The manifest carries the optional builder `referer`.
- Tests import `#self`, which resolves to `target/library/penpot.js`. From `library/`, rebuild with `pnpm run build:bundle` before `pnpm run test`, or the tests can run against a stale bundle. `library/scripts/test` performs both but also installs dependencies. The default `./scripts/ci library` checks do not build the bundle; see `mem:scripts/ci`.
- Tests import `#self`, which resolves to `target/library/penpot.js`. From `library/`, rebuild with `pnpm run build:bundle` before a direct `pnpm run test`, or tests can run against a stale bundle. `./scripts/ci library` builds it before testing without the install step in `library/scripts/test`; see `mem:scripts/ci`.
- Changes to file construction in `common/` can affect this external builder even when the app still works. For cross-cutting test design see `mem:testing`; for migrations see `mem:common/file-migrations`.

View File

@ -3,7 +3,7 @@
- From the repo root, use `./scripts/ci MODULE...` for the selected modules' lint, tests and format check. Build is opt-in. Run `./scripts/ci --help` for flags, modules and commands; `--dry-run` previews them without executing. For test design and output discipline, read `mem:testing`.
- Pass every changed module. A `common` change can affect frontend, backend, exporter and library; select affected consumers too. Backend lint includes common sources but its format task does not check common, so include `common` explicitly.
- The script appends `enable-backend-asserts` to `PENPOT_FLAGS`. Backend assertions are selected when code loads; running tests without the flag can compile them out. See `mem:backend/testing`.
- The default library test runs the existing bundle, unlike GitHub CI, which rebuilds first. Rebuild before relying on the result; see `mem:library/core`. `--fix library` currently calls the nonexistent `fmt:clj` script: from `library/` use `pnpm run fmt` instead until the orchestrator is corrected.
- The library test task builds its bundle before running tests, like GitHub CI. Direct `pnpm run test` does not rebuild it; see `mem:library/core`. `--fix library` uses the package's `fmt` script.
- `--build` uses module build commands but does not run by default or package deployable bundles. It avoids some cache-clearing wrappers; consult the command in `scripts/ci` rather than assuming every module's build has identical behavior. Native WASM build scripts serialize through a lock, but manual Cargo commands do not; see `mem:render-wasm/core`.
- `mcp` and `media-processor` have no lint task and are reported as skipped. The exporter test task supplies a fallback test secret when absent. `scripts/test_ci.py` tests orchestrator wiring and dry runs, not the module builds themselves.
- Full task logs are in `.ci-logs/<module>-<task>.log`; inspect them after failure and do not pipe test output directly to filters. `--dry-run` executes no tasks. For long full-module runs allow ample time. The `local-ci` skill is the verification entry point.

View File

@ -47,7 +47,7 @@ declare -A TEST_CMD=(
[exporter]="PENPOT_SECRET_KEY=${PENPOT_SECRET_KEY:-test-secret-key} pnpm run test:quiet"
[mcp]="pnpm run test"
[plugins]="pnpm run test"
[library]="pnpm run test"
[library]="pnpm run build:bundle && pnpm run test"
[media-processor]="pnpm run test"
)
@ -71,7 +71,7 @@ declare -A FMT_FIX_CMD=(
[exporter]="pnpm run fmt:clj"
[mcp]="pnpm run fmt"
[plugins]="pnpm run format"
[library]="pnpm run fmt:clj"
[library]="pnpm run fmt"
[media-processor]="pnpm run fmt"
)

View File

@ -73,7 +73,7 @@ class BuildTaskTests(unittest.TestCase):
code, out = run_ci("--dry-run", "--all")
self.assertEqual(code, 0, out)
self.assertNotIn("build:", out)
self.assertNotIn("build: would run", out)
for task in ("lint", "test", "fmt"):
self.assertIn(f"{task}: would run", out)
@ -145,6 +145,18 @@ class ModuleCommandTests(unittest.TestCase):
self.assertEqual(code, 0, out)
self.assertIn("pnpm run check-fmt", out)
def test_library_format_fix_uses_its_declared_script(self):
code, out = run_ci("--fmt", "--fix", "--dry-run", "library")
self.assertEqual(code, 0, out)
self.assertIn("fmt: would run 'pnpm run fmt' in library/", out)
def test_library_tests_rebuild_the_bundle_first(self):
code, out = run_ci("--test", "--dry-run", "library")
self.assertEqual(code, 0, out)
self.assertIn("pnpm run build:bundle && pnpm run test", out)
class HelpTests(unittest.TestCase):
def help_options(self, out):