From 4f2d38ff49644d79d05c3661256c68ad3bcc5e63 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sat, 18 Jan 2025 23:20:58 +0100 Subject: [PATCH 1/3] Build/Libraries - Pin `referencing` library which breaks due to out-dated flask_expects_json, remove pip upgrade in test(#2912) --- .github/workflows/pypi-release.yml | 1 - requirements.txt | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index b708c9a8b..3c27c2dab 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -45,7 +45,6 @@ jobs: - name: Test that the basic pip built package runs without error run: | set -ex - sudo pip3 install --upgrade pip pip3 install dist/changedetection.io*.whl changedetection.io -d /tmp -p 10000 & sleep 3 diff --git a/requirements.txt b/requirements.txt index 0bcb6552b..3355e770b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -95,5 +95,8 @@ babel # Needed for > 3.10, https://github.com/microsoft/playwright-python/issues/2096 greenlet >= 3.0.3 +# Pinned or it causes problems with flask_expects_json which seems unmaintained +referencing==0.35.1 + # Scheduler - Windows seemed to miss a lot of default timezone info (even "UTC" !) tzdata From 938065db6f8a735e562e2f62a7fb5300b734efd8 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 20 Jan 2025 16:10:54 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 12bcb507b..4492fcfd7 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ Easily add the current web page to your changedetection.io tool, simply install [Chrome Extension to easily add the current web-page to detect a change.](https://chromewebstore.google.com/detail/changedetectionio-website/kefcfmgmlhmankjmnbijimhofdjekbop) -[Goto the Chrome Webstore to download the extension.](https://chromewebstore.google.com/detail/changedetectionio-website/kefcfmgmlhmankjmnbijimhofdjekbop) +[Goto the Chrome Webstore to download the extension.](https://chromewebstore.google.com/detail/changedetectionio-website/kefcfmgmlhmankjmnbijimhofdjekbop) ( Or check out the [GitHub repo](https://github.com/dgtlmoon/changedetection.io-browser-extension) ) ## Installation From e799a1cdcbf1cb1feaa12838b7a8a3a85fee4f62 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 21 Jan 2025 13:40:01 +0100 Subject: [PATCH 3/3] 0.49.00 --- .../test-stack-reusable-workflow.yml | 8 ++- changedetectionio/__init__.py | 5 +- changedetectionio/tests/unit/test_semver.py | 64 +++++++++++++++++++ 3 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 changedetectionio/tests/unit/test_semver.py diff --git a/.github/workflows/test-stack-reusable-workflow.yml b/.github/workflows/test-stack-reusable-workflow.yml index f2864680c..29903c171 100644 --- a/.github/workflows/test-stack-reusable-workflow.yml +++ b/.github/workflows/test-stack-reusable-workflow.yml @@ -64,14 +64,16 @@ jobs: echo "Running processes in docker..." docker ps - - name: Test built container with Pytest (generally as requests/plaintext fetching) + - name: Run Unit Tests run: | # Unit tests - echo "run test with unittest" docker run test-changedetectionio bash -c 'python3 -m unittest changedetectionio.tests.unit.test_notification_diff' docker run test-changedetectionio bash -c 'python3 -m unittest changedetectionio.tests.unit.test_watch_model' docker run test-changedetectionio bash -c 'python3 -m unittest changedetectionio.tests.unit.test_jinja2_security' - + docker run test-changedetectionio bash -c 'python3 -m unittest changedetectionio.tests.unit.test_semver' + + - name: Test built container with Pytest (generally as requests/plaintext fetching) + run: | # All tests echo "run test with pytest" # The default pytest logger_level is TRACE diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index f30d95e4a..6f386b7e2 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -2,7 +2,7 @@ # Read more https://github.com/dgtlmoon/changedetection.io/wiki -__version__ = '0.48.06' +__version__ = '0.49.0' from changedetectionio.strtobool import strtobool from json.decoder import JSONDecodeError @@ -24,6 +24,9 @@ from loguru import logger app = None datastore = None +def get_version(): + return __version__ + # Parent wrapper or OS sends us a SIGTERM/SIGINT, do everything required for a clean shutdown def sigshutdown_handler(_signo, _stack_frame): global app diff --git a/changedetectionio/tests/unit/test_semver.py b/changedetectionio/tests/unit/test_semver.py new file mode 100644 index 000000000..5ebfc95e7 --- /dev/null +++ b/changedetectionio/tests/unit/test_semver.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 + +# run from dir above changedetectionio/ dir +# python3 -m unittest changedetectionio.tests.unit.test_semver + +import re +import unittest + + +# The SEMVER regex +SEMVER_REGEX = r"^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$" + +# Compile the regex +semver_pattern = re.compile(SEMVER_REGEX) + +class TestSemver(unittest.TestCase): + def test_valid_versions(self): + """Test valid semantic version strings""" + valid_versions = [ + "1.0.0", + "0.1.0", + "0.0.1", + "1.0.0-alpha", + "1.0.0-alpha.1", + "1.0.0-0.3.7", + "1.0.0-x.7.z.92", + "1.0.0-alpha+001", + "1.0.0+20130313144700", + "1.0.0-beta+exp.sha.5114f85" + ] + for version in valid_versions: + with self.subTest(version=version): + self.assertIsNotNone(semver_pattern.match(version), f"Version {version} should be valid") + + def test_invalid_versions(self): + """Test invalid semantic version strings""" + invalid_versions = [ + "0.48.06", + "1.0", + "1.0.0-", +# Seems to pass the semver.org regex? +# "1.0.0-alpha-", + "1.0.0+", + "1.0.0-alpha+", + "1.0.0-", + "01.0.0", + "1.01.0", + "1.0.01", + ".1.0.0", + "1..0.0" + ] + for version in invalid_versions: + with self.subTest(version=version): + res = semver_pattern.match(version) + self.assertIsNone(res, f"Version '{version}' should be invalid") + + def test_our_version(self): + from changedetectionio import get_version + our_version = get_version() + self.assertIsNotNone(semver_pattern.match(our_version), f"Our version '{our_version}' should be a valid SEMVER string") + + +if __name__ == '__main__': + unittest.main()