Skip to content

Anchor the Nx workspace root to each checkout - #3461

Merged
lresende merged 1 commit into
elyra-ai:mainfrom
lresende:fix-nx-workspace-root
Nov 15, 2026
Merged

lresende merged 1 commit into
elyra-ai:mainfrom
lresende:fix-nx-workspace-root

Conversation

@lresende

@lresende lresende commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Lerna runs its tasks through Nx. Without an nx.json, Nx takes the outermost directory that has node_modules/nx as its workspace root, so a checkout nested inside another one builds the outer checkout. This is what happens to the clone create-release.py makes under build/release/elyra. Its labextensions are never built, so the release wheels and extension packages ship without the UI, while every step reports success. #3460 has the details, reproduction steps, and the NX_WORKSPACE_ROOT_PATH workaround for branches without this fix.

  • nx.json (new) anchors the Nx workspace root at the checkout. It defines no targets, so lerna keeps its default task behavior. It also pins the settings Nx changes as soon as an nx.json exists, so everything else behaves as it does today:
    • "useDaemonProcess": false. Without nx.json, Nx never starts its daemon. With the file present, local runs would launch one.
    • pluginsConfig["@nx/js"] with analyzeLockfile: false and analyzeSourceFiles: false. Nx skips lockfile analysis in lerna repositories without nx.json (lerna/lerna#3807) and turns it on once the file exists. Adding any @nx/js options also turns on source-file analysis by default.
  • .gitignore: ignore .nx/, where Nx now keeps its cache and workspace data instead of node_modules/.cache/nx*.
  • Makefile: make purge, and therefore make clean, also removes .nx. Before this change, that data was removed along with node_modules.
  • create-release.py: after make release, verify_labextensions_built() fails the release if any labextensions/elyra_* package is missing its built labextension/package.json. A build without the UI can no longer be packaged silently.
  • elyra/tests/test_create_release.py (new): tests for that check.
  • pyproject.toml: omit create-release.py from coverage measurement. The new tests import the script, which would otherwise add all of it to the project total and fail codecov/project (-1.88%). The script ships in no package, and most of it only runs during a real release.

Fixes #3460

How was this pull request tested?

All runs below were done from a checkout nested inside another checkout (both with dependencies installed), with NX_WORKSPACE_ROOT_PATH unset.

  • yarn lerna list --all --json: before this change, all 12 packages resolved into the outer checkout. With it, all 12 resolve inside the nested checkout.
  • Ran the release packaging functions from create-release.py (build_server, build_release, prepare_extensions_release, pre-release mode) in the nested checkout:
    • Lerna ran build:prod for all 12 projects there, and the new check reported 12 built labextensions.
    • The elyra wheel contains 131 files under share/jupyter/labextensions (12 labextensions), and each of the five extension wheels contains its UI.
    • The outer checkout's packages/*/lib, labextensions/*/labextension/package.json, and node_modules/.yarn-state.yml were not modified.
  • Parity with current behavior: I compared the Nx project graph that lerna builds without nx.json (root set through NX_WORKSPACE_ROOT_PATH) with the one built with this nx.json. They are identical: 12 projects, 19 dependency edges between them, no external nodes, and no lockfile parsing. Without the pluginsConfig pin, Nx parsed yarn.lock and added 1,900 external nodes. Without useDaemonProcess: false, local runs launched the Nx daemon.
  • yarn lerna run clean:lintcache --verbose logs "Nx target configuration was not found. Task dependencies will not be automatically included." This is lerna's default task mode, and the target ran for all 12 projects.
  • pytest elyra/tests/test_create_release.py: 4 passed. A fully built tree passes. One missing build, all builds missing, and no packages each fail and name what is missing.
  • Coverage, run with --cov as in make pytest: before the omit, the report included create-release.py (511 statements, 11% covered by these tests). With it, that file is the only one removed (41 to 40 measured files).
  • Ran prettier on nx.json, and black and flake8 on the changed Python files.

Developer's Certificate of Origin 1.1

   By making a contribution to this project, I certify that:

   (a) The contribution was created in whole or in part by me and I
       have the right to submit it under the Apache License 2.0; or

   (b) The contribution is based upon previous work that, to the best
       of my knowledge, is covered under an appropriate open source
       license and I have the right under that license to submit that
       work with modifications, whether created in whole or in part
       by me, under the same open source license (unless I am
       permitted to submit under a different license), as indicated
       in the file; or

   (c) The contribution was provided directly to me by some other
       person who certified (a), (b) or (c) and I have not modified
       it.

   (d) I understand and agree that this project and the contribution
       are public and that a record of the contribution (including all
       personal information I submit with it, including my sign-off) is
       maintained indefinitely and may be redistributed consistent with
       this project or the open source license(s) involved.

@lresende lresende added kind:bug Something isn't working component:build build and build related issues(dependencies and docker) labels Nov 15, 2026
@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.85%. Comparing base (7b72694) to head (59a99df).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3461      +/-   ##
==========================================
+ Coverage   84.82%   84.85%   +0.02%     
==========================================
  Files         159      160       +1     
  Lines       19297    19327      +30     
  Branches      500      502       +2     
==========================================
+ Hits        16369    16399      +30     
  Misses       2889     2889              
  Partials       39       39              
Flag Coverage Δ
integration-editors 48.21% <ø> (ø)
integration-misc 25.64% <ø> (ø)
integration-pipeline 47.62% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
elyra/tests/test_create_release.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Lerna runs its tasks through Nx. Without an nx.json, Nx takes the
outermost directory that has node_modules/nx as its workspace root, so
a checkout nested inside another one builds the outer checkout. This
happens to the clone create-release.py makes under build/release and
to git worktrees inside the repo. Lerna still reports success, but the
nested checkout's labextensions are never built, and the wheels and
extension packages it produces ship without any UI.

Add an nx.json so Nx stops at the current checkout. It defines no
targets, so lerna keeps its default task behavior. It also pins the
settings Nx changes once the file exists: the daemon stays off, and
the JS plugin still skips lockfile and source file analysis. The
resulting project graph matches the one built without nx.json.

With nx.json present, Nx keeps its cache and workspace data in .nx/
instead of node_modules/.cache, so ignore that directory and remove it
in make purge.

Also make create-release.py fail when make release leaves any
labextension unbuilt, instead of packaging wheels without the UI.
The tests for that check import the script, so omit it from coverage
measurement: it ships in no package, and its release steps would
otherwise count against the project coverage total.

Fixes elyra-ai#3460

Signed-off-by: Luciano Resende <lresende@apple.com>
@lresende
lresende force-pushed the fix-nx-workspace-root branch from f23fa93 to 59a99df Compare November 15, 2026 00:23
@lresende
lresende merged commit 12f0d4e into elyra-ai:main Nov 15, 2026
19 checks passed
@lresende
lresende deleted the fix-nx-workspace-root branch November 15, 2026 15:31
@lresende lresende added this to the 4.3.0 milestone Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:build build and build related issues(dependencies and docker) kind:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lerna/Nx builds the outer checkout when Elyra is nested in another checkout

1 participant