ci_script.sh 14 KB

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