ci_script.sh 8.6 KB

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