ci_script.sh 16 KB

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