ci_script.sh 15 KB

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