ci_script.sh 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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. # 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. # Test develop script with hyphens and underscores in the module name
  151. jupyter labextension develop test-hyphens --overwrite --debug
  152. jupyter labextension develop test_no_hyphens --overwrite --debug
  153. jupyter labextension develop test-hyphens-underscore --overwrite --debug
  154. python -m jupyterlab.browser_check
  155. jupyter labextension list 1>labextensions 2>&1
  156. cat labextensions | grep "@jupyterlab/mock-extension.*enabled.*OK"
  157. jupyter labextension build extension --static-url /foo/
  158. jupyter labextension disable @jupyterlab/mock-extension --debug
  159. jupyter labextension enable @jupyterlab/mock-extension --debug
  160. jupyter labextension uninstall @jupyterlab/mock-extension --debug
  161. jupyter labextension list 1>labextensions 2>&1
  162. # check the federated extension is still listed after jupyter labextension uninstall
  163. cat labextensions | grep -q "mock-extension"
  164. popd
  165. jupyter lab workspaces export > workspace.json --debug
  166. jupyter lab workspaces import --name newspace workspace.json --debug
  167. jupyter lab workspaces export newspace > newspace.json --debug
  168. rm workspace.json newspace.json
  169. # Make sure we can call help on all the cli apps.
  170. jupyter lab -h
  171. jupyter lab build -h
  172. jupyter lab clean -h
  173. jupyter lab path -h
  174. jupyter labextension link -h
  175. jupyter labextension unlink -h
  176. jupyter labextension install -h
  177. jupyter labextension uninstall -h
  178. jupyter labextension list -h
  179. jupyter labextension enable -h
  180. jupyter labextension disable -h
  181. # Make sure we can run JupyterLab under classic notebook
  182. python -m jupyterlab.browser_check --notebook
  183. # Make sure we can add and remove a sibling package.
  184. # jlpm run add:sibling jupyterlab/tests/mock_packages/extension
  185. # jlpm run build
  186. # jlpm run remove:package extension
  187. # jlpm run build
  188. # jlpm run integrity --force # Should have a clean tree now
  189. # Test cli tools
  190. jlpm run get:dependency mocha
  191. jlpm run update:dependency mocha
  192. jlpm run remove:dependency mocha
  193. jlpm run get:dependency @jupyterlab/buildutils
  194. jlpm run get:dependency typescript
  195. jlpm run get:dependency react-native
  196. # Use the extension upgrade script
  197. pip install cookiecutter
  198. python -m jupyterlab.upgrade_extension --no-input jupyterlab/tests/mock_packages/extension
  199. # Test theme creation - make sure we can add it as a package, build,
  200. # and run browser
  201. pip install -q pexpect
  202. python scripts/create_theme.py
  203. mv foo packages
  204. jlpm run integrity
  205. jlpm run build:packages
  206. jlpm run build:dev
  207. python -m jupyterlab.browser_check --dev-mode
  208. jlpm run remove:package foo
  209. jlpm run integrity
  210. ## Test app directory support being a symlink
  211. mkdir tmp
  212. pushd tmp
  213. mkdir real_app_dir
  214. ln -s real_app_dir link_app_dir
  215. # verify that app directory is resolved
  216. env JUPYTERLAB_DIR=./link_app_dir jupyter lab path | grep real_app_dir
  217. popd
  218. # Make sure we can successfully load the dev app.
  219. python -m jupyterlab.browser_check --dev-mode
  220. # Make sure core mode works
  221. jlpm run build:core
  222. # Make sure we have a final released version of JupyterLab server
  223. python -m jupyterlab.browser_check --core-mode
  224. # Make sure we can run the built app.
  225. jupyter labextension install ./jupyterlab/tests/mock_packages/extension --debug
  226. python -m jupyterlab.browser_check
  227. jupyter labextension list --debug
  228. # Make sure we can run watch mode with no built application
  229. jupyter lab clean
  230. python -m jupyterlab.browser_check --watch
  231. # Make sure we can non-dev install.
  232. virtualenv -p $(which python3) test_install
  233. ./test_install/bin/pip install -q ".[test]" # this populates <sys_prefix>/share/jupyter/lab
  234. ./test_install/bin/jupyter server extension list 1>serverextensions 2>&1
  235. cat serverextensions
  236. cat serverextensions | grep -i "jupyterlab.*enabled"
  237. cat serverextensions | grep -i "jupyterlab.*OK"
  238. # TODO: remove when we no longer support classic notebook
  239. ./test_install/bin/jupyter serverextension list 1>serverextensions 2>&1
  240. cat serverextensions
  241. cat serverextensions | grep -i "jupyterlab.*enabled"
  242. cat serverextensions | grep -i "jupyterlab.*OK"
  243. ./test_install/bin/python -m jupyterlab.browser_check
  244. # Make sure we can run the build
  245. ./test_install/bin/jupyter lab build
  246. # Make sure we can start and kill the lab server
  247. ./test_install/bin/jupyter lab --no-browser &
  248. TASK_PID=$!
  249. # Make sure the task is running
  250. ps -p $TASK_PID || exit 1
  251. sleep 5
  252. kill $TASK_PID
  253. wait $TASK_PID
  254. # Check the labhubapp
  255. ./test_install/bin/pip install jupyterhub
  256. export JUPYTERHUB_API_TOKEN="mock_token"
  257. ./test_install/bin/jupyter-labhub --HubOAuth.oauth_client_id="mock_id" &
  258. TASK_PID=$!
  259. unset JUPYTERHUB_API_TOKEN
  260. # Make sure the task is running
  261. ps -p $TASK_PID || exit 1
  262. sleep 5
  263. kill $TASK_PID
  264. # Make sure we can clean various bits of the app dir
  265. jupyter lab clean
  266. jupyter lab clean --extensions
  267. jupyter lab clean --settings
  268. jupyter lab clean --static
  269. jupyter lab clean --all
  270. fi
  271. if [[ $GROUP == interop ]]; then
  272. cd jupyterlab/tests/mock_packages/interop
  273. # Install a source extension that depends on a prebuilt extension
  274. pushd token
  275. jupyter labextension link . --no-build
  276. popd
  277. pushd provider
  278. jupyter labextension build .
  279. pip install .
  280. popd
  281. pushd consumer
  282. jupyter labextension install .
  283. popd
  284. jupyter labextension list 1>labextensions 2>&1
  285. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  286. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  287. python -m jupyterlab.browser_check
  288. # Clear install
  289. pip uninstall -y jlab_mock_provider
  290. jupyter lab clean --all
  291. # Install a prebuilt extension that depends on a source extension
  292. pushd token
  293. jupyter labextension link . --no-build
  294. popd
  295. pushd provider
  296. jupyter labextension install .
  297. popd
  298. pushd consumer
  299. jupyter labextension build .
  300. pip install .
  301. popd
  302. jupyter labextension list 1>labextensions 2>&1
  303. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  304. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  305. python -m jupyterlab.browser_check
  306. # Clear install
  307. pip uninstall -y jlab_mock_consumer
  308. jupyter lab clean --all
  309. # Install the mock consumer as a source extension and as a
  310. # prebuilt extension to test shadowing
  311. pushd token
  312. jupyter labextension link . --no-build
  313. popd
  314. pushd provider
  315. jupyter labextension install . --no-build
  316. popd
  317. pushd consumer
  318. # Need to install source first because it would get ignored
  319. # if installed after
  320. jupyter labextension install .
  321. jupyter labextension build .
  322. pip install .
  323. popd
  324. jupyter labextension list 1>labextensions 2>&1
  325. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  326. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  327. python -m jupyterlab.browser_check
  328. fi
  329. if [[ $GROUP == nonode ]]; then
  330. # Make sure we can install the wheel
  331. virtualenv -p $(which python3) test_install
  332. ./test_install/bin/pip install -v --pre --no-cache-dir --no-deps jupyterlab --no-index --find-links=dist # Install latest jupyterlab
  333. ./test_install/bin/pip install jupyterlab # Install jupyterlab dependencies
  334. ./test_install/bin/python -m jupyterlab.browser_check --no-chrome-test
  335. # Make sure we can start and kill the lab server
  336. ./test_install/bin/jupyter lab --no-browser &
  337. TASK_PID=$!
  338. # Make sure the task is running
  339. ps -p $TASK_PID || exit 1
  340. sleep 5
  341. kill $TASK_PID
  342. wait $TASK_PID
  343. # Make sure we can install the tarball
  344. virtualenv -p $(which python3) test_sdist
  345. ./test_sdist/bin/pip install dist/*.tar.gz
  346. ./test_sdist/bin/python -m jupyterlab.browser_check --no-chrome-test
  347. fi