Skip to content

Commit

Permalink
Enable lerna caching for build scripts (#6767)
Browse files Browse the repository at this point in the history
* Enable lerna caching for build scripts

* Fix script definitions

* Lint

* simplify cacheable tasks

* Update to lerna 7

* update config

* cleanup

* Stay on lerna 6 for now

* Revert "cleanup"

This reverts commit c061fc0.

* lint

* Skip cache when building prod

* Cache labextension builds

* Update `targetDefaults`

* Update dev command

* Fix dependencies

* Add missing dependency

* fix dep order

* fix script deps

* Update scripts

* Update scripts dependencies

* Add back scripts

* lint

* cache more

* Mention task caching in contributing guide
  • Loading branch information
jtpio authored Jul 31, 2023
1 parent 2270c04 commit ac3c882
Show file tree
Hide file tree
Showing 10 changed files with 1,191 additions and 1,093 deletions.
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tasks:
source /workspace/bin/activate-env.sh
micromamba install -n base -y -c conda-forge python=3.11 nodejs=18
source /workspace/bin/activate-env.sh
python -m pip install -e ".[dev,test]" && jlpm && jlpm run build && jlpm develop
python -m pip install -e ".[dev,test]" && jlpm run build && jlpm develop
gp sync-done setup
command: |
gp sync-done setup
Expand Down
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ Running the end to end tests in headful mode will trigger something like the fol

![playwight-headed-demo](https://user-images.githubusercontent.com/591645/141274633-ca9f9c2f-eef6-430e-9228-a35827f8133d.gif)

## Tasks caching

The repository is configured to use the Lerna caching system (via `nx`) for some of the development scripts.

This helps speed up rebuilds when running `jlpm run build` multiple times to avoid rebuilding packages that have not changed on disk.

To learn more about Lerna caching:

- https://lerna.js.org/docs/features/cache-tasks
- https://nx.dev/core-features/cache-task-results

### Updating reference snapshots

Often a PR might make changes to the user interface, which can cause the visual regression tests to fail.
Expand Down
5 changes: 4 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@
"@jupyterlab/tooltip-extension": "^4.0.3",
"@jupyterlab/translation-extension": "^4.0.3",
"@jupyterlab/ui-components-extension": "^4.0.3",
"@jupyterlab/vega5-extension": "^4.0.3"
"@jupyterlab/vega5-extension": "^4.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"yjs": "^13.5.40"
},
"devDependencies": {
"@jupyterlab/builder": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"npmClient": "jlpm",
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "independent",
"useWorkspaces": true
}
35 changes: 35 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"build",
"build:prod",
"build:lib",
"build:labextension:dev",
"build:labextension"
]
}
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*"]
},
"targetDefaults": {
"build:lib": {
"dependsOn": ["^build:lib"],
"inputs": ["default", "^default"],
"outputs": ["{projectRoot}/lib"]
},
"build": {
"dependsOn": ["^build"],
"inputs": ["default", "^default"]
},
"build:prod": {
"dependsOn": ["^build:prod"],
"inputs": ["default", "^default"]
}
}
}
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
"packages/*"
]
},
"nx": {},
"scripts": {
"build": "lerna run build",
"build:prod": "lerna run build:prod",
"build:lib": "lerna run build:lib",
"build:prod": "lerna run build:prod --skip-nx-cache",
"build:test": "lerna run build:test",
"build:utils": "cd buildutils && npm run build",
"clean": "lerna run clean",
Expand Down Expand Up @@ -50,10 +52,15 @@
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"lerna": "^6.5.1",
"lerna": "^6.6.2",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.5",
"rimraf": "^3.0.2",
"typescript": "~5.0.2"
},
"resolutions": {
"@types/react": "^18.0.26",
"react": "^18.2.0",
"yjs": "^13.5.40"
}
}
1 change: 1 addition & 0 deletions packages/docmanager-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"watch": "tsc -b --watch"
},
"dependencies": {
"@jupyter-notebook/application": "^7.0.0",
"@jupyterlab/application": "^4.0.3",
"@jupyterlab/coreutils": "^6.0.3",
"@jupyterlab/docmanager": "^4.0.3",
Expand Down
7 changes: 6 additions & 1 deletion packages/docmanager-extension/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
"outDir": "lib",
"rootDir": "src"
},
"include": ["src/**/*"]
"include": ["src/**/*"],
"references": [
{
"path": "../application"
}
]
}
39 changes: 36 additions & 3 deletions packages/lab-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,51 @@
"style/index.js"
],
"scripts": {
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
"build": "jlpm run build:labextension:dev",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"build:lib": "tsc",
"build:prod": "jlpm run build:lib && jlpm run build:labextension",
"build:lib": "tsc -b",
"build:prod": "jlpm run build:labextension",
"clean": "jlpm run clean:lib && jlpm run clean:labextension",
"clean:labextension": "rimraf ../../notebook/labextension",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"watch": "run-p watch:src watch:labextension",
"watch:labextension": "jupyter labextension watch .",
"watch:src": "tsc -w"
},
"nx": {
"targets": {
"build:labextension:dev": {
"dependsOn": [
"^build:lib",
"build:lib"
],
"outputs": [
"{workspaceRoot}/notebook/labextension",
"{workspaceRoot}/notebook/labextension/build_log.json"
]
},
"build:labextension": {
"dependsOn": [
"^build:lib",
"build:lib"
],
"outputs": [
"{workspaceRoot}/notebook/labextension"
]
},
"build": {
"dependsOn": [
"build:labextension:dev"
]
},
"build:prod": {
"dependsOn": [
"build:labextension"
]
}
}
},
"dependencies": {
"@jupyter-notebook/application": "^7.0.0",
"@jupyterlab/application": "^4.0.3",
Expand Down
Loading

0 comments on commit ac3c882

Please sign in to comment.