ci_script.sh 13 KB

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