From f04e88f5746e240826772075bb2732c145ad8504 Mon Sep 17 00:00:00 2001 From: "Christopher K. Long" Date: Mon, 14 Apr 2025 12:56:43 +0100 Subject: [PATCH 1/7] Added license and github link to documentation navigation pane --- docs/License.rst | 4 ++++ docs/index.rst | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 docs/License.rst diff --git a/docs/License.rst b/docs/License.rst new file mode 100644 index 0000000..c12accf --- /dev/null +++ b/docs/License.rst @@ -0,0 +1,4 @@ +License +======= +.. include:: ../LICENSE + :parser: myst_parser.sphinx_ \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 6c56f32..bcdaecc 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -16,4 +16,7 @@ saveable-objects user_guide/index reference/index - ChangeLog.md.rst \ No newline at end of file + ChangeLog.md.rst + License + GitHub + PyPI \ No newline at end of file From cbce73257b2453d33f1d9b3c6cbcebd9ecbf9614 Mon Sep 17 00:00:00 2001 From: "Christopher K. Long" Date: Mon, 14 Apr 2025 13:19:25 +0100 Subject: [PATCH 2/7] Added test requirements --- tests/requirements.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/requirements.txt diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..314d711 --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,4 @@ +toml +pyyaml +numpy +cloudpickle \ No newline at end of file From 991e66262688fef08c8457aaf5f0226fef9fc1cb Mon Sep 17 00:00:00 2001 From: "Christopher K. Long" Date: Mon, 14 Apr 2025 13:19:41 +0100 Subject: [PATCH 3/7] Updated github workflows to use test requirements --- .github/workflows/test-python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 4d1b526..7378697 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -69,7 +69,7 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi for w in ./dist/*.whl; do python -m pip install $w; done - name: Lint with flake8 run: | From 5181f1ee57e217cddc0ba40ba8829ee3dbd49fcb Mon Sep 17 00:00:00 2001 From: "Christopher K. Long" Date: Mon, 14 Apr 2025 13:19:59 +0100 Subject: [PATCH 4/7] Added version consistency check --- tests/test_version_consistency.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/test_version_consistency.py diff --git a/tests/test_version_consistency.py b/tests/test_version_consistency.py new file mode 100644 index 0000000..b73f97b --- /dev/null +++ b/tests/test_version_consistency.py @@ -0,0 +1,26 @@ +import os +import toml +import yaml + +PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) +README_FILE = os.path.join(PROJECT_DIR, "README.md") +TOML_FILE = os.path.join(PROJECT_DIR, "pyproject.toml") +CITATION_FILE = os.path.join(PROJECT_DIR, "CITATION.cff") +CHANGELOG_FILE = os.path.join(PROJECT_DIR, "ChangeLog.md") + +def test_version_consistency(): + toml_version = toml.load(TOML_FILE)["project"]["version"] + with open(CITATION_FILE, "r") as f: + citation_content = yaml.safe_load(f) + citation_version = citation_content["version"] + assert citation_version == toml_version + with open(README_FILE, "r") as f: + for line in f.readline(): + if "`](ChangeLog.md#release-" in line: + assert f"[`{toml_version}`](ChangeLog.md#release-{toml_version.replace('.', '')})" in line + with open(CHANGELOG_FILE, "r") as f: + for line in f.readlines(): + if line.startswith("## "): + assert toml_version in line + break + else: assert False, "Version not found in CHANGELOG.md" \ No newline at end of file From 9a6364236da7fad0c18966853003518020e18f00 Mon Sep 17 00:00:00 2001 From: "Christopher K. Long" Date: Mon, 14 Apr 2025 13:20:49 +0100 Subject: [PATCH 5/7] Added tox support --- .gitignore | 1 + tox.ini | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index f6e48a2..99add88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc .vscode +.tox dist !.github \ No newline at end of file diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..d6e2726 --- /dev/null +++ b/tox.ini @@ -0,0 +1,9 @@ +[tox] +requires = + tox>=4 +envlist = 3X + +[testenv] +description = run unit tests +deps = -rtests/requirements.txt +commands = pytest tests \ No newline at end of file From a9f9a40b9ebcdda0e647247803762cbd9a820890 Mon Sep 17 00:00:00 2001 From: "Christopher K. Long" Date: Mon, 14 Apr 2025 13:20:58 +0100 Subject: [PATCH 6/7] Documented unit tests --- docs/user_guide/index.rst | 1 + docs/user_guide/overview.md | 5 +++++ docs/user_guide/running_tests.md | 32 +++++++++++++++++++++++++++ docs/user_guide/saving_and_loading.md | 2 +- 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 docs/user_guide/running_tests.md diff --git a/docs/user_guide/index.rst b/docs/user_guide/index.rst index 1eb15af..2ee8eab 100644 --- a/docs/user_guide/index.rst +++ b/docs/user_guide/index.rst @@ -8,6 +8,7 @@ User Guide getting_started creating_a_saveableobject saving_and_loading + running_tests .. include:: overview.md :parser: myst_parser.sphinx_ diff --git a/docs/user_guide/overview.md b/docs/user_guide/overview.md index 2513263..855c92d 100644 --- a/docs/user_guide/overview.md +++ b/docs/user_guide/overview.md @@ -9,6 +9,11 @@ - [Creating a SaveableObject](creating_a_saveableobject.md) - [Saving and loading](saving_and_loading.md) +## Running Tests + + - [Running Tests](running_tests.md) + + --- [Next](getting_started.md) \ No newline at end of file diff --git a/docs/user_guide/running_tests.md b/docs/user_guide/running_tests.md new file mode 100644 index 0000000..ccf56d2 --- /dev/null +++ b/docs/user_guide/running_tests.md @@ -0,0 +1,32 @@ +# Running Tests + +Current status of units tests: + +[![Unit Tests](https://github.com/Christopher-K-Long/saveable-objects/actions/workflows/test-python-package.yml/badge.svg)](https://github.com/Christopher-K-Long/saveable-objects/actions/workflows/test-python-package.yml) + +You can run the unit tests yourself using [pytest](https://docs.pytest.org) or [tox](https://tox.wiki/). + +## Using [tox](https://tox.wiki/) + +Once [tox](https://tox.wiki/) is installed you can execute the command +```bash +tox +``` +in from a terminal in the root directory of saveable-objects to execute the tests for your installed python interpreter. + +## Using [pytest](https://docs.pytest.org) + +To execute the tests with [pytest](https://docs.pytest.org) you will need to set up a python environment with saveable-objects and the packages in `texts/requirements.txt`. For example, you can run +```bash +pip install ./ +pip install tests/requirements.txt +``` +from the root directory of saveable-objects to install all the requirements. Next the tests can be executed with the command +```bash +pytest +``` +from the root directory of saveable-objects. + +--- + +[Previous](saving_and_loading.md) \ No newline at end of file diff --git a/docs/user_guide/saving_and_loading.md b/docs/user_guide/saving_and_loading.md index 4ce8710..2a91862 100644 --- a/docs/user_guide/saving_and_loading.md +++ b/docs/user_guide/saving_and_loading.md @@ -221,4 +221,4 @@ we will this time load the state and find `b.z=10`. This is the end of the tutorial. Now you know everything to use saveable-objects! -[Previous](creating_a_saveableobject.md) \ No newline at end of file +[Previous](creating_a_saveableobject.md) | [Next](running_tests.md) \ No newline at end of file From d18d6f588406e922567ec48f2449fa2c14d6c678 Mon Sep 17 00:00:00 2001 From: "Christopher K. Long" Date: Mon, 14 Apr 2025 13:23:33 +0100 Subject: [PATCH 7/7] v1.1.5 --- CITATION.cff | 2 +- ChangeLog.md | 7 +++++++ README.md | 2 +- pyproject.toml | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 0f89bbd..2bcbc8c 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -29,5 +29,5 @@ keywords: - load - loading license: Apache-2.0 -version: v1.1.4 +version: 1.1.5 date-released: '2025-04-01' \ No newline at end of file diff --git a/ChangeLog.md b/ChangeLog.md index 7660cdf..29e67fe 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,12 @@ # [saveable-objects](README.md) Change Log +## Release v1.1.5 + +- Added the license to the documentation +- Added link to the GitHub repository to the navigation pane in the documentation +- Added a version consistency test +- Added [tox](https://tox.wiki/) support for user testing. + ## Release v1.1.4 - Hid superfluous table of contents in the index page of the User Guide in the documentation; diff --git a/README.md b/README.md index faa7ce4..844557b 100644 --- a/README.md +++ b/README.md @@ -32,5 +32,5 @@ Source code can be found at: [https://github.com/Christopher-K-Long/saveable-obj ## Version and Changes -The current version is [`1.1.4`](ChangeLog.md#release-114). Please see the [Change Log](ChangeLog.md) for more +The current version is [`1.1.5`](ChangeLog.md#release-115). Please see the [Change Log](ChangeLog.md) for more details. diff --git a/pyproject.toml b/pyproject.toml index f53df2d..1421be7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "saveable-objects" -version = "1.1.4" +version = "1.1.5" authors = [ { name="Christopher_K._Long", email="ckl45@cam.ac.uk" }, ]