ci_script.sh 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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 docs (includes API docs)
  30. pushd docs
  31. conda env create -f environment.yml
  32. conda init --all
  33. source $CONDA/bin/activate jupyterlab_documentation
  34. make html
  35. conda deactivate
  36. popd
  37. fi
  38. if [[ $GROUP == linkcheck ]]; then
  39. # Build the docs
  40. pushd docs
  41. conda env create -f environment.yml
  42. conda init --all
  43. source $CONDA/bin/activate jupyterlab_documentation
  44. make html
  45. conda deactivate
  46. popd
  47. # Run the link check on the built html files
  48. CACHE_DIR="${HOME}/.cache/pytest-link-check"
  49. mkdir -p ${CACHE_DIR}
  50. echo "Existing cache:"
  51. ls -ltr ${CACHE_DIR}
  52. # Expire links after a week
  53. LINKS_EXPIRE=604800
  54. base_args="--check-links --check-links-cache --check-links-cache-expire-after ${LINKS_EXPIRE} --check-links-cache-name ${CACHE_DIR}/cache"
  55. # Ignore pull requests and issues to the link check doesn't take all day
  56. base_args="--check-links-ignore https://github.com/.*/(pull|issues)/.* ${base_args}"
  57. # Check built html files
  58. args="--ignore docs/build/html/genindex.html --ignore docs/build/html/search.html --ignore docs/build/html/api ${base_args}"
  59. py.test $args --links-ext .html -k .html docs/build/html || py.test $args --links-ext .html -k .html --lf docs/build/html
  60. # Check markdown files
  61. py.test ${base_args} --links-ext .md -k .md . || py.test $args --links-ext .md -k .md --lf .
  62. fi
  63. if [[ $GROUP == integrity ]]; then
  64. # Run the integrity script first
  65. jlpm run integrity --force
  66. # Check yarn.lock file
  67. jlpm check --integrity
  68. # Run a browser check in dev mode
  69. jlpm run build
  70. python -m jupyterlab.browser_check --dev-mode
  71. fi
  72. if [[ $GROUP == lint ]]; then
  73. # Lint our files.
  74. jlpm run lint:check || (echo 'Please run `jlpm run lint` locally and push changes' && exit 1)
  75. fi
  76. if [[ $GROUP == integrity2 ]]; then
  77. # Run the integrity script to link binary files
  78. jlpm integrity
  79. # Build the packages individually.
  80. jlpm run build:src
  81. # Make sure we can build for release
  82. jlpm run build:dev:prod:release
  83. # Make sure the storybooks build.
  84. jlpm run build:storybook
  85. # Make sure we have CSS that can be converted with postcss
  86. jlpm global add postcss postcss-cli
  87. jlpm config set prefix ~/.yarn
  88. ~/.yarn/bin/postcss packages/**/style/*.css --dir /tmp
  89. # run twine check on the python build assets.
  90. # this must be done before altering any versions below.
  91. python -m pip install -U twine wheel build
  92. python -m build .
  93. twine check dist/*
  94. fi
  95. if [[ $GROUP == integrity3 ]]; then
  96. # Make sure we can bump the version
  97. # This must be done at the end so as not to interfere
  98. # with the other checks
  99. git config --global user.email "you@example.com"
  100. git config --global user.name "CI"
  101. git stash
  102. git checkout -b commit_${BUILD_SOURCEVERSION}
  103. git clean -df
  104. jlpm bumpversion minor --force
  105. jlpm bumpversion major --force
  106. jlpm bumpversion release --force # switch to beta
  107. jlpm bumpversion release --force # switch to rc
  108. jlpm bumpversion build --force
  109. VERSION=$(python setup.py --version)
  110. if [[ $VERSION != *rc1 ]]; then exit 1; fi
  111. # make sure we can patch release
  112. jlpm bumpversion release --force # switch to final
  113. jlpm patch:release --force
  114. # make sure we can bump major JS releases
  115. jlpm bumpversion minor --force
  116. jlpm bump:js:major console --force
  117. jlpm bump:js:major console notebook --force
  118. # Make sure that a prepublish would include the proper files.
  119. jlpm run prepublish:check
  120. fi
  121. if [[ $GROUP == release_check ]]; then
  122. jlpm run publish:js --dry-run
  123. jlpm run prepare:python-release
  124. ./scripts/release_test.sh
  125. fi
  126. if [[ $GROUP == examples ]]; then
  127. # Run the integrity script to link binary files
  128. jlpm integrity
  129. # Build the examples.
  130. jlpm run build:packages
  131. jlpm run build:examples
  132. # Test the examples
  133. jlpm run test:examples
  134. fi
  135. if [[ $GROUP == usage ]]; then
  136. # Run the integrity script to link binary files
  137. jlpm integrity
  138. # Test the cli apps.
  139. jupyter lab clean --debug
  140. jupyter lab build --debug
  141. jupyter lab path --debug
  142. pushd jupyterlab/tests/mock_packages
  143. jupyter labextension link mimeextension --no-build --debug
  144. jupyter labextension unlink mimeextension --no-build --debug
  145. jupyter labextension link mimeextension --no-build --debug
  146. jupyter labextension unlink @jupyterlab/mock-mime-extension --no-build --debug
  147. # Test with a source package install
  148. jupyter labextension install mimeextension --debug
  149. jupyter labextension list --debug
  150. jupyter labextension list 1>labextensions 2>&1
  151. cat labextensions | grep "@jupyterlab/mock-mime-extension.*enabled.*OK"
  152. python -m jupyterlab.browser_check
  153. jupyter labextension disable @jupyterlab/mock-mime-extension --debug
  154. jupyter labextension enable @jupyterlab/mock-mime-extension --debug
  155. jupyter labextension uninstall @jupyterlab/mock-mime-extension --no-build --debug
  156. # Test enable/disable and uninstall/install a core package
  157. jupyter labextension disable @jupyterlab/notebook-extension --debug
  158. jupyter labextension uninstall @jupyterlab/notebook-extension --no-build --debug
  159. jupyter labextension list 1>labextensions 2>&1
  160. cat labextensions | grep "Uninstalled core extensions:"
  161. jupyter labextension install @jupyterlab/notebook-extension --no-build --debug
  162. jupyter labextension enable @jupyterlab/notebook-extension --debug
  163. # Test with a prebuilt install
  164. jupyter labextension develop extension --debug
  165. jupyter labextension build extension
  166. # Test develop script with hyphens and underscores in the module name
  167. jupyter labextension develop test-hyphens --overwrite --debug
  168. jupyter labextension develop test_no_hyphens --overwrite --debug
  169. jupyter labextension develop test-hyphens-underscore --overwrite --debug
  170. python -m jupyterlab.browser_check
  171. jupyter labextension list 1>labextensions 2>&1
  172. cat labextensions | grep "@jupyterlab/mock-extension.*enabled.*OK"
  173. jupyter labextension build extension --static-url /foo/
  174. jupyter labextension build extension --core-path ../../../examples/federated/core_package
  175. jupyter labextension disable @jupyterlab/mock-extension --debug
  176. jupyter labextension enable @jupyterlab/mock-extension --debug
  177. jupyter labextension uninstall @jupyterlab/mock-extension --debug
  178. jupyter labextension list 1>labextensions 2>&1
  179. # check the federated extension is still listed after jupyter labextension uninstall
  180. cat labextensions | grep -q "mock-extension"
  181. # build it again without a static-url to avoid causing errors
  182. jupyter labextension build extension
  183. popd
  184. jupyter lab workspaces export > workspace.json --debug
  185. jupyter lab workspaces import --name newspace workspace.json --debug
  186. jupyter lab workspaces export newspace > newspace.json --debug
  187. rm workspace.json newspace.json
  188. # Make sure we can call help on all the cli apps.
  189. jupyter lab -h
  190. jupyter lab build -h
  191. jupyter lab clean -h
  192. jupyter lab path -h
  193. jupyter labextension link -h
  194. jupyter labextension unlink -h
  195. jupyter labextension install -h
  196. jupyter labextension uninstall -h
  197. jupyter labextension list -h
  198. jupyter labextension enable -h
  199. jupyter labextension disable -h
  200. # Make sure we can run JupyterLab under classic notebook
  201. python -m jupyterlab.browser_check --notebook
  202. # Make sure we can add and remove a sibling package.
  203. # jlpm run add:sibling jupyterlab/tests/mock_packages/extension
  204. # jlpm run build
  205. # jlpm run remove:package extension
  206. # jlpm run build
  207. # jlpm run integrity --force # Should have a clean tree now
  208. # Test cli tools
  209. jlpm run get:dependency mocha
  210. jlpm run update:dependency mocha
  211. jlpm run remove:dependency mocha
  212. jlpm run get:dependency @jupyterlab/buildutils
  213. jlpm run get:dependency typescript
  214. jlpm run get:dependency react-native
  215. # Use the extension upgrade script
  216. pip install cookiecutter
  217. python -m jupyterlab.upgrade_extension --no-input jupyterlab/tests/mock_packages/extension
  218. # Test theme creation - make sure we can add it as a package, build,
  219. # and run browser
  220. pip install -q pexpect
  221. python scripts/create_theme.py
  222. mv foo packages
  223. jlpm run integrity
  224. jlpm run build:packages
  225. jlpm run build:dev
  226. python -m jupyterlab.browser_check --dev-mode
  227. jlpm run remove:package foo
  228. jlpm run integrity
  229. fi
  230. if [[ $GROUP == usage2 ]]; then
  231. ## Test app directory support being a symlink
  232. mkdir tmp
  233. pushd tmp
  234. mkdir real_app_dir
  235. ln -s real_app_dir link_app_dir
  236. # verify that app directory is resolved
  237. env JUPYTERLAB_DIR=./link_app_dir jupyter lab path | grep real_app_dir
  238. popd
  239. # Make sure we can successfully load the dev app.
  240. python -m jupyterlab.browser_check --dev-mode
  241. # Make sure core mode works
  242. jlpm run build:core
  243. # Make sure we have a final released version of JupyterLab server
  244. python -m jupyterlab.browser_check --core-mode
  245. # Make sure we can run the built app.
  246. jupyter labextension install ./jupyterlab/tests/mock_packages/extension --debug
  247. python -m jupyterlab.browser_check
  248. jupyter labextension list --debug
  249. # Make sure we can run watch mode with no built application
  250. jupyter lab clean
  251. python -m jupyterlab.browser_check --watch
  252. # Make sure we can non-dev install.
  253. virtualenv -p $(which python3) test_install
  254. ./test_install/bin/pip install -q ".[test]" # this populates <sys_prefix>/share/jupyter/lab
  255. ./test_install/bin/jupyter server extension list 1>serverextensions 2>&1
  256. cat serverextensions
  257. cat serverextensions | grep -i "jupyterlab.*enabled"
  258. cat serverextensions | grep -i "jupyterlab.*OK"
  259. # TODO: remove when we no longer support classic notebook
  260. ./test_install/bin/jupyter serverextension list 1>serverextensions 2>&1
  261. cat serverextensions
  262. cat serverextensions | grep -i "jupyterlab.*enabled"
  263. cat serverextensions | grep -i "jupyterlab.*OK"
  264. ./test_install/bin/python -m jupyterlab.browser_check
  265. # Make sure we can run the build
  266. ./test_install/bin/jupyter lab build
  267. # Make sure we can start and kill the lab server
  268. ./test_install/bin/jupyter lab --no-browser &
  269. TASK_PID=$!
  270. # Make sure the task is running
  271. ps -p $TASK_PID || exit 1
  272. sleep 5
  273. kill $TASK_PID
  274. wait $TASK_PID
  275. # Check the labhubapp
  276. ./test_install/bin/pip install jupyterhub
  277. export JUPYTERHUB_API_TOKEN="mock_token"
  278. ./test_install/bin/jupyter-labhub --HubOAuth.oauth_client_id="mock_id" &
  279. TASK_PID=$!
  280. unset JUPYTERHUB_API_TOKEN
  281. # Make sure the task is running
  282. ps -p $TASK_PID || exit 1
  283. sleep 5
  284. kill $TASK_PID
  285. # Make sure we can clean various bits of the app dir
  286. jupyter lab clean
  287. jupyter lab clean --extensions
  288. jupyter lab clean --settings
  289. jupyter lab clean --static
  290. jupyter lab clean --all
  291. fi
  292. if [[ $GROUP == splice_source ]];then
  293. # Run the integrity script to link binary files
  294. jlpm integrity
  295. jupyter lab build --minimize=False --debug --dev-build=True --splice-source
  296. jupyter lab --version > version.txt
  297. cat version.txt
  298. cat version.txt | grep -q "spliced"
  299. python -m jupyterlab.browser_check
  300. cd jupyterlab/tests/mock_packages/mimeextension
  301. jupyter labextension install .
  302. python -m jupyterlab.browser_check
  303. jupyter lab --version > version.txt
  304. cat version.txt
  305. cat version.txt | grep -q "spliced"
  306. jupyter lab clean --all
  307. jupyter lab --version > version.txt
  308. cat version.txt
  309. cat version.txt | grep -q "spliced" && exit 1
  310. jupyter labextension install --splice-source .
  311. jupyter lab --version > version.txt
  312. cat version.txt | grep -q "spliced"
  313. python -m jupyterlab.browser_check
  314. fi
  315. if [[ $GROUP == interop ]]; then
  316. cd jupyterlab/tests/mock_packages/interop
  317. # Install a source extension that depends on a prebuilt extension
  318. pushd token
  319. jupyter labextension link . --no-build
  320. popd
  321. pushd provider
  322. jupyter labextension build .
  323. pip install .
  324. popd
  325. pushd consumer
  326. jupyter labextension install .
  327. popd
  328. jupyter labextension list 1>labextensions 2>&1
  329. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  330. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  331. python -m jupyterlab.browser_check
  332. # Clear install
  333. pip uninstall -y jlab_mock_provider
  334. jupyter lab clean --all
  335. # Install a prebuilt extension that depends on a source extension
  336. pushd token
  337. jupyter labextension link . --no-build
  338. popd
  339. pushd provider
  340. jupyter labextension install .
  341. popd
  342. pushd consumer
  343. jupyter labextension build .
  344. pip install .
  345. popd
  346. jupyter labextension list 1>labextensions 2>&1
  347. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  348. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  349. python -m jupyterlab.browser_check
  350. # Clear install
  351. pip uninstall -y jlab_mock_consumer
  352. jupyter lab clean --all
  353. # Install the mock consumer as a source extension and as a
  354. # prebuilt extension to test shadowing
  355. pushd token
  356. jupyter labextension link . --no-build
  357. popd
  358. pushd provider
  359. jupyter labextension install . --no-build
  360. popd
  361. pushd consumer
  362. # Need to install source first because it would get ignored
  363. # if installed after
  364. jupyter labextension install .
  365. jupyter labextension build .
  366. pip install .
  367. popd
  368. jupyter labextension list 1>labextensions 2>&1
  369. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  370. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  371. python -m jupyterlab.browser_check
  372. fi
  373. if [[ $GROUP == nonode ]]; then
  374. # Make sure we can install the wheel
  375. virtualenv -p $(which python3) test_install
  376. ./test_install/bin/pip install -v --pre --no-cache-dir --no-deps jupyterlab --no-index --find-links=dist # Install latest jupyterlab
  377. ./test_install/bin/pip install jupyterlab # Install jupyterlab dependencies
  378. ./test_install/bin/python -m jupyterlab.browser_check --no-browser-test
  379. # Make sure we can start and kill the lab server
  380. ./test_install/bin/jupyter lab --no-browser &
  381. TASK_PID=$!
  382. # Make sure the task is running
  383. ps -p $TASK_PID || exit 1
  384. sleep 5
  385. kill $TASK_PID
  386. wait $TASK_PID
  387. # Make sure we can install the tarball
  388. virtualenv -p $(which python3) test_sdist
  389. ./test_sdist/bin/pip install dist/*.tar.gz
  390. ./test_sdist/bin/python -m jupyterlab.browser_check --no-browser-test
  391. fi