ci_script.sh 16 KB

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