From 262fed576c2435fb1546f6846f720724ac3a3bb0 Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Wed, 24 Apr 2024 16:22:50 +0200 Subject: [PATCH] Supporting OctoPrint 1.10 and Python 3.12 (#258) * Testing on 1.10.x * Using rc2. * Including full version to the matrix. * Adjusting exceptions. * Removing condition on Wheel installation. * Testing on Python 3.12. * Using mocked version 0.0.0 for testing instead of unknown. * Removing template test. * Removing snapshot updating action. * trying rc3 * Using rc4 * Using prod ready 1.10 in CI. * Updating integration test in Release workflow. * Removing snapshottest installation in CI. --- .github/workflows/CI.yaml | 19 +- .github/workflows/release.yaml | 15 +- .github/workflows/snapshot.yaml | 38 - octoprint_octorelay/_version.py | 9 +- tests/snapshots/__init__.py | 0 tests/snapshots/snap_test_templates.py | 4988 ------------------------ tests/test_templates.py | 36 - 7 files changed, 32 insertions(+), 5073 deletions(-) delete mode 100644 .github/workflows/snapshot.yaml delete mode 100644 tests/snapshots/__init__.py delete mode 100644 tests/snapshots/snap_test_templates.py delete mode 100644 tests/test_templates.py diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index f013fffc..85e5a024 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -51,26 +51,36 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] - octoprint: [ "1.5", "1.6", "1.7", "1.8", "1.9" ] + python: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ] + octoprint: [ "1.5", "1.6", "1.7", "1.8", "1.9", "1.10" ] exclude: # These versions are not compatible to each other: - octoprint: 1.5 python: 3.10 - octoprint: 1.5 python: 3.11 + - octoprint: 1.5 + python: 3.12 - octoprint: 1.6 python: 3.10 - octoprint: 1.6 python: 3.11 + - octoprint: 1.6 + python: 3.12 - octoprint: 1.7 python: 3.10 - octoprint: 1.7 python: 3.11 + - octoprint: 1.7 + python: 3.12 - octoprint: 1.8 python: 3.10 - octoprint: 1.8 python: 3.11 + - octoprint: 1.8 + python: 3.12 + - octoprint: 1.9 + python: 3.12 steps: - uses: actions/checkout@v4 - name: Install Python @@ -90,12 +100,11 @@ jobs: run: pip install octoprint~=${{ matrix.octoprint }}.0 - name: Install Wheel # see https://community.octoprint.org/t/setuptools-error-while-installing-plugin-octoklipper-on-manual-op-installation/51387 - if: matrix.octoprint != '1.9' run: pip install wheel - name: Install OctoRelay run: pip install -e . - name: Prepare testing environment - run: pip install coverage pylint snapshottest mypy + run: pip install coverage pylint mypy - name: Test working-directory: tests run: python -m coverage run -m unittest test*.py @@ -103,7 +112,7 @@ jobs: working-directory: tests run: | python -m coverage lcov --omit=test*,_version* - python -m coverage report --show-missing --omit=test*,_version*,snap_* + python -m coverage report --show-missing --omit=test*,_version* - name: Coveralls uses: coverallsapp/github-action@v2 continue-on-error: true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2210b8a5..c3b18480 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -68,26 +68,36 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] - octoprint: [ "1.5", "1.6", "1.7", "1.8", "1.9" ] + python: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ] + octoprint: [ "1.5", "1.6", "1.7", "1.8", "1.9", "1.10" ] exclude: # These versions are not compatible to each other: - octoprint: 1.5 python: 3.10 - octoprint: 1.5 python: 3.11 + - octoprint: 1.5 + python: 3.12 - octoprint: 1.6 python: 3.10 - octoprint: 1.6 python: 3.11 + - octoprint: 1.6 + python: 3.12 - octoprint: 1.7 python: 3.10 - octoprint: 1.7 python: 3.11 + - octoprint: 1.7 + python: 3.12 - octoprint: 1.8 python: 3.10 - octoprint: 1.8 python: 3.11 + - octoprint: 1.8 + python: 3.12 + - octoprint: 1.9 + python: 3.12 steps: - name: Install Python uses: actions/setup-python@v4 @@ -102,7 +112,6 @@ jobs: run: pip install octoprint~=${{ matrix.octoprint }}.0 - name: Install Wheel # see https://community.octoprint.org/t/setuptools-error-while-installing-plugin-octoklipper-on-manual-op-installation/51387 - if: matrix.octoprint != '1.9' run: pip install wheel - name: Install the distributed package run: pip install dist/OctoRelay-*.zip diff --git a/.github/workflows/snapshot.yaml b/.github/workflows/snapshot.yaml deleted file mode 100644 index 8a7aca8b..00000000 --- a/.github/workflows/snapshot.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: Snapshot Update -on: workflow_dispatch - -jobs: - snapshotUpdate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: fregante/setup-git-user@v2 - - name: Install Python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: Get pip cache dir - id: pipCache - run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - - name: Cache pip modules - uses: actions/cache@v3 - with: - path: ${{ steps.pipCache.outputs.dir }} - key: ${{ runner.os }}-build-cache-pip-python-3.10-octoprint-1.9 - - name: Install OctoPrint - run: pip install octoprint~=1.9.0 - - name: Install OctoRelay - run: pip install -e . - - name: Prepare testing environment - run: pip install coverage pylint snapshottest - - name: Remove snapshots - run: rm tests/snapshots/snap* - - name: Make new snapshots - working-directory: tests - run: python -m coverage run -m unittest test*.py - - name: Commit changes - run: | - git add tests/snapshots - git commit -m "Updating snapshots." - - name: Push changes - run: git push diff --git a/octoprint_octorelay/_version.py b/octoprint_octorelay/_version.py index f8898532..4d5c1c05 100644 --- a/octoprint_octorelay/_version.py +++ b/octoprint_octorelay/_version.py @@ -27,7 +27,8 @@ def get_version(version_file=STATIC_VERSION_FILE): if not version: version = get_version_from_git_archive(version_info) if not version: - version = Version("unknown", None, None) + # version = Version("unknown", None, None) + version = Version("0.0.0", None, None) return pep440_format(version) else: return version @@ -95,7 +96,8 @@ def get_version_from_git(): except ValueError: # No tags, only the git hash # prepend 'g' to match with format returned by 'git describe' git = "g{}".format(*description) - release = "unknown" + # release = "unknown" + release = "0.0.0" dev = None labels = [] @@ -141,7 +143,8 @@ def get_version_from_git_archive(version_info): release, *_ = sorted(version_tags) # prefer e.g. "2.0" over "2.0rc1" return Version(release, dev=None, labels=None) else: - return Version("unknown", dev=None, labels=["g{}".format(git_hash)]) + # return Version("unknown", dev=None, labels=["g{}".format(git_hash)]) + return Version("0.0.0", dev=None, labels=["g{}".format(git_hash)]) __version__ = get_version() diff --git a/tests/snapshots/__init__.py b/tests/snapshots/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/snapshots/snap_test_templates.py b/tests/snapshots/snap_test_templates.py deleted file mode 100644 index 4d96a0de..00000000 --- a/tests/snapshots/snap_test_templates.py +++ /dev/null @@ -1,4988 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import Snapshot - - -snapshots = Snapshot() - -snapshots['TestTemplates::test_templates octorelay_navbar.jinja2'] = ''' - - - - - - - - - - - - - - - - - -''' - -snapshots['TestTemplates::test_templates octorelay_settings.jinja2'] = '''
-

OctoRelay Settings

- - - -
- -
-
- -
-
- - - - - - - - - -
- - All operations on this relay are disabled - -
-
- -
- -
-
- ON - preview -
- -
-
- OFF - preview -
- - -
- -
- -
-
- - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
- -
-
- - - - - - - - - - - - - -
- - Disconnects when turning - OFF - -
-
- -
- -
-
- s - -
- Requires OctoPrint 1.9.0+ -
-
- -
- -
-
- BCM - -
- - - - - -
-
- -
- -
-
- - - - - - - - - -
- - For normally closed relays - - - - -
-
- -
- -
-
- - - - - - - - - -
- - Enables an extra dialog - -
-
- -
- -
-
- - - - - - - - - -
- - Including the ability to cancel - -
-
- - - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
-
- -
-
- -
-
- - - - - - - - - -
- - All operations on this relay are disabled - -
-
- -
- -
-
- ON - preview -
- -
-
- OFF - preview -
- - -
- -
- -
-
- - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
- -
-
- - - - - - - - - - - - - -
- - Disconnects when turning - OFF - -
-
- -
- -
-
- s - -
- Requires OctoPrint 1.9.0+ -
-
- -
- -
-
- BCM - -
- - - - - -
-
- -
- -
-
- - - - - - - - - -
- - For normally closed relays - - - - -
-
- -
- -
-
- - - - - - - - - -
- - Enables an extra dialog - -
-
- -
- -
-
- - - - - - - - - -
- - Including the ability to cancel - -
-
- - - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
-
- -
-
- -
-
- - - - - - - - - -
- - All operations on this relay are disabled - -
-
- -
- -
-
- ON - preview -
- -
-
- OFF - preview -
- - -
- -
- -
-
- - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
- -
-
- - - - - - - - - - - - - -
- - Disconnects when turning - OFF - -
-
- -
- -
-
- s - -
- Requires OctoPrint 1.9.0+ -
-
- -
- -
-
- BCM - -
- - - - - -
-
- -
- -
-
- - - - - - - - - -
- - For normally closed relays - - - - -
-
- -
- -
-
- - - - - - - - - -
- - Enables an extra dialog - -
-
- -
- -
-
- - - - - - - - - -
- - Including the ability to cancel - -
-
- - - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
-
- -
-
- -
-
- - - - - - - - - -
- - All operations on this relay are disabled - -
-
- -
- -
-
- ON - preview -
- -
-
- OFF - preview -
- - -
- -
- -
-
- - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
- -
-
- - - - - - - - - - - - - -
- - Disconnects when turning - OFF - -
-
- -
- -
-
- s - -
- Requires OctoPrint 1.9.0+ -
-
- -
- -
-
- BCM - -
- - - - - -
-
- -
- -
-
- - - - - - - - - -
- - For normally closed relays - - - - -
-
- -
- -
-
- - - - - - - - - -
- - Enables an extra dialog - -
-
- -
- -
-
- - - - - - - - - -
- - Including the ability to cancel - -
-
- - - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
-
- -
-
- -
-
- - - - - - - - - -
- - All operations on this relay are disabled - -
-
- -
- -
-
- ON - preview -
- -
-
- OFF - preview -
- - -
- -
- -
-
- - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
- -
-
- - - - - - - - - - - - - -
- - Disconnects when turning - OFF - -
-
- -
- -
-
- s - -
- Requires OctoPrint 1.9.0+ -
-
- -
- -
-
- BCM - -
- - - - - -
-
- -
- -
-
- - - - - - - - - -
- - For normally closed relays - - - - -
-
- -
- -
-
- - - - - - - - - -
- - Enables an extra dialog - -
-
- -
- -
-
- - - - - - - - - -
- - Including the ability to cancel - -
-
- - - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
-
- -
-
- -
-
- - - - - - - - - -
- - All operations on this relay are disabled - -
-
- -
- -
-
- ON - preview -
- -
-
- OFF - preview -
- - -
- -
- -
-
- - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
- -
-
- - - - - - - - - - - - - -
- - Disconnects when turning - OFF - -
-
- -
- -
-
- s - -
- Requires OctoPrint 1.9.0+ -
-
- -
- -
-
- BCM - -
- - - - - -
-
- -
- -
-
- - - - - - - - - -
- - For normally closed relays - - - - -
-
- -
- -
-
- - - - - - - - - -
- - Enables an extra dialog - -
-
- -
- -
-
- - - - - - - - - -
- - Including the ability to cancel - -
-
- - - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
-
- -
-
- -
-
- - - - - - - - - -
- - All operations on this relay are disabled - -
-
- -
- -
-
- ON - preview -
- -
-
- OFF - preview -
- - -
- -
- -
-
- - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
- -
-
- - - - - - - - - - - - - -
- - Disconnects when turning - OFF - -
-
- -
- -
-
- s - -
- Requires OctoPrint 1.9.0+ -
-
- -
- -
-
- BCM - -
- - - - - -
-
- -
- -
-
- - - - - - - - - -
- - For normally closed relays - - - - -
-
- -
- -
-
- - - - - - - - - -
- - Enables an extra dialog - -
-
- -
- -
-
- - - - - - - - - -
- - Including the ability to cancel - -
-
- - - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
-
- -
-
- -
-
- - - - - - - - - -
- - All operations on this relay are disabled - -
-
- -
- -
-
- ON - preview -
- -
-
- OFF - preview -
- - -
- -
- -
-
- - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
- -
-
- - - - - - - - - - - - - -
- - Disconnects when turning - OFF - -
-
- -
- -
-
- s - -
- Requires OctoPrint 1.9.0+ -
-
- -
- -
-
- BCM - -
- - - - - -
-
- -
- -
-
- - - - - - - - - -
- - For normally closed relays - - - - -
-
- -
- -
-
- - - - - - - - - -
- - Enables an extra dialog - -
-
- -
- -
-
- - - - - - - - - -
- - Including the ability to cancel - -
-
- - - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - - - - -
- -
-
- - - - - - - - - - - - - - - - -
-
- delay - - s -
-
-
- - - -
- -
-
- - -
-
-
- -
- -
-
- - -
-
-
- - -
-
- -
-
''' diff --git a/tests/test_templates.py b/tests/test_templates.py deleted file mode 100644 index 1b7862c0..00000000 --- a/tests/test_templates.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -import unittest -import sys -from unittest.mock import Mock -from snapshottest import TestCase -from jinja2 import Environment, FileSystemLoader - -# Mocking required before the further import -sys.modules["RPi.GPIO"] = Mock() - -# pylint: disable=wrong-import-position -from octoprint_octorelay.const import get_ui_vars - -# avoid keeping other modules automatically imported by this test -if "octoprint_octorelay" in sys.modules: - del sys.modules["octoprint_octorelay"] - -environment = Environment(loader=FileSystemLoader("../octoprint_octorelay/templates/")) - -class TestTemplates(TestCase): - def test_templates(self): - files = [ - "octorelay_settings.jinja2", - "octorelay_navbar.jinja2" - ] - ui_vars = get_ui_vars() - for file in files: - template = environment.get_template(file) - html = template.render({ - "_": lambda value: value, - **{ "plugin_octorelay_" + key: value for key, value in ui_vars.items() } - }) - self.assertMatchSnapshot(html, file) - -if __name__ == "__main__": - unittest.main()