From 521888359b72fca7860c47eae1057987860fa3cc Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 13 Dec 2023 15:22:35 +0100 Subject: [PATCH 1/3] fix(reader): correctly parse Python versions needed for pre-releases, for example 2.0.0b1 which is correct in Python-land, but not SemVer compatible --- pyproject.toml | 1 + wetest/testing/reader.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fafdf7d..9d0b3d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ pyepics = "^3.5.1" pykwalify = "^1.8.0" reportlab = "^3.6.8" semver = "^3.0.2" +packaging = "^23.2" [tool.poetry.group.dev.dependencies] pytest = "^7.4.3" diff --git a/wetest/testing/reader.py b/wetest/testing/reader.py index c7c0dd7..5c94e6a 100644 --- a/wetest/testing/reader.py +++ b/wetest/testing/reader.py @@ -23,6 +23,7 @@ import sys import yaml +from packaging.version import Version as PyPIVersion from pkg_resources import resource_filename from pykwalify import errors from pykwalify.core import Core @@ -57,8 +58,21 @@ WETEST_METADATA = importlib.metadata.metadata("WeTest") +def _convert2semver(ver: PyPIVersion) -> Version: + if ver.epoch != 0: + err = "Can't convert an epoch to semver" + raise ValueError(err) + if ver.post is not None: + err = "Can't convert a post part to semver" + raise ValueError(err) + + pre = None if not ver.pre else "".join([str(i) for i in ver.pre]) + return Version(*ver.release, prerelease=pre, build=ver.dev) + # Maximum file version supported -VERSION = Version.parse(importlib.metadata.version("WeTest")) +VERSION = _convert2semver(PyPIVersion(importlib.metadata.version("WeTest"))) +# ignore pre-releases when comparing versions +VERSION = VERSION.finalize_version() REPOSITORY = WETEST_METADATA["Home-page"] From c1ca497a60fde370537fc9eabc99e7c62ef8804d Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 13 Dec 2023 15:31:04 +0100 Subject: [PATCH 2/3] fix(ci): fix Ruff action ignoring changed files --- .github/workflows/ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index acbb72a..a860bc2 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -21,4 +21,4 @@ jobs: - uses: cachix/install-nix-action@v24 - name: "Check Ruff lints" if: steps.changed-files.outputs.any_changed == 'true' - run: nix run 'nixpkgs#ruff' -- check . --output-format=github ${{ steps.changed-files.outputs.all_changed_files }} + run: nix run 'nixpkgs#ruff' -- check --output-format=github ${{ steps.changed-files.outputs.all_changed_files }} From bf76e986bf0944477a32047f14cfb10a679b6768 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 13 Dec 2023 15:26:13 +0100 Subject: [PATCH 3/3] chore(release): prepare for 2.0.0rc1 --- CHANGELOG.md | 70 +++++++++++++++++++++++++++++++++++ nix/checks/simple.nix | 2 +- pyproject.toml | 4 +- tests/acceptance-demo.yaml | 6 +-- tests/bad.yml | 6 +-- tests/mks946-testing.yaml | 6 +-- tests/mks946.yaml | 6 +-- tests/scenario_example01.yaml | 6 +-- tests/scenario_example02.yaml | 6 +-- tests/scenario_example03.yaml | 6 +-- tests/scenario_example04.yaml | 6 +-- tests/scenario_example05.yaml | 6 +-- tests/suite_example01.yaml | 6 +-- tests/test_testing_reader.py | 5 +-- 14 files changed, 105 insertions(+), 36 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a61a63a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,70 @@ +# Changelog + +All notable changes to this project are documented in this file. + +## [2.0.0rc1] - 2023-12-13 + +### Highlights + +This release drops support for Python 2.7. +This version should be compatible with Python 3.7 and later. + +The build system was also switched to Poetry. + +Nix files were also added as a way to build and test the project. + +No changes were made to the scenario YAML format. +You can update the version in your YAML files to `2.0.0`. + +### Bug Fixes + +- Crash when creating PDF report +- Fix reader tests +- Don't run CI on every push +- Only run Ruff GitHub Action on changed Python files +- Correctly parse Python versions +- Fix Ruff action ignoring changed files + +### Features + +- Configure ruff in pyproject.toml +- Add ruff check as GitHub action +- Add editor config file +- Add editor config check as GitHub action +- Add support for Nix without flakes +- Add Nix build as GitHub action +- Generate Nix bundle archives on tagged releases +- Add CHANGELOG generation support with git-cliff + +### Miscellaneous Tasks + +- [**breaking**] convert codebase to Python 3 +- [**breaking**] switch build system to Poetry +- Add Nix build +- Support more architectures with Nix, add a simple test +- Ruff format everything +- Run ruff check --fix +- Run ruff check --fix --unsafe-fixes +- Other ruff lint manual fixes +- Correct spelling toogle -> toggle +- Remove trailing whitespace, ensure final newlines +- Update README installation instructions +- README formatting and wording +- Add metadata to the Nix WeTest package +- Improve project metadata +- [**breaking**] Add pytest, bump min Python version to 3.7 +- Move tests to own directory +- Don't ask compatibility question +- Link to repository instead of print changelog +- Remove non-working tests +- Rename Ruff lint action workflow, make it clearer +- Update install-nix-action in CI +- Run Nix checks instead of build on CI +- Use Python3.9 in the Nix build + +### Refactor + +- Make validate_file return boolean +- Rename _version_is_supported -> supports_version +- Better fetch of WeTest version +- Use semver for version comparison diff --git a/nix/checks/simple.nix b/nix/checks/simple.nix index f5556b3..f2b00c9 100644 --- a/nix/checks/simple.nix +++ b/nix/checks/simple.nix @@ -16,7 +16,7 @@ pkgs.nixosTest { testScript = let scenario = pkgs.writeText "simple.yml" '' - version: {major: 1, minor: 2, bugfix: 2} + version: {major: 2, minor: 0, bugfix: 0} config: type: unit diff --git a/pyproject.toml b/pyproject.toml index 9d0b3d0..cb56748 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "wetest" -version = "1.2.2" +version = "2.0.0rc1" description = "WeTest enables you to test EPICS modules" license = "EPICS" authors = [ @@ -68,6 +68,8 @@ ignore = [ ] # https://git-cliff.org/docs/configuration +# Run: +# git-cliff -c pyproject.toml --bump -u --prepend CHANGELOG.md [tool.git-cliff.changelog] header = """ # Changelog\n diff --git a/tests/acceptance-demo.yaml b/tests/acceptance-demo.yaml index 4bf58e0..f530bb4 100644 --- a/tests/acceptance-demo.yaml +++ b/tests/acceptance-demo.yaml @@ -1,7 +1,7 @@ version: - major: 1 - minor: 2 - bugfix: 2 + major: 2 + minor: 0 + bugfix: 0 config: type: functional diff --git a/tests/bad.yml b/tests/bad.yml index c211732..09d9934 100644 --- a/tests/bad.yml +++ b/tests/bad.yml @@ -1,7 +1,7 @@ version: - major: 1 - minor: 2 - bugfix: 2 + major: 2 + minor: 0 + bugfix: 0 config: type: unit diff --git a/tests/mks946-testing.yaml b/tests/mks946-testing.yaml index 8c721cb..43a95d7 100644 --- a/tests/mks946-testing.yaml +++ b/tests/mks946-testing.yaml @@ -1,7 +1,7 @@ version: - major: 1 - minor: 2 - bugfix: 2 + major: 2 + minor: 0 + bugfix: 0 config: type: unit diff --git a/tests/mks946.yaml b/tests/mks946.yaml index bbec254..3d7f117 100644 --- a/tests/mks946.yaml +++ b/tests/mks946.yaml @@ -1,7 +1,7 @@ version: - major: 1 - minor: 2 - bugfix: 2 + major: 2 + minor: 0 + bugfix: 0 config: type: unit diff --git a/tests/scenario_example01.yaml b/tests/scenario_example01.yaml index d8df0a3..89eb158 100644 --- a/tests/scenario_example01.yaml +++ b/tests/scenario_example01.yaml @@ -1,7 +1,7 @@ version: - major: 1 - minor: 2 - bugfix: 2 + major: 2 + minor: 0 + bugfix: 0 config: type: "unit" diff --git a/tests/scenario_example02.yaml b/tests/scenario_example02.yaml index 46b5159..c16e02a 100644 --- a/tests/scenario_example02.yaml +++ b/tests/scenario_example02.yaml @@ -1,7 +1,7 @@ version: - major: 1 - minor: 2 - bugfix: 2 + major: 2 + minor: 0 + bugfix: 0 config: {} diff --git a/tests/scenario_example03.yaml b/tests/scenario_example03.yaml index 96c1bf2..f1d307f 100644 --- a/tests/scenario_example03.yaml +++ b/tests/scenario_example03.yaml @@ -1,7 +1,7 @@ version: - major: 1 - minor: 2 - bugfix: 2 + major: 2 + minor: 0 + bugfix: 0 config: type: functional diff --git a/tests/scenario_example04.yaml b/tests/scenario_example04.yaml index ae9aef4..d5c8afb 100644 --- a/tests/scenario_example04.yaml +++ b/tests/scenario_example04.yaml @@ -1,7 +1,7 @@ version: - major: 1 - minor: 2 - bugfix: 2 + major: 2 + minor: 0 + bugfix: 0 config: type: functional diff --git a/tests/scenario_example05.yaml b/tests/scenario_example05.yaml index 83d16f7..8716408 100644 --- a/tests/scenario_example05.yaml +++ b/tests/scenario_example05.yaml @@ -1,7 +1,7 @@ version: - major: 1 - minor: 2 - bugfix: 2 + major: 2 + minor: 0 + bugfix: 0 config: type: functional diff --git a/tests/suite_example01.yaml b/tests/suite_example01.yaml index aed7fa2..07f7857 100644 --- a/tests/suite_example01.yaml +++ b/tests/suite_example01.yaml @@ -1,7 +1,7 @@ version: - major: 1 - minor: 2 - bugfix: 2 + major: 2 + minor: 0 + bugfix: 0 name: "ExampleSuite01" diff --git a/tests/test_testing_reader.py b/tests/test_testing_reader.py index b928a82..bcb0c01 100644 --- a/tests/test_testing_reader.py +++ b/tests/test_testing_reader.py @@ -10,10 +10,7 @@ def test_yaml_version_checker(): """Test supported versions are well identified.""" - assert ScenarioReader.supports_version(major=1, minor=0, bugfix=0) - assert ScenarioReader.supports_version(major=1, minor=1, bugfix=0) - assert ScenarioReader.supports_version(major=1, minor=2, bugfix=0) - assert ScenarioReader.supports_version(major=1, minor=2, bugfix=2) + assert ScenarioReader.supports_version(major=2, minor=0, bugfix=0) with pytest.raises(UnsupportedFileFormatError): ScenarioReader.supports_version(major=0, minor=0, bugfix=0) with pytest.raises(UnsupportedFileFormatError):