ci_script.sh 10 KB

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