ci_script.sh 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. #!/bin/bash
  2. # Copyright (c) Jupyter Development Team.
  3. # Distributed under the terms of the Modified BSD License.
  4. set -ex
  5. set -o pipefail
  6. if [[ $GROUP != nonode ]]; then
  7. python -c "from jupyterlab.commands import build_check; build_check()"
  8. fi
  9. if [[ $GROUP == python ]]; then
  10. jupyter lab build --debug
  11. # Run the python tests
  12. py.test
  13. fi
  14. if [[ $GROUP == js* ]]; then
  15. if [[ $GROUP == "js-testutils" ]]; then
  16. pushd testutils
  17. else
  18. # extract the group name
  19. export PKG="${GROUP#*-}"
  20. pushd packages/${PKG}
  21. fi
  22. jlpm run build:test; true
  23. export FORCE_COLOR=1
  24. CMD="jlpm run test:cov"
  25. $CMD || $CMD || $CMD
  26. jlpm run clean
  27. fi
  28. if [[ $GROUP == docs ]]; then
  29. # Build the docs (includes API docs)
  30. pushd docs
  31. conda env create -f environment.yml
  32. conda init --all
  33. source $CONDA/bin/activate jupyterlab_documentation
  34. make html
  35. conda deactivate
  36. popd
  37. fi
  38. if [[ $GROUP == integrity ]]; then
  39. # Run the integrity script first
  40. jlpm run integrity --force
  41. # Check yarn.lock file
  42. jlpm check --integrity
  43. # Run a browser check in dev mode
  44. jlpm run build
  45. python -m jupyterlab.browser_check --dev-mode
  46. fi
  47. if [[ $GROUP == lint ]]; then
  48. # Lint our files.
  49. jlpm run lint:check || (echo 'Please run `jlpm run lint` locally and push changes' && exit 1)
  50. fi
  51. if [[ $GROUP == integrity2 ]]; then
  52. # Run the integrity script to link binary files
  53. jlpm integrity
  54. # Check the manifest
  55. check-manifest -v
  56. # Build the packages individually.
  57. jlpm run build:src
  58. # Make sure we can build for release
  59. jlpm run build:dev:prod:release
  60. # Make sure the storybooks build.
  61. jlpm run build:storybook
  62. jlpm config set prefix ~/.yarn
  63. # Make sure we have CSS that can be converted with postcss
  64. jlpm global add postcss postcss-cli
  65. ~/.yarn/bin/postcss packages/**/style/*.css --dir /tmp
  66. # run twine check on the python build assets.
  67. # this must be done before altering any versions below.
  68. python -m pip install -U twine wheel build
  69. python -m build .
  70. twine check dist/*
  71. fi
  72. if [[ $GROUP == integrity3 ]]; then
  73. # Make sure we can bump the version
  74. # This must be done at the end so as not to interfere
  75. # with the other checks
  76. git config --global user.email "you@example.com"
  77. git config --global user.name "CI"
  78. git stash
  79. git checkout -b commit_${BUILD_SOURCEVERSION}
  80. git clean -df
  81. jlpm bumpversion minor --force
  82. jlpm bumpversion major --force
  83. jlpm bumpversion release --force # switch to beta
  84. jlpm bumpversion release --force # switch to rc
  85. jlpm bumpversion build --force
  86. VERSION=$(python setup.py --version)
  87. if [[ $VERSION != *rc1 ]]; then exit 1; fi
  88. # make sure we can patch release
  89. jlpm bumpversion release --force # switch to final
  90. jlpm bumpversion patch --force
  91. # make sure we can bump major JS releases
  92. jlpm bumpversion minor --force
  93. jlpm bump:js:major console --force
  94. jlpm bump:js:major console notebook --force
  95. # Make sure that a prepublish would include the proper files.
  96. jlpm run prepublish:check
  97. fi
  98. if [[ $GROUP == release_check ]]; then
  99. jlpm run publish:js --dry-run
  100. jlpm run prepare:python-release
  101. ./scripts/release_test.sh
  102. # Prep for using verdaccio during publish
  103. node buildutils/lib/local-repository.js start
  104. npm whoami
  105. pushd packages/application
  106. npm version patch
  107. npm publish
  108. popd
  109. node buildutils/lib/local-repository.js stop
  110. fi
  111. if [[ $GROUP == examples ]]; then
  112. # Run the integrity script to link binary files
  113. jlpm integrity
  114. # Build the examples.
  115. jlpm run build:packages
  116. jlpm run build:examples
  117. # Test the examples
  118. jlpm run test:examples
  119. fi
  120. if [[ $GROUP == usage ]]; then
  121. # Run the integrity script to link binary files
  122. jlpm integrity
  123. # Test the cli apps.
  124. jupyter lab clean --debug
  125. jupyter lab build --debug
  126. jupyter lab path --debug
  127. pushd jupyterlab/tests/mock_packages
  128. jupyter labextension link mimeextension --no-build --debug
  129. jupyter labextension unlink mimeextension --no-build --debug
  130. jupyter labextension link mimeextension --no-build --debug
  131. jupyter labextension unlink @jupyterlab/mock-mime-extension --no-build --debug
  132. # Test with a source package install
  133. jupyter labextension install mimeextension --debug
  134. jupyter labextension list --debug
  135. jupyter labextension list 1>labextensions 2>&1
  136. cat labextensions | grep "@jupyterlab/mock-mime-extension.*enabled.*OK"
  137. python -m jupyterlab.browser_check
  138. jupyter labextension disable @jupyterlab/mock-mime-extension --debug
  139. jupyter labextension enable @jupyterlab/mock-mime-extension --debug
  140. jupyter labextension uninstall @jupyterlab/mock-mime-extension --no-build --debug
  141. # Test enable/disable and uninstall/install a core package
  142. jupyter labextension disable @jupyterlab/notebook-extension --debug
  143. jupyter labextension uninstall @jupyterlab/notebook-extension --no-build --debug
  144. jupyter labextension list 1>labextensions 2>&1
  145. cat labextensions | grep "Uninstalled core extensions:"
  146. jupyter labextension install @jupyterlab/notebook-extension --no-build --debug
  147. jupyter labextension enable @jupyterlab/notebook-extension --debug
  148. # Test with a prebuilt install
  149. jupyter labextension develop extension --debug
  150. jupyter labextension build extension
  151. # Test develop script with hyphens and underscores in the module name
  152. pip install -e test-hyphens
  153. jupyter labextension develop test-hyphens --overwrite --debug
  154. pip install -e test_no_hyphens
  155. jupyter labextension develop test_no_hyphens --overwrite --debug
  156. pip install -e test-hyphens-underscore
  157. jupyter labextension develop test-hyphens-underscore --overwrite --debug
  158. python -m jupyterlab.browser_check
  159. jupyter labextension list 1>labextensions 2>&1
  160. cat labextensions | grep "@jupyterlab/mock-extension.*enabled.*OK"
  161. jupyter labextension build extension --static-url /foo/
  162. jupyter labextension build extension --core-path ../../../examples/federated/core_package
  163. jupyter labextension disable @jupyterlab/mock-extension --debug
  164. jupyter labextension enable @jupyterlab/mock-extension --debug
  165. jupyter labextension uninstall @jupyterlab/mock-extension --debug
  166. jupyter labextension list 1>labextensions 2>&1
  167. # check the federated extension is still listed after jupyter labextension uninstall
  168. cat labextensions | grep -q "mock-extension"
  169. # build it again without a static-url to avoid causing errors
  170. jupyter labextension build extension
  171. popd
  172. jupyter lab workspaces export > workspace.json --debug
  173. jupyter lab workspaces import --name newspace workspace.json --debug
  174. jupyter lab workspaces export newspace > newspace.json --debug
  175. rm workspace.json newspace.json
  176. # Make sure we can call help on all the cli apps.
  177. jupyter lab -h
  178. jupyter lab build -h
  179. jupyter lab clean -h
  180. jupyter lab path -h
  181. jupyter labextension link -h
  182. jupyter labextension unlink -h
  183. jupyter labextension install -h
  184. jupyter labextension uninstall -h
  185. jupyter labextension list -h
  186. jupyter labextension enable -h
  187. jupyter labextension disable -h
  188. # Make sure we can run JupyterLab under classic notebook
  189. python -m jupyterlab.browser_check --notebook
  190. # Make sure we can add and remove a sibling package.
  191. # jlpm run add:sibling jupyterlab/tests/mock_packages/extension
  192. # jlpm run build
  193. # jlpm run remove:package extension
  194. # jlpm run build
  195. # jlpm run integrity --force # Should have a clean tree now
  196. # Test cli tools
  197. jlpm run get:dependency mocha
  198. jlpm run update:dependency mocha
  199. jlpm run remove:dependency mocha
  200. jlpm run get:dependency @jupyterlab/buildutils
  201. jlpm run get:dependency typescript
  202. jlpm run get:dependency react-native
  203. # Use the extension upgrade script
  204. pip install cookiecutter
  205. python -m jupyterlab.upgrade_extension --no-input jupyterlab/tests/mock_packages/extension
  206. # Test theme creation - make sure we can add it as a package, build,
  207. # and run browser
  208. pip install -q pexpect
  209. python scripts/create_theme.py
  210. mv foo packages
  211. jlpm run integrity
  212. jlpm run build:packages
  213. jlpm run build:dev
  214. python -m jupyterlab.browser_check --dev-mode
  215. jlpm run remove:package foo
  216. jlpm run integrity
  217. fi
  218. if [[ $GROUP == usage2 ]]; then
  219. ## Test app directory support being a symlink
  220. mkdir tmp
  221. pushd tmp
  222. mkdir real_app_dir
  223. ln -s real_app_dir link_app_dir
  224. # verify that app directory is resolved
  225. env JUPYTERLAB_DIR=./link_app_dir jupyter lab path | grep real_app_dir
  226. popd
  227. # Make sure we can successfully load the dev app.
  228. python -m jupyterlab.browser_check --dev-mode
  229. # Make sure core mode works
  230. jlpm run build:core
  231. # Make sure we have a final released version of JupyterLab server
  232. python -m jupyterlab.browser_check --core-mode
  233. # Make sure we can run the built app.
  234. jupyter labextension install ./jupyterlab/tests/mock_packages/extension --debug
  235. python -m jupyterlab.browser_check
  236. jupyter labextension list --debug
  237. # Make sure we can run watch mode with no built application
  238. jupyter lab clean
  239. python -m jupyterlab.browser_check --watch
  240. # Make sure we can non-dev install.
  241. virtualenv -p $(which python3) test_install
  242. ./test_install/bin/pip install -q ".[test]" # this populates <sys_prefix>/share/jupyter/lab
  243. ./test_install/bin/jupyter server extension list 1>serverextensions 2>&1
  244. cat serverextensions
  245. cat serverextensions | grep -i "jupyterlab.*enabled"
  246. cat serverextensions | grep -i "jupyterlab.*OK"
  247. # TODO: remove when we no longer support classic notebook
  248. ./test_install/bin/jupyter serverextension list 1>serverextensions 2>&1
  249. cat serverextensions
  250. cat serverextensions | grep -i "jupyterlab.*enabled"
  251. cat serverextensions | grep -i "jupyterlab.*OK"
  252. ./test_install/bin/python -m jupyterlab.browser_check
  253. # Make sure we can run the build
  254. ./test_install/bin/jupyter lab build
  255. # Make sure we can start and kill the lab server
  256. ./test_install/bin/jupyter lab --no-browser &
  257. TASK_PID=$!
  258. # Make sure the task is running
  259. ps -p $TASK_PID || exit 1
  260. sleep 5
  261. kill $TASK_PID
  262. wait $TASK_PID
  263. # Check the labhubapp
  264. ./test_install/bin/pip install jupyterhub
  265. export JUPYTERHUB_API_TOKEN="mock_token"
  266. ./test_install/bin/jupyter-labhub --HubOAuth.oauth_client_id="mock_id" &
  267. TASK_PID=$!
  268. unset JUPYTERHUB_API_TOKEN
  269. # Make sure the task is running
  270. ps -p $TASK_PID || exit 1
  271. sleep 5
  272. kill $TASK_PID
  273. # Make sure we can clean various bits of the app dir
  274. jupyter lab clean
  275. jupyter lab clean --extensions
  276. jupyter lab clean --settings
  277. jupyter lab clean --static
  278. jupyter lab clean --all
  279. fi
  280. if [[ $GROUP == splice_source ]]; then
  281. # Run the integrity script to link binary files
  282. jlpm integrity
  283. jupyter lab build --minimize=False --debug --dev-build=True --splice-source
  284. jupyter lab --version > version.txt
  285. cat version.txt
  286. cat version.txt | grep -q "spliced"
  287. python -m jupyterlab.browser_check
  288. cd jupyterlab/tests/mock_packages/mimeextension
  289. jupyter labextension install .
  290. python -m jupyterlab.browser_check
  291. jupyter lab --version > version.txt
  292. cat version.txt
  293. cat version.txt | grep -q "spliced"
  294. jupyter lab clean --all
  295. jupyter lab --version > version.txt
  296. cat version.txt
  297. cat version.txt | grep -q "spliced" && exit 1
  298. jupyter labextension install --splice-source .
  299. jupyter lab --version > version.txt
  300. cat version.txt | grep -q "spliced"
  301. python -m jupyterlab.browser_check
  302. fi
  303. if [[ $GROUP == interop ]]; then
  304. cd jupyterlab/tests/mock_packages/interop
  305. # Install a source extension that depends on a prebuilt extension
  306. pushd token
  307. jupyter labextension link . --no-build
  308. popd
  309. pushd provider
  310. jupyter labextension build .
  311. pip install .
  312. popd
  313. pushd consumer
  314. jupyter labextension install .
  315. popd
  316. jupyter labextension list 1>labextensions 2>&1
  317. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  318. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  319. python -m jupyterlab.browser_check
  320. # Clear install
  321. pip uninstall -y jlab_mock_provider
  322. jupyter lab clean --all
  323. # Install a prebuilt extension that depends on a source extension
  324. pushd token
  325. jupyter labextension link . --no-build
  326. popd
  327. pushd provider
  328. jupyter labextension install .
  329. popd
  330. pushd consumer
  331. jupyter labextension build .
  332. pip install .
  333. popd
  334. jupyter labextension list 1>labextensions 2>&1
  335. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  336. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  337. python -m jupyterlab.browser_check
  338. # Clear install
  339. pip uninstall -y jlab_mock_consumer
  340. jupyter lab clean --all
  341. # Install the mock consumer as a source extension and as a
  342. # prebuilt extension to test shadowing
  343. pushd token
  344. jupyter labextension link . --no-build
  345. popd
  346. pushd provider
  347. jupyter labextension install . --no-build
  348. popd
  349. pushd consumer
  350. # Need to install source first because it would get ignored
  351. # if installed after
  352. jupyter labextension install .
  353. jupyter labextension build .
  354. pip install .
  355. popd
  356. jupyter labextension list 1>labextensions 2>&1
  357. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  358. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  359. python -m jupyterlab.browser_check
  360. fi
  361. if [[ $GROUP == nonode ]]; then
  362. # Make sure we can install the wheel
  363. virtualenv -p $(which python3) test_install
  364. ./test_install/bin/pip install -v --pre --no-cache-dir --no-deps jupyterlab --no-index --find-links=dist # Install latest jupyterlab
  365. ./test_install/bin/pip install jupyterlab # Install jupyterlab dependencies
  366. ./test_install/bin/python -m jupyterlab.browser_check --no-browser-test
  367. # Make sure we can start and kill the lab server
  368. ./test_install/bin/jupyter lab --no-browser &
  369. TASK_PID=$!
  370. # Make sure the task is running
  371. ps -p $TASK_PID || exit 1
  372. sleep 5
  373. kill $TASK_PID
  374. wait $TASK_PID
  375. # Make sure we can install the tarball
  376. virtualenv -p $(which python3) test_sdist
  377. ./test_sdist/bin/pip install dist/*.tar.gz
  378. ./test_sdist/bin/python -m jupyterlab.browser_check --no-browser-test
  379. fi