ci_script.sh 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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 bumpversion patch --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. pip install -e test-hyphens
  170. jupyter labextension develop test-hyphens --overwrite --debug
  171. pip install -e test_no_hyphens
  172. jupyter labextension develop test_no_hyphens --overwrite --debug
  173. pip install -e test-hyphens-underscore
  174. jupyter labextension develop test-hyphens-underscore --overwrite --debug
  175. python -m jupyterlab.browser_check
  176. jupyter labextension list 1>labextensions 2>&1
  177. cat labextensions | grep "@jupyterlab/mock-extension.*enabled.*OK"
  178. jupyter labextension build extension --static-url /foo/
  179. jupyter labextension build extension --core-path ../../../examples/federated/core_package
  180. jupyter labextension disable @jupyterlab/mock-extension --debug
  181. jupyter labextension enable @jupyterlab/mock-extension --debug
  182. jupyter labextension uninstall @jupyterlab/mock-extension --debug
  183. jupyter labextension list 1>labextensions 2>&1
  184. # check the federated extension is still listed after jupyter labextension uninstall
  185. cat labextensions | grep -q "mock-extension"
  186. # build it again without a static-url to avoid causing errors
  187. jupyter labextension build extension
  188. popd
  189. jupyter lab workspaces export > workspace.json --debug
  190. jupyter lab workspaces import --name newspace workspace.json --debug
  191. jupyter lab workspaces export newspace > newspace.json --debug
  192. rm workspace.json newspace.json
  193. # Make sure we can call help on all the cli apps.
  194. jupyter lab -h
  195. jupyter lab build -h
  196. jupyter lab clean -h
  197. jupyter lab path -h
  198. jupyter labextension link -h
  199. jupyter labextension unlink -h
  200. jupyter labextension install -h
  201. jupyter labextension uninstall -h
  202. jupyter labextension list -h
  203. jupyter labextension enable -h
  204. jupyter labextension disable -h
  205. # Make sure we can run JupyterLab under classic notebook
  206. python -m jupyterlab.browser_check --notebook
  207. # Make sure we can add and remove a sibling package.
  208. # jlpm run add:sibling jupyterlab/tests/mock_packages/extension
  209. # jlpm run build
  210. # jlpm run remove:package extension
  211. # jlpm run build
  212. # jlpm run integrity --force # Should have a clean tree now
  213. # Test cli tools
  214. jlpm run get:dependency mocha
  215. jlpm run update:dependency mocha
  216. jlpm run remove:dependency mocha
  217. jlpm run get:dependency @jupyterlab/buildutils
  218. jlpm run get:dependency typescript
  219. jlpm run get:dependency react-native
  220. # Use the extension upgrade script
  221. pip install cookiecutter
  222. python -m jupyterlab.upgrade_extension --no-input jupyterlab/tests/mock_packages/extension
  223. # Test theme creation - make sure we can add it as a package, build,
  224. # and run browser
  225. pip install -q pexpect
  226. python scripts/create_theme.py
  227. mv foo packages
  228. jlpm run integrity
  229. jlpm run build:packages
  230. jlpm run build:dev
  231. python -m jupyterlab.browser_check --dev-mode
  232. jlpm run remove:package foo
  233. jlpm run integrity
  234. fi
  235. if [[ $GROUP == usage2 ]]; then
  236. ## Test app directory support being a symlink
  237. mkdir tmp
  238. pushd tmp
  239. mkdir real_app_dir
  240. ln -s real_app_dir link_app_dir
  241. # verify that app directory is resolved
  242. env JUPYTERLAB_DIR=./link_app_dir jupyter lab path | grep real_app_dir
  243. popd
  244. # Make sure we can successfully load the dev app.
  245. python -m jupyterlab.browser_check --dev-mode
  246. # Make sure core mode works
  247. jlpm run build:core
  248. # Make sure we have a final released version of JupyterLab server
  249. python -m jupyterlab.browser_check --core-mode
  250. # Make sure we can run the built app.
  251. jupyter labextension install ./jupyterlab/tests/mock_packages/extension --debug
  252. python -m jupyterlab.browser_check
  253. jupyter labextension list --debug
  254. # Make sure we can run watch mode with no built application
  255. jupyter lab clean
  256. python -m jupyterlab.browser_check --watch
  257. # Make sure we can non-dev install.
  258. virtualenv -p $(which python3) test_install
  259. ./test_install/bin/pip install -q ".[test]" # this populates <sys_prefix>/share/jupyter/lab
  260. ./test_install/bin/jupyter server extension list 1>serverextensions 2>&1
  261. cat serverextensions
  262. cat serverextensions | grep -i "jupyterlab.*enabled"
  263. cat serverextensions | grep -i "jupyterlab.*OK"
  264. # TODO: remove when we no longer support classic notebook
  265. ./test_install/bin/jupyter serverextension list 1>serverextensions 2>&1
  266. cat serverextensions
  267. cat serverextensions | grep -i "jupyterlab.*enabled"
  268. cat serverextensions | grep -i "jupyterlab.*OK"
  269. ./test_install/bin/python -m jupyterlab.browser_check
  270. # Make sure we can run the build
  271. ./test_install/bin/jupyter lab build
  272. # Make sure we can start and kill the lab server
  273. ./test_install/bin/jupyter lab --no-browser &
  274. TASK_PID=$!
  275. # Make sure the task is running
  276. ps -p $TASK_PID || exit 1
  277. sleep 5
  278. kill $TASK_PID
  279. wait $TASK_PID
  280. # Check the labhubapp
  281. ./test_install/bin/pip install jupyterhub
  282. export JUPYTERHUB_API_TOKEN="mock_token"
  283. ./test_install/bin/jupyter-labhub --HubOAuth.oauth_client_id="mock_id" &
  284. TASK_PID=$!
  285. unset JUPYTERHUB_API_TOKEN
  286. # Make sure the task is running
  287. ps -p $TASK_PID || exit 1
  288. sleep 5
  289. kill $TASK_PID
  290. # Make sure we can clean various bits of the app dir
  291. jupyter lab clean
  292. jupyter lab clean --extensions
  293. jupyter lab clean --settings
  294. jupyter lab clean --static
  295. jupyter lab clean --all
  296. fi
  297. if [[ $GROUP == splice_source ]]; then
  298. # Run the integrity script to link binary files
  299. jlpm integrity
  300. jupyter lab build --minimize=False --debug --dev-build=True --splice-source
  301. jupyter lab --version > version.txt
  302. cat version.txt
  303. cat version.txt | grep -q "spliced"
  304. python -m jupyterlab.browser_check
  305. cd jupyterlab/tests/mock_packages/mimeextension
  306. jupyter labextension install .
  307. python -m jupyterlab.browser_check
  308. jupyter lab --version > version.txt
  309. cat version.txt
  310. cat version.txt | grep -q "spliced"
  311. jupyter lab clean --all
  312. jupyter lab --version > version.txt
  313. cat version.txt
  314. cat version.txt | grep -q "spliced" && exit 1
  315. jupyter labextension install --splice-source .
  316. jupyter lab --version > version.txt
  317. cat version.txt | grep -q "spliced"
  318. python -m jupyterlab.browser_check
  319. fi
  320. if [[ $GROUP == interop ]]; then
  321. cd jupyterlab/tests/mock_packages/interop
  322. # Install a source extension that depends on a prebuilt extension
  323. pushd token
  324. jupyter labextension link . --no-build
  325. popd
  326. pushd provider
  327. jupyter labextension build .
  328. pip install .
  329. popd
  330. pushd consumer
  331. jupyter labextension install .
  332. popd
  333. jupyter labextension list 1>labextensions 2>&1
  334. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  335. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  336. python -m jupyterlab.browser_check
  337. # Clear install
  338. pip uninstall -y jlab_mock_provider
  339. jupyter lab clean --all
  340. # Install a prebuilt extension that depends on a source extension
  341. pushd token
  342. jupyter labextension link . --no-build
  343. popd
  344. pushd provider
  345. jupyter labextension install .
  346. popd
  347. pushd consumer
  348. jupyter labextension build .
  349. pip install .
  350. popd
  351. jupyter labextension list 1>labextensions 2>&1
  352. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  353. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  354. python -m jupyterlab.browser_check
  355. # Clear install
  356. pip uninstall -y jlab_mock_consumer
  357. jupyter lab clean --all
  358. # Install the mock consumer as a source extension and as a
  359. # prebuilt extension to test shadowing
  360. pushd token
  361. jupyter labextension link . --no-build
  362. popd
  363. pushd provider
  364. jupyter labextension install . --no-build
  365. popd
  366. pushd consumer
  367. # Need to install source first because it would get ignored
  368. # if installed after
  369. jupyter labextension install .
  370. jupyter labextension build .
  371. pip install .
  372. popd
  373. jupyter labextension list 1>labextensions 2>&1
  374. cat labextensions | grep -q "@jupyterlab/mock-consumer.*OK"
  375. cat labextensions | grep -q "@jupyterlab/mock-provider.*OK"
  376. python -m jupyterlab.browser_check
  377. fi
  378. if [[ $GROUP == nonode ]]; then
  379. # Make sure we can install the wheel
  380. virtualenv -p $(which python3) test_install
  381. ./test_install/bin/pip install -v --pre --no-cache-dir --no-deps jupyterlab --no-index --find-links=dist # Install latest jupyterlab
  382. ./test_install/bin/pip install jupyterlab # Install jupyterlab dependencies
  383. ./test_install/bin/python -m jupyterlab.browser_check --no-browser-test
  384. # Make sure we can start and kill the lab server
  385. ./test_install/bin/jupyter lab --no-browser &
  386. TASK_PID=$!
  387. # Make sure the task is running
  388. ps -p $TASK_PID || exit 1
  389. sleep 5
  390. kill $TASK_PID
  391. wait $TASK_PID
  392. # Make sure we can install the tarball
  393. virtualenv -p $(which python3) test_sdist
  394. ./test_sdist/bin/pip install dist/*.tar.gz
  395. ./test_sdist/bin/python -m jupyterlab.browser_check --no-browser-test
  396. fi