From 1ac9c443b56465fe1ee83139a059bcd337a763ec Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Fri, 18 Nov 2022 15:11:44 +0100 Subject: [PATCH] maint: add test to extras_require, remove dev-requirements.txt --- .github/workflows/test.yml | 2 +- RELEASE.md | 49 ++++++++++++++++-------------- dev-requirements.txt | 18 ----------- docs/source/contributing/setup.rst | 19 ++++-------- docs/source/contributing/tests.rst | 30 ++++++++++-------- setup.py | 21 +++++++++++++ 6 files changed, 73 insertions(+), 66 deletions(-) delete mode 100644 dev-requirements.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 94847e23..78bb9b8f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -140,7 +140,7 @@ jobs: - name: Install Python dependencies run: | pip install --upgrade pip - pip install --upgrade . -r dev-requirements.txt + pip install ".[test]" if [ "${{ matrix.oldest_dependencies }}" != "" ]; then # take any dependencies in requirements.txt such as tornado>=5.0 diff --git a/RELEASE.md b/RELEASE.md index 1bdbb3d4..b00a089e 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,39 +1,42 @@ # How to make a release -`jupyterhub` is a package [available on -PyPI](https://pypi.org/project/jupyterhub/) and -[conda-forge](https://conda-forge.org/). -These are instructions on how to make a release on PyPI. -The PyPI release is done automatically by CI when a tag is pushed. +`jupyterhub` is a package available on [PyPI][] and [conda-forge][]. +These are instructions on how to make a release. -For you to follow along according to these instructions, you need: +## Pre-requisites -- To have push rights to the [jupyterhub GitHub - repository](https://github.com/jupyterhub/jupyterhub). +- Push rights to [jupyterhub/jupyterhub][] +- Push rights to [conda-forge/jupyterhub-feedstock][] ## Steps to make a release +1. Create a PR updating `docs/source/changelog.md` with [github-activity][] and + continue only when its merged. + + ```shell + pip install github-activity + + github-activity --heading-level=3 jupyterhub/jupyterhub + ``` + 1. Checkout main and make sure it is up to date. ```shell - ORIGIN=${ORIGIN:-origin} # set to the canonical remote, e.g. 'upstream' if 'origin' is not the official repo git checkout main - git fetch $ORIGIN main - git reset --hard $ORIGIN/main + git fetch origin main + git reset --hard origin/main ``` -1. Make sure `docs/source/changelog.md` is up-to-date. - [github-activity][] can help with this. - -1. Update the version with `tbump`. - You can see what will happen without making any changes with `tbump --dry-run ${VERSION}` +1. Update the version, make commits, and push a git tag with `tbump`. ```shell + pip install tbump + tbump --dry-run ${VERSION} + tbump ${VERSION} ``` - This will tag and publish a release, - which will be finished on CI. + Following this, the [CI system][] will build and publish a release. 1. Reset the version back to dev, e.g. `2.1.0.dev` after releasing `2.0.0` @@ -42,9 +45,11 @@ For you to follow along according to these instructions, you need: ``` 1. Following the release to PyPI, an automated PR should arrive to - [conda-forge/jupyterhub-feedstock][], - check for the tests to succeed on this PR and then merge it to successfully - update the package for `conda` on the conda-forge channel. + [conda-forge/jupyterhub-feedstock][] with instructions. -[github-activity]: https://github.com/choldgraf/github-activity +[pypi]: https://pypi.org/project/jupyterhub/ +[conda-forge]: https://anaconda.org/conda-forge/jupyterhub +[jupyterhub/jupyterhub]: https://github.com/jupyterhub/jupyterhub [conda-forge/jupyterhub-feedstock]: https://github.com/conda-forge/jupyterhub-feedstock +[github-activity]: https://github.com/executablebooks/github-activity +[ci system]: https://github.com/jupyterhub/jupyterhub/actions/workflows/release.yml diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index 65747e80..00000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -beautifulsoup4[html5lib] -coverage -cryptography -jsonschema -jupyterlab>=3 -mock -# nbclassic provides the '/tree/' handler, which we use in tests -# it is a transitive dependency via jupyterlab, -# but depend on it directly -nbclassic -pre-commit -pytest>=3.3 -pytest-asyncio>=0.17 -pytest-cov -requests-mock -selenium -tbump -virtualenv diff --git a/docs/source/contributing/setup.rst b/docs/source/contributing/setup.rst index aa60f3b7..1fabe6f7 100644 --- a/docs/source/contributing/setup.rst +++ b/docs/source/contributing/setup.rst @@ -94,12 +94,13 @@ When developing JupyterHub, you would need to make changes and be able to instan conda install configurable-http-proxy yarn -4. Install the python packages required for JupyterHub development. +4. Install an editable version of JupyterHub and its requirements for + development and testing. This lets you edit JupyterHub code in a text editor + & restart the JupyterHub process to see your code changes immediately. .. code:: bash - python3 -m pip install -r dev-requirements.txt - python3 -m pip install -r requirements.txt + python3 -m pip install --editable ".[test]" 5. Set up a database. @@ -108,21 +109,13 @@ When developing JupyterHub, you would need to make changes and be able to instan available via `Python `__. See :doc:`/reference/database` for details on other supported databases. -6. Install the development version of JupyterHub. This lets you edit - JupyterHub code in a text editor & restart the JupyterHub process to - see your code changes immediately. - - .. code:: bash - - python3 -m pip install --editable . - -7. You are now ready to start JupyterHub! +6. You are now ready to start JupyterHub! .. code:: bash jupyterhub -8. You can access JupyterHub from your browser at +7. You can access JupyterHub from your browser at ``http://localhost:8000`` now. Happy developing! diff --git a/docs/source/contributing/tests.rst b/docs/source/contributing/tests.rst index 8904b8c1..55bded61 100644 --- a/docs/source/contributing/tests.rst +++ b/docs/source/contributing/tests.rst @@ -110,22 +110,28 @@ Make sure you have completed all the steps in :ref:`contributing/setup` successf Code formatting and linting =========================== -JupyterHub has adopted automatic code formatting and linting. -As long as your code is valid, the pre-commit hook should take care of how it should look. -You can invoke the pre-commit hook manually at any time with: +JupyterHub automatically enforces code formatting. This means that pull requests +with changes breaking this formatting will receive a commit from pre-commit.ci +automatically. + +To automatically format code locally, you can install pre-commit and register a +_git hook_ to automatically check with pre-commit before you make a commit if +the formatting is okay. .. code:: bash + pip install pre-commit + pre-commit install --install-hooks + +To run pre-commit manually you would do: + +.. code:: bash + + # check for changes to code not yet committed pre-commit run -This should run any auto formatting on your code and tell you about any errors it couldn't fix automatically. -You may also install `black integration `_ -into your text editor to format code automatically. - -If you have already committed files before running pre-commit you can fix everything using: - -.. code:: bash - + # check for changes also in already committed code pre-commit run --all-files -And committing the changes. +You may also install `black integration `_ +into your text editor to format code automatically. diff --git a/setup.py b/setup.py index eff3cbf3..9f06e496 100755 --- a/setup.py +++ b/setup.py @@ -121,6 +121,27 @@ setup_args = dict( 'Source': 'https://github.com/jupyterhub/jupyterhub/', 'Tracker': 'https://github.com/jupyterhub/jupyterhub/issues', }, + extras_require={ + "test": [ + "beautifulsoup4[html5lib]", + "coverage", + # cryptography is an optional dependency for jupyterhub that we test + # against by default + "cryptography", + "jsonschema", + "jupyterlab>=3", + "mock", + # nbclassic provides the '/tree/' handler that we tests against in + # the test test_nbclassic_control_panel. + "nbclassic", + "pytest>=3.3", + "pytest-asyncio>=0.17", + "pytest-cov", + "requests-mock", + "selenium", + "virtualenv", + ], + } )