ci_script.sh 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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. python -m pytest
  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. jlpm bumpversion next --force
  87. VERSION=$(python setup.py --version)
  88. if [[ $VERSION != *rc2 ]]; then exit 1; fi
  89. # make sure we can patch release
  90. jlpm bumpversion release --force # switch to final
  91. jlpm bumpversion patch --force
  92. jlpm bumpversion next --force
  93. # make sure we can bump major JS releases
  94. jlpm bumpversion minor --force
  95. jlpm bump:js:major console --force
  96. jlpm bump:js:major console notebook --force
  97. # Make sure that a prepublish would include the proper files.
  98. jlpm run prepublish:check
  99. fi
  100. if [[ $GROUP == release_test ]]; then
  101. # bump the version
  102. git checkout -b test HEAD
  103. jlpm bumpversion next --force
  104. # Use verdaccio during publish
  105. node buildutils/lib/local-repository.js start
  106. npm whoami
  107. jlpm run publish:js --yes
  108. jlpm run prepare:python-release
  109. cat jupyterlab/staging/package.json
  110. ./scripts/release_test.sh
  111. node buildutils/lib/local-repository.js stop
  112. fi
  113. if [[ $GROUP == examples ]]; then
  114. # Run the integrity script to link binary files
  115. jlpm integrity
  116. # Build the examples.
  117. jlpm run build:packages
  118. jlpm run build:examples
  119. # Test the examples
  120. jlpm run test:examples
  121. fi
  122. if [[ $GROUP == usage ]]; then
  123. # Run the integrity script to link binary files
  124. jlpm integrity
  125. # Test the cli apps.
  126. jupyter lab clean --debug
  127. jupyter lab build --debug
  128. jupyter lab path --debug
  129. pushd jupyterlab/tests/mock_packages
  130. jupyter labextension link mimeextension --no-build --debug
  131. jupyter labextension unlink mimeextension --no-build --debug
  132. jupyter labextension link mimeextension --no-build --debug
  133. jupyter labextension unlink @jupyterlab/mock-mime-extension --no-build --debug
  134. # Test with a source package install
  135. jupyter labextension install mimeextension --debug
  136. jupyter labextension list --debug
  137. jupyter labextension list 1>labextensions 2>&1
  138. cat labextensions | grep "@jupyterlab/mock-mime-extension.*enabled.*OK"
  139. python -m jupyterlab.browser_check
  140. jupyter labextension disable @jupyterlab/mock-mime-extension --debug
  141. jupyter labextension enable @jupyterlab/mock-mime-extension --debug
  142. jupyter labextension uninstall @jupyterlab/mock-mime-extension --no-build --debug
  143. # Test enable/disable and uninstall/install a core package
  144. jupyter labextension disable @jupyterlab/notebook-extension --debug
  145. jupyter labextension uninstall @jupyterlab/notebook-extension --no-build --debug
  146. jupyter labextension list 1>labextensions 2>&1
  147. cat labextensions | grep "Uninstalled core extensions:"
  148. jupyter labextension install @jupyterlab/notebook-extension --no-build --debug
  149. jupyter labextension enable @jupyterlab/notebook-extension --debug
  150. # Test with a prebuilt install
  151. jupyter labextension develop extension --debug
  152. jupyter labextension build extension
  153. # Test develop script with hyphens and underscores in the module name
  154. pip install -e test-hyphens
  155. jupyter labextension develop test-hyphens --overwrite --debug
  156. pip install -e test_no_hyphens
  157. jupyter labextension develop test_no_hyphens --overwrite --debug
  158. pip install -e test-hyphens-underscore
  159. jupyter labextension develop test-hyphens-underscore --overwrite --debug
  160. python -m jupyterlab.browser_check
  161. jupyter labextension list 1>labextensions 2>&1
  162. cat labextensions | grep "@jupyterlab/mock-extension.*enabled.*OK"
  163. jupyter labextension build extension --static-url /foo/
  164. jupyter labextension build extension --core-path ../../../examples/federated/core_package
  165. jupyter labextension disable @jupyterlab/mock-extension --debug
  166. jupyter labextension enable @jupyterlab/mock-extension --debug
  167. jupyter labextension uninstall @jupyterlab/mock-extension --debug
  168. jupyter labextension list 1>labextensions 2>&1
  169. # check the federated extension is still listed after jupyter labextension uninstall
  170. cat labextensions | grep -q "mock-extension"
  171. # build it again without a static-url to avoid causing errors
  172. jupyter labextension build extension
  173. popd
  174. jupyter lab workspaces export > workspace.json --debug
  175. jupyter lab workspaces import --name newspace workspace.json --debug
  176. jupyter lab workspaces export newspace > newspace.json --debug
  177. rm workspace.json newspace.json
  178. # Make sure we can call help on all the cli apps.
  179. jupyter lab -h
  180. jupyter lab build -h
  181. jupyter lab clean -h
  182. jupyter lab path -h
  183. jupyter labextension link -h
  184. jupyter labextension unlink -h
  185. jupyter labextension install -h
  186. jupyter labextension uninstall -h
  187. jupyter labextension list -h
  188. jupyter labextension enable -h
  189. jupyter labextension disable -h
  190. # Make sure we can run JupyterLab under classic notebook
  191. python -m jupyterlab.browser_check --notebook
  192. # Make sure we can add and remove a sibling package.
  193. # jlpm run add:sibling jupyterlab/tests/mock_packages/extension
  194. # jlpm run build
  195. # jlpm run remove:package extension
  196. # jlpm run build
  197. # jlpm run integrity --force # Should have a clean tree now
  198. # Test cli tools
  199. jlpm run get:dependency mocha
  200. jlpm run update:dependency mocha
  201. jlpm run remove:dependency mocha
  202. jlpm run get:dependency @jupyterlab/buildutils
  203. jlpm run get:dependency typescript
  204. jlpm run get:dependency react-native
  205. # Use the extension upgrade script
  206. pip install cookiecutter
  207. python -m jupyterlab.upgrade_extension --no-input jupyterlab/tests/mock_packages/extension
  208. # Test theme creation - make sure we can add it as a package, build,
  209. # and run browser
  210. pip install -q pexpect
  211. python scripts/create_theme.py
  212. mv foo packages
  213. jlpm run integrity
  214. jlpm run build:packages
  215. jlpm run build:dev
  216. python -m jupyterlab.browser_check --dev-mode
  217. jlpm run remove:package foo
  218. jlpm run integrity
  219. fi
  220. if [[ $GROUP == usage2 ]]; then
  221. ## Test app directory support being a symlink
  222. mkdir tmp
  223. pushd tmp
  224. mkdir real_app_dir
  225. ln -s real_app_dir link_app_dir
  226. # verify that app directory is resolved
  227. env JUPYTERLAB_DIR=./link_app_dir jupyter lab path | grep real_app_dir
  228. popd
  229. # Make sure we can successfully load the dev app.
  230. python -m jupyterlab.browser_check --dev-mode
  231. # Make sure core mode works
  232. jlpm run build:core
  233. # Make sure we have a final released version of JupyterLab server
  234. python -m jupyterlab.browser_check --core-mode
  235. # Make sure we can run the built app.
  236. jupyter labextension install ./jupyterlab/tests/mock_packages/extension --debug
  237. python -m jupyterlab.browser_check
  238. jupyter labextension list --debug
  239. # Make sure we can run watch mode with no built application
  240. jupyter lab clean
  241. python -m jupyterlab.browser_check --watch
  242. # Make sure we can non-dev install.
  243. virtualenv -p $(which python3) test_install
  244. ./test_install/bin/pip install -q ".[test]" # this populates <sys_prefix>/share/jupyter/lab
  245. ./test_install/bin/jupyter server extension list 1>serverextensions 2>&1
  246. cat serverextensions
  247. cat serverextensions | grep -i "jupyterlab.*enabled"
  248. cat serverextensions | grep -i "jupyterlab.*OK"
  249. # TODO: remove when we no longer support classic notebook
  250. ./test_install/bin/jupyter serverextension list 1>serverextensions 2>&1
  251. cat serverextensions
  252. cat serverextensions | grep -i "jupyterlab.*enabled"
  253. cat serverextensions | grep -i "jupyterlab.*OK"
  254. ./test_install/bin/python -m jupyterlab.browser_check
  255. # Make sure we can run the build
  256. ./test_install/bin/jupyter lab build
  257. # Make sure we can start and kill the lab server
  258. ./test_install/bin/jupyter lab --no-browser &
  259. TASK_PID=$!
  260. # Make sure the task is running
  261. ps -p $TASK_PID || exit 1
  262. sleep 5
  263. kill $TASK_PID
  264. wait $TASK_PID
  265. # Check the labhubapp
  266. ./test_install/bin/pip install jupyterhub
  267. export JUPYTERHUB_API_TOKEN="mock_token"
  268. ./test_install/bin/jupyter-labhub --HubOAuth.oauth_client_id="mock_id" &
  269. TASK_PID=$!
  270. unset JUPYTERHUB_API_TOKEN
  271. # Make sure the task is running
  272. ps -p $TASK_PID || exit 1
  273. sleep 5
  274. kill $TASK_PID
  275. # Make sure we can clean various bits of the app dir
  276. jupyter lab clean
  277. jupyter lab clean --extensions
  278. jupyter lab clean --settings
  279. jupyter lab clean --static
  280. jupyter lab clean --all
  281. fi
  282. if [[ $GROUP == splice_source ]]; then
  283. # Run the integrity script to link binary files
  284. jlpm integrity
  285. jupyter lab build --minimize=False --debug --dev-build=True --splice-source
  286. jupyter lab --version > version.txt
  287. cat version.txt
  288. cat version.txt | grep -q "spliced"
  289. python -m jupyterlab.browser_check
  290. cd jupyterlab/tests/mock_packages/mimeextension
  291. jupyter labextension install .
  292. python -m jupyterlab.browser_check
  293. jupyter lab --version > version.txt
  294. cat version.txt
  295. cat version.txt | grep -q "spliced"
  296. jupyter lab clean --all
  297. jupyter lab --version > version.txt
  298. cat version.txt
  299. cat version.txt | grep -q "spliced" && exit 1
  300. jupyter labextension install --splice-source .
  301. jupyter lab --version > version.txt
  302. cat version.txt | grep -q "spliced"
  303. python -m jupyterlab.browser_check
  304. fi
  305. if [[ $GROUP == interop ]]; then
  306. cd jupyterlab/tests/mock_packages/interop
  307. # Install a source extension that depends on a prebuilt extension
  308. pushd token
  309. jupyter labextension link . --no-build
  310. popd
  311. pushd provider
  312. jupyter labextension build .
  313. pip install .
  314. popd
  315. pushd consumer
  316. jupyter labextension install .
  317. popd
  318. jupyter labextension list 1>labextensions 2>&1
  319. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  320. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  321. python -m jupyterlab.browser_check
  322. # Clear install
  323. pip uninstall -y jlab_mock_provider
  324. jupyter lab clean --all
  325. # Install a prebuilt extension that depends on a source extension
  326. pushd token
  327. jupyter labextension link . --no-build
  328. popd
  329. pushd provider
  330. jupyter labextension install .
  331. popd
  332. pushd consumer
  333. jupyter labextension build .
  334. pip install .
  335. popd
  336. jupyter labextension list 1>labextensions 2>&1
  337. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  338. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  339. python -m jupyterlab.browser_check
  340. # Clear install
  341. pip uninstall -y jlab_mock_consumer
  342. jupyter lab clean --all
  343. # Install the mock consumer as a source extension and as a
  344. # prebuilt extension to test shadowing
  345. pushd token
  346. jupyter labextension link . --no-build
  347. popd
  348. pushd provider
  349. jupyter labextension install . --no-build
  350. popd
  351. pushd consumer
  352. # Need to install source first because it would get ignored
  353. # if installed after
  354. jupyter labextension install .
  355. jupyter labextension build .
  356. pip install .
  357. popd
  358. jupyter labextension list 1>labextensions 2>&1
  359. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  360. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  361. python -m jupyterlab.browser_check
  362. fi
  363. if [[ $GROUP == nonode ]]; then
  364. # Make sure we can install the wheel
  365. virtualenv -p $(which python3) test_install
  366. ./test_install/bin/pip install -v --pre --no-cache-dir --no-deps jupyterlab --no-index --find-links=dist # Install latest jupyterlab
  367. ./test_install/bin/pip install jupyterlab # Install jupyterlab dependencies
  368. ./test_install/bin/python -m jupyterlab.browser_check --no-browser-test
  369. # Make sure we can start and kill the lab server
  370. ./test_install/bin/jupyter lab --no-browser &
  371. TASK_PID=$!
  372. # Make sure the task is running
  373. ps -p $TASK_PID || exit 1
  374. sleep 5
  375. kill $TASK_PID
  376. wait $TASK_PID
  377. # Make sure we can install the tarball
  378. virtualenv -p $(which python3) test_sdist
  379. ./test_sdist/bin/pip install dist/*.tar.gz
  380. ./test_sdist/bin/python -m jupyterlab.browser_check --no-browser-test
  381. fi