ci_script.sh 9.5 KB

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