ci_script.sh 8.2 KB

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