ci_script.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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 tutorial docs
  30. pushd docs
  31. pip install -r ./requirements.txt
  32. make html
  33. popd
  34. # Build the API docs
  35. jlpm build:packages
  36. jlpm docs
  37. fi
  38. if [[ $GROUP == linkcheck ]]; then
  39. # Build the tutorial docs
  40. pushd docs
  41. pip install -r ./requirements.txt
  42. make html
  43. popd
  44. # Run the link check on the built html files
  45. CACHE_DIR="${HOME}/.cache/pytest-link-check"
  46. mkdir -p ${CACHE_DIR}
  47. echo "Existing cache:"
  48. ls -ltr ${CACHE_DIR}
  49. # Expire links after a week
  50. LINKS_EXPIRE=604800
  51. args="--check-links --check-links-cache --check-links-cache-expire-after ${LINKS_EXPIRE} --check-links-cache-name ${CACHE_DIR}/cache"
  52. args="--ignore docs/build/html/genindex.html --ignore docs/build/html/search.html ${args}"
  53. py.test $args --links-ext .html -k .html docs/build/html || py.test $args --links-ext .html -k .html --lf docs/build/html
  54. # Run the link check on md files - allow for a link to fail once (--lf means only run last failed)
  55. args="--check-links --check-links-cache --check-links-cache-expire-after ${LINKS_EXPIRE} --check-links-cache-name ${CACHE_DIR}/cache"
  56. py.test $args --links-ext .md -k .md . || py.test $args --links-ext .md -k .md --lf .
  57. fi
  58. if [[ $GROUP == integrity ]]; then
  59. # Run the integrity script first
  60. jlpm run integrity --force
  61. # Check yarn.lock file
  62. jlpm check --integrity
  63. # Run a browser check in dev mode
  64. jlpm run build
  65. python -m jupyterlab.browser_check --dev-mode
  66. fi
  67. if [[ $GROUP == lint ]]; then
  68. # Lint our files.
  69. jlpm run lint:check || (echo 'Please run `jlpm run lint` locally and push changes' && exit 1)
  70. fi
  71. if [[ $GROUP == integrity2 ]]; then
  72. # Run the integrity script to link binary files
  73. jlpm integrity
  74. # Build the packages individually.
  75. jlpm run build:src
  76. # Make sure we can build for release
  77. jlpm run build:dev:prod:release
  78. # Make sure the storybooks build.
  79. jlpm run build:storybook
  80. # Make sure we have CSS that can be converted with postcss
  81. jlpm global add postcss postcss-cli
  82. jlpm config set prefix ~/.yarn
  83. ~/.yarn/bin/postcss packages/**/style/*.css --dir /tmp
  84. # run twine check on the python build assets.
  85. # this must be done before altering any versions below.
  86. python -m pip install -U twine wheel build
  87. python -m build .
  88. twine check dist/*
  89. # Make sure we can bump the version
  90. # This must be done at the end so as not to interfere
  91. # with the other checks
  92. git config --global user.email "you@example.com"
  93. git config --global user.name "CI"
  94. git stash
  95. git checkout -b commit_${BUILD_SOURCEVERSION}
  96. git clean -df
  97. jlpm bumpversion minor --force
  98. jlpm bumpversion major --force
  99. jlpm bumpversion release --force # switch to beta
  100. jlpm bumpversion release --force # switch to rc
  101. jlpm bumpversion build --force
  102. VERSION=$(python setup.py --version)
  103. if [[ $VERSION != *rc1 ]]; then exit 1; fi
  104. # make sure we can patch release
  105. jlpm bumpversion release --force # switch to final
  106. jlpm patch:release --force
  107. # make sure we can bump major JS releases
  108. jlpm bumpversion minor --force
  109. jlpm bump:js:major console --force
  110. jlpm bump:js:major console notebook --force
  111. # Make sure that a prepublish would include the proper files.
  112. jlpm run prepublish:check
  113. fi
  114. if [[ $GROUP == examples ]]; then
  115. # Run the integrity script to link binary files
  116. jlpm integrity
  117. # Build the examples.
  118. jlpm run build:packages
  119. jlpm run build:examples
  120. # Test the examples
  121. jlpm run test:examples
  122. fi
  123. if [[ $GROUP == usage ]]; then
  124. # Run the integrity script to link binary files
  125. jlpm integrity
  126. # Test the cli apps.
  127. jupyter lab clean --debug
  128. jupyter lab build --debug
  129. jupyter lab path --debug
  130. pushd jupyterlab/tests/mock_packages
  131. jupyter labextension link extension --no-build --debug
  132. jupyter labextension unlink extension --no-build --debug
  133. jupyter labextension link extension --no-build --debug
  134. jupyter labextension unlink @jupyterlab/mock-extension --no-build --debug
  135. # Test with a full install
  136. jupyter labextension install extension --no-build --debug
  137. jupyter labextension list --debug
  138. jupyter labextension disable @jupyterlab/mock-extension --debug
  139. jupyter labextension enable @jupyterlab/mock-extension --debug
  140. jupyter labextension disable @jupyterlab/notebook-extension --debug
  141. jupyter labextension uninstall @jupyterlab/mock-extension --no-build --debug
  142. jupyter labextension uninstall @jupyterlab/notebook-extension --no-build --debug
  143. # Test with a dynamic install
  144. jupyter labextension develop extension --debug
  145. jupyter labextension build extension
  146. python -m jupyterlab.browser_check
  147. jupyter labextension list 1>labextensions 2>&1
  148. cat labextensions | grep "@jupyterlab/mock-extension.*enabled.*OK"
  149. jupyter labextension build extension --static-url /foo/
  150. jupyter labextension disable @jupyterlab/mock-extension --debug
  151. jupyter labextension enable @jupyterlab/mock-extension --debug
  152. jupyter labextension uninstall @jupyterlab/mock-extension --debug
  153. jupyter labextension list 1>labextensions 2>&1
  154. # bail if mock-extension was listed
  155. cat labextensions | grep -q "mock-extension" && exit 1
  156. popd
  157. jupyter lab workspaces export > workspace.json --debug
  158. jupyter lab workspaces import --name newspace workspace.json --debug
  159. jupyter lab workspaces export newspace > newspace.json --debug
  160. rm workspace.json newspace.json
  161. # Make sure we can call help on all the cli apps.
  162. jupyter lab -h
  163. jupyter lab build -h
  164. jupyter lab clean -h
  165. jupyter lab path -h
  166. jupyter labextension link -h
  167. jupyter labextension unlink -h
  168. jupyter labextension install -h
  169. jupyter labextension uninstall -h
  170. jupyter labextension list -h
  171. jupyter labextension enable -h
  172. jupyter labextension disable -h
  173. # Make sure we can run JupyterLab under classic notebook
  174. python -m jupyterlab.browser_check --notebook
  175. # Make sure we can add and remove a sibling package.
  176. # jlpm run add:sibling jupyterlab/tests/mock_packages/extension
  177. # jlpm run build
  178. # jlpm run remove:package extension
  179. # jlpm run build
  180. # jlpm run integrity --force # Should have a clean tree now
  181. # Test cli tools
  182. jlpm run get:dependency mocha
  183. jlpm run update:dependency mocha
  184. jlpm run remove:dependency mocha
  185. jlpm run get:dependency @jupyterlab/buildutils
  186. jlpm run get:dependency typescript
  187. jlpm run get:dependency react-native
  188. # Use the extension upgrade script
  189. pip install cookiecutter
  190. python -m jupyterlab.upgrade_extension --no-input jupyterlab/tests/mock_packages/extension
  191. # Test theme creation - make sure we can add it as a package, build,
  192. # and run browser
  193. pip install -q pexpect
  194. python scripts/create_theme.py
  195. mv foo packages
  196. jlpm run integrity
  197. jlpm run build:packages
  198. jlpm run build:dev
  199. python -m jupyterlab.browser_check --dev-mode
  200. jlpm run remove:package foo
  201. jlpm run integrity
  202. ## Test app directory support being a symlink
  203. mkdir tmp
  204. pushd tmp
  205. mkdir real_app_dir
  206. ln -s real_app_dir link_app_dir
  207. # verify that app directory is not resolved
  208. env JUPYTERLAB_DIR=./link_app_dir jupyter lab path | grep link_app_dir
  209. popd
  210. # Make sure we can successfully load the dev app.
  211. python -m jupyterlab.browser_check --dev-mode
  212. # Make sure core mode works
  213. jlpm run build:core
  214. # Make sure we have a final released version of JupyterLab server
  215. python -m jupyterlab.browser_check --core-mode
  216. # Make sure we can run the built app.
  217. jupyter labextension install ./jupyterlab/tests/mock_packages/extension --debug
  218. python -m jupyterlab.browser_check
  219. jupyter labextension list --debug
  220. # Make sure we can run watch mode with no built application
  221. jupyter lab clean
  222. python -m jupyterlab.browser_check --watch
  223. # Make sure we can non-dev install.
  224. virtualenv -p $(which python3) test_install
  225. ./test_install/bin/pip install -q ".[test]" # this populates <sys_prefix>/share/jupyter/lab
  226. ./test_install/bin/jupyter server extension list 1>serverextensions 2>&1
  227. cat serverextensions
  228. cat serverextensions | grep -i "jupyterlab.*enabled"
  229. cat serverextensions | grep -i "jupyterlab.*OK"
  230. # TODO: remove when we no longer support classic notebook
  231. ./test_install/bin/jupyter serverextension list 1>serverextensions 2>&1
  232. cat serverextensions
  233. cat serverextensions | grep -i "jupyterlab.*enabled"
  234. cat serverextensions | grep -i "jupyterlab.*OK"
  235. ./test_install/bin/python -m jupyterlab.browser_check
  236. # Make sure we can run the build
  237. ./test_install/bin/jupyter lab build
  238. # Make sure we can start and kill the lab server
  239. ./test_install/bin/jupyter lab --no-browser &
  240. TASK_PID=$!
  241. # Make sure the task is running
  242. ps -p $TASK_PID || exit 1
  243. sleep 5
  244. kill $TASK_PID
  245. wait $TASK_PID
  246. # Check the labhubapp
  247. ./test_install/bin/pip install jupyterhub
  248. ./test_install/bin/jupyter-labhub --no-browser &
  249. TASK_PID=$!
  250. # Make sure the task is running
  251. ps -p $TASK_PID || exit 1
  252. sleep 5
  253. kill $TASK_PID
  254. wait $TASK_PID
  255. # Make sure we can clean various bits of the app dir
  256. jupyter lab clean
  257. jupyter lab clean --extensions
  258. jupyter lab clean --settings
  259. jupyter lab clean --static
  260. jupyter lab clean --all
  261. fi
  262. if [[ $GROUP == nonode ]]; then
  263. # Make sure we can install the wheel
  264. virtualenv -p $(which python3) test_install
  265. ./test_install/bin/pip install -v --pre --no-cache-dir --no-deps jupyterlab --no-index --find-links=dist # Install latest jupyterlab
  266. ./test_install/bin/pip install jupyterlab # Install jupyterlab dependencies
  267. ./test_install/bin/python -m jupyterlab.browser_check --no-chrome-test
  268. # Make sure we can start and kill the lab server
  269. ./test_install/bin/jupyter lab --no-browser &
  270. TASK_PID=$!
  271. # Make sure the task is running
  272. ps -p $TASK_PID || exit 1
  273. sleep 5
  274. kill $TASK_PID
  275. wait $TASK_PID
  276. fi