Skip to content

Commit e799a1c

Browse files
authored
0.49.00
1 parent 938065d commit e799a1c

3 files changed

Lines changed: 73 additions & 4 deletions

File tree

.github/workflows/test-stack-reusable-workflow.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,16 @@ jobs:
6464
echo "Running processes in docker..."
6565
docker ps
6666
67-
- name: Test built container with Pytest (generally as requests/plaintext fetching)
67+
- name: Run Unit Tests
6868
run: |
6969
# Unit tests
70-
echo "run test with unittest"
7170
docker run test-changedetectionio bash -c 'python3 -m unittest changedetectionio.tests.unit.test_notification_diff'
7271
docker run test-changedetectionio bash -c 'python3 -m unittest changedetectionio.tests.unit.test_watch_model'
7372
docker run test-changedetectionio bash -c 'python3 -m unittest changedetectionio.tests.unit.test_jinja2_security'
74-
73+
docker run test-changedetectionio bash -c 'python3 -m unittest changedetectionio.tests.unit.test_semver'
74+
75+
- name: Test built container with Pytest (generally as requests/plaintext fetching)
76+
run: |
7577
# All tests
7678
echo "run test with pytest"
7779
# The default pytest logger_level is TRACE

changedetectionio/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Read more https://github.com/dgtlmoon/changedetection.io/wiki
44

5-
__version__ = '0.48.06'
5+
__version__ = '0.49.0'
66

77
from changedetectionio.strtobool import strtobool
88
from json.decoder import JSONDecodeError
@@ -24,6 +24,9 @@
2424
app = None
2525
datastore = None
2626

27+
def get_version():
28+
return __version__
29+
2730
# Parent wrapper or OS sends us a SIGTERM/SIGINT, do everything required for a clean shutdown
2831
def sigshutdown_handler(_signo, _stack_frame):
2932
global app
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env python3
2+
3+
# run from dir above changedetectionio/ dir
4+
# python3 -m unittest changedetectionio.tests.unit.test_semver
5+
6+
import re
7+
import unittest
8+
9+
10+
# The SEMVER regex
11+
SEMVER_REGEX = r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?: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<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
12+
13+
# Compile the regex
14+
semver_pattern = re.compile(SEMVER_REGEX)
15+
16+
class TestSemver(unittest.TestCase):
17+
def test_valid_versions(self):
18+
"""Test valid semantic version strings"""
19+
valid_versions = [
20+
"1.0.0",
21+
"0.1.0",
22+
"0.0.1",
23+
"1.0.0-alpha",
24+
"1.0.0-alpha.1",
25+
"1.0.0-0.3.7",
26+
"1.0.0-x.7.z.92",
27+
"1.0.0-alpha+001",
28+
"1.0.0+20130313144700",
29+
"1.0.0-beta+exp.sha.5114f85"
30+
]
31+
for version in valid_versions:
32+
with self.subTest(version=version):
33+
self.assertIsNotNone(semver_pattern.match(version), f"Version {version} should be valid")
34+
35+
def test_invalid_versions(self):
36+
"""Test invalid semantic version strings"""
37+
invalid_versions = [
38+
"0.48.06",
39+
"1.0",
40+
"1.0.0-",
41+
# Seems to pass the semver.org regex?
42+
# "1.0.0-alpha-",
43+
"1.0.0+",
44+
"1.0.0-alpha+",
45+
"1.0.0-",
46+
"01.0.0",
47+
"1.01.0",
48+
"1.0.01",
49+
".1.0.0",
50+
"1..0.0"
51+
]
52+
for version in invalid_versions:
53+
with self.subTest(version=version):
54+
res = semver_pattern.match(version)
55+
self.assertIsNone(res, f"Version '{version}' should be invalid")
56+
57+
def test_our_version(self):
58+
from changedetectionio import get_version
59+
our_version = get_version()
60+
self.assertIsNotNone(semver_pattern.match(our_version), f"Our version '{our_version}' should be a valid SEMVER string")
61+
62+
63+
if __name__ == '__main__':
64+
unittest.main()

0 commit comments

Comments
 (0)