There are several test implementations in ``nucypher``, however, the vast majority
of test are written for execution with ``pytest``.
For more details see the `Pytest Documentation`_.
To run the tests, use the following commands:
..code:: bash
(nucypher)$ pytest -s tests/unit
(nucypher)$ pytest -s tests/integration
Optionally, to run the full, slow, verbose test suite run:
..code:: bash
(nucypher)$ pytest
Setup Commit & Push Hooks
--------------------------
`Pre-commit <https://pre-commit.com/>`_ and pre-push are used for quality control to identify and prevent the inclusion of problematic code changes. They may prevent a commit that will fail
if passed along to CI servers or make small formatting changes directly to source code files.
If it's not already installed in your virtual environment, install pre-commit:
..code:: bash
(nucypher)$ pip install pre-commit
To enable pre-commit checks:
..code:: bash
(nucypher)$ pre-commit install
To enable pre-push checks:
..code:: bash
(nucypher)$ pre-commit install -t pre-push
For convenience, here is a one-liner to enable both:
The versioning scheme used is inspired by `semantic versioning 2.0 <https://semver.org/>`_, but adds development stage and release candidate tags. The basic idea:
- MAJOR version when you make incompatible API changes
- MINOR version when you add functionality in a backwards compatible manner
- PATCH version when you make backwards compatible bug fixes
Two additional tags are used: ``-dev`` and ``-rc.x`` (i.e. ``v1.2.3-dev`` or ``v4.5.6-rc.0``)
Upstream Branches
^^^^^^^^^^^^^^^^^
-``main`` is the stable and released version published to PyPI and docker cloud (``v6.0.0``).
-``development`` is the default upstream base branch containing new changes ahead of ``main`` and tagged with ``-dev`` (``v6.1.0-dev``).
Major/Minor Release Cycle
^^^^^^^^^^^^^^^^^^^^^^^^^
- New pull requests are made into ``development``.
- When a commit from ``development`` is selected as a release candidate the version tag is changed from ``-dev`` to ``rc.0`` (``v6.1.0-rc.0``). Selecting a release candidate implies a feature freeze.
- The release candidate is deployed to beta testers, staging, and testnet environments for QA.
- If the candidate is suitable, it is tagged, merged into ``main``, and published:
- All version tags are removed (``v6.1.0-dev`` -> ``v6.1.0``)
- A new upstream git version tag is pushed (triggering publication on CI) (``v6.1.0``)
-``development`` is merged into ``main``
-`development` version is bumped and the `-dev` tag is appended (``v6.2.0-dev`` or ``v7.0.0-dev``)
Release Blockers
^^^^^^^^^^^^^^^^
Sometimes changes are needed to fix a release blocker after a release candidate has already been selected. Normally the best course of action is to open a pull request into ``development``.
- Merge the pull request into ``development``
- Bump the release candidate's development number (``v7.0.0-rc.0`` -> ``v7.0.0-rc.1``)
- Redeploy beta testing environments, experimental nodes, staging, testnets, etc.
- Rinse & repeat until a suitable release candidate is found.
In the event that a release blocker's fix introduces unexpected backwards incompatibility during a minor release, bump the major version instead skipping directly to ``-rc.0``.
Patches (bugfixes, security patches, "hotfixes")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sometimes urgent changes need to be made outside of a planned minor or major release. If the required changes are backwards compatible open a pull request into ``main``. Once the changes are reviewed and merged, ``development`` must be rebased over ``main``
- Pull request is merged into ``main``
- The version's patch number is bumped (``v6.1.0`` -> ``v6.1.1``)
- A new upstream tag is pushed, triggering the publication build on CI (``v6.1.1``)
-``development`` is rebased over ``main``, amending the existing bumpversion commit with the new patch (this will be a merge conflict).
- Rinse & repeat
Release Automation
--------------------
..note::
This process uses ``towncrier`` and ``bumpversion``, which can be installed by running ``pip install -e .[deploy]`` or ``pip install towncrier bumpversion``.
Also note that it requires you have git commit signing properly configured.
..important::
Ensure your local tree is based on ``main`` and has no uncommitted changes.
1. Decide what part of the version to bump.
The version string follows the format ``{major}.{minor}.{patch}-{stage}.{devnum}``,
so the options are ``major``, ``minor``, ``patch``, ``stage``, or ``devnum``.
We usually issue new releases increasing the ``patch`` version.
2. Use the ``make release`` script, specifying the version increment with the ``bump`` parameter.
For example, for a new ``patch`` release, we would do:
..code:: bash
(nucypher)$ make release bump=patch
3. The previous step triggers the publication webhooks.
Monitor the triggered deployment build for manual approval.