From 894e7a8de600e9eabb94e4b2d7d702a3da020692 Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Fri, 24 Nov 2023 07:16:22 -0800 Subject: [PATCH 01/12] Switch from setup.py to pyproject.toml, update unit tests, update github workflows. --- pyproject.toml | 75 +++++++++++++++++++ requirements.txt | 1 - setup.py | 52 ------------- src/{statick_web => statick_tool}/__init__.py | 0 .../plugins/__init__.py | 0 .../plugins/discovery/__init__.py | 0 .../plugins/discovery/css.py} | 0 .../plugins/discovery/html.py} | 0 .../plugins/discovery/javascript.py} | 0 .../plugins/tool/__init__.py | 0 .../plugins/tool/eslint.py} | 0 .../plugins/tool/htmllint.py} | 0 .../plugins/tool/jshint.py} | 0 .../plugins/tool/stylelint.py} | 0 {rsc => src/statick_tool/rsc}/.eslintrc | 0 {rsc => src/statick_tool/rsc}/.htmllintrc | 0 {rsc => src/statick_tool/rsc}/.jshintrc | 0 {rsc => src/statick_tool/rsc}/.stylelintrc | 0 .../statick_tool/rsc}/eslint-profile.yaml | 0 .../statick_tool/rsc}/htmllint-profile.yaml | 0 .../statick_tool/rsc}/jshint-profile.yaml | 0 .../statick_tool/rsc}/stylelint-profile.yaml | 0 {rsc => src/statick_tool/rsc}/web-config.yaml | 0 .../statick_tool/rsc}/web-profile.yaml | 0 .../css_discovery_plugin.yapsy-plugin | 3 - .../html_discovery_plugin.yapsy-plugin | 3 - .../javascript_discovery_plugin.yapsy-plugin | 3 - .../tool/eslint_tool_plugin.yapsy-plugin | 3 - .../tool/htmllint_tool_plugin.yapsy-plugin | 3 - .../tool/jshint_tool_plugin.yapsy-plugin | 3 - .../tool/stylelint_tool_plugin.yapsy-plugin | 3 - .../test_css_discovery_plugin.py | 38 ++++------ .../test_html_discovery_plugin.py | 39 ++++------ .../test_javascript_discovery_plugin.py | 40 ++++------ .../test_eslint_tool_plugin.py | 47 +++++------- .../test_htmllint_tool_plugin.py | 47 +++++------- .../test_jshint_tool_plugin.py | 45 +++++------ .../test_stylelint_tool_plugin.py | 45 +++++------ tox.ini | 44 ++--------- 39 files changed, 191 insertions(+), 303 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py rename src/{statick_web => statick_tool}/__init__.py (100%) rename src/{statick_web => statick_tool}/plugins/__init__.py (100%) rename src/{statick_web => statick_tool}/plugins/discovery/__init__.py (100%) rename src/{statick_web/plugins/discovery/css_discovery_plugin.py => statick_tool/plugins/discovery/css.py} (100%) rename src/{statick_web/plugins/discovery/html_discovery_plugin.py => statick_tool/plugins/discovery/html.py} (100%) rename src/{statick_web/plugins/discovery/javascript_discovery_plugin.py => statick_tool/plugins/discovery/javascript.py} (100%) rename src/{statick_web => statick_tool}/plugins/tool/__init__.py (100%) rename src/{statick_web/plugins/tool/eslint_tool_plugin.py => statick_tool/plugins/tool/eslint.py} (100%) rename src/{statick_web/plugins/tool/htmllint_tool_plugin.py => statick_tool/plugins/tool/htmllint.py} (100%) rename src/{statick_web/plugins/tool/jshint_tool_plugin.py => statick_tool/plugins/tool/jshint.py} (100%) rename src/{statick_web/plugins/tool/stylelint_tool_plugin.py => statick_tool/plugins/tool/stylelint.py} (100%) rename {rsc => src/statick_tool/rsc}/.eslintrc (100%) rename {rsc => src/statick_tool/rsc}/.htmllintrc (100%) rename {rsc => src/statick_tool/rsc}/.jshintrc (100%) rename {rsc => src/statick_tool/rsc}/.stylelintrc (100%) rename {rsc => src/statick_tool/rsc}/eslint-profile.yaml (100%) rename {rsc => src/statick_tool/rsc}/htmllint-profile.yaml (100%) rename {rsc => src/statick_tool/rsc}/jshint-profile.yaml (100%) rename {rsc => src/statick_tool/rsc}/stylelint-profile.yaml (100%) rename {rsc => src/statick_tool/rsc}/web-config.yaml (100%) rename {rsc => src/statick_tool/rsc}/web-profile.yaml (100%) delete mode 100644 src/statick_web/plugins/discovery/css_discovery_plugin.yapsy-plugin delete mode 100644 src/statick_web/plugins/discovery/html_discovery_plugin.yapsy-plugin delete mode 100644 src/statick_web/plugins/discovery/javascript_discovery_plugin.yapsy-plugin delete mode 100644 src/statick_web/plugins/tool/eslint_tool_plugin.yapsy-plugin delete mode 100644 src/statick_web/plugins/tool/htmllint_tool_plugin.yapsy-plugin delete mode 100644 src/statick_web/plugins/tool/jshint_tool_plugin.yapsy-plugin delete mode 100644 src/statick_web/plugins/tool/stylelint_tool_plugin.yapsy-plugin diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..14673a6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,75 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "statick-web" +authors = [{name = "NIWC Pacific"}] +description="Statick analysis plugins for Web (css, html, js) files." +version = "0.1.3" +readme = "README.md" +requires-python = ">=3.8" +license = {text = "CC0-1.0"} +classifiers = [ + "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Quality Assurance", + "Topic :: Software Development :: Testing", + "Typing :: Typed", +] + +dependencies = [ + "importlib_metadata", + "statick", +] + +[tool.setuptools.package-data] +statick_tool = [ + "rsc/*", + "rsc/.*", +] + +[project.entry-points."statick_tool.plugins.discovery"] +css = "statick_tool.plugins.discovery.css:CSSDiscoveryPlugin" +html = "statick_tool.plugins.discovery.html:HTMLDiscoveryPlugin" +javascript = "statick_tool.plugins.discovery.javascript:JavaScriptDiscoveryPlugin" + +[project.entry-points."statick_tool.plugins.tool"] +eslint = "statick_tool.plugins.tool.eslint:ESLintToolPlugin" +htmllint = "statick_tool.plugins.tool.htmllint:HTMLLintToolPlugin" +jshint = "statick_tool.plugins.tool.jshint:JSHintToolPlugin" +stylelint = "statick_tool.plugins.tool.stylelint:StylelintToolPlugin" + +[project.urls] +"Homepage" = "https://github.com/sscpac/statick-web" +"Bug Tracker" = "https://github.com/sscpac/statick-web/issues" + +[project.optional-dependencies] +test = [ + "coverage", + "flake8-pep3101", + "flake8<5", # Pin until https://github.com/tholo/pytest-flake8/issues/87 is fixed. + "mock", + "mypy", + "pycodestyle<2.9.0", # Pin until https://github.com/tholo/pytest-flake8/issues/87 is fixed. + "pydocstyle", + "pytest", + "pytest-cov", + "setuptools", + "statick", + "statick-md", + "tox", + "tox-gh-actions", +] +docs = [ + "yaml-1.3", +] +dist = [ + "setuptools", + "wheel", +] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 15f3587..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -statick diff --git a/setup.py b/setup.py deleted file mode 100644 index 449066f..0000000 --- a/setup.py +++ /dev/null @@ -1,52 +0,0 @@ -"""Setup.""" - - -from setuptools import setup - -with open("README.md", encoding="utf8") as fid: - long_description = fid.read() # pylint: disable=invalid-name - -TEST_DEPS = [ - "mock", - "pytest", -] - -EXTRAS = { - "test": TEST_DEPS, -} - -setup( - author="NIWC Pacific", - name="statick-web", - description="Statick analysis plugins for Web (css, html, js) files.", - version="0.1.3", - packages=[ - "statick_tool", - "statick_tool.plugins.discovery", - "statick_tool.plugins.tool", - ], - package_dir={ - "statick_tool": ".", - "statick_tool.plugins.discovery": "src/statick_web/plugins/discovery", - "statick_tool.plugins.tool": "src/statick_web/plugins/tool", - }, - package_data={ - "statick_tool": ["rsc/.*", "rsc/*"], - "statick_tool.plugins.discovery": ["*.yapsy-plugin"], - "statick_tool.plugins.tool": ["*.yapsy-plugin"], - }, - long_description=long_description, - long_description_content_type="text/markdown", - install_requires=["statick"], - tests_require=TEST_DEPS, - extras_require=EXTRAS, - url="https://github.com/sscpac/statick-web", - classifiers=[ - "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Software Development :: Testing", - ], -) diff --git a/src/statick_web/__init__.py b/src/statick_tool/__init__.py similarity index 100% rename from src/statick_web/__init__.py rename to src/statick_tool/__init__.py diff --git a/src/statick_web/plugins/__init__.py b/src/statick_tool/plugins/__init__.py similarity index 100% rename from src/statick_web/plugins/__init__.py rename to src/statick_tool/plugins/__init__.py diff --git a/src/statick_web/plugins/discovery/__init__.py b/src/statick_tool/plugins/discovery/__init__.py similarity index 100% rename from src/statick_web/plugins/discovery/__init__.py rename to src/statick_tool/plugins/discovery/__init__.py diff --git a/src/statick_web/plugins/discovery/css_discovery_plugin.py b/src/statick_tool/plugins/discovery/css.py similarity index 100% rename from src/statick_web/plugins/discovery/css_discovery_plugin.py rename to src/statick_tool/plugins/discovery/css.py diff --git a/src/statick_web/plugins/discovery/html_discovery_plugin.py b/src/statick_tool/plugins/discovery/html.py similarity index 100% rename from src/statick_web/plugins/discovery/html_discovery_plugin.py rename to src/statick_tool/plugins/discovery/html.py diff --git a/src/statick_web/plugins/discovery/javascript_discovery_plugin.py b/src/statick_tool/plugins/discovery/javascript.py similarity index 100% rename from src/statick_web/plugins/discovery/javascript_discovery_plugin.py rename to src/statick_tool/plugins/discovery/javascript.py diff --git a/src/statick_web/plugins/tool/__init__.py b/src/statick_tool/plugins/tool/__init__.py similarity index 100% rename from src/statick_web/plugins/tool/__init__.py rename to src/statick_tool/plugins/tool/__init__.py diff --git a/src/statick_web/plugins/tool/eslint_tool_plugin.py b/src/statick_tool/plugins/tool/eslint.py similarity index 100% rename from src/statick_web/plugins/tool/eslint_tool_plugin.py rename to src/statick_tool/plugins/tool/eslint.py diff --git a/src/statick_web/plugins/tool/htmllint_tool_plugin.py b/src/statick_tool/plugins/tool/htmllint.py similarity index 100% rename from src/statick_web/plugins/tool/htmllint_tool_plugin.py rename to src/statick_tool/plugins/tool/htmllint.py diff --git a/src/statick_web/plugins/tool/jshint_tool_plugin.py b/src/statick_tool/plugins/tool/jshint.py similarity index 100% rename from src/statick_web/plugins/tool/jshint_tool_plugin.py rename to src/statick_tool/plugins/tool/jshint.py diff --git a/src/statick_web/plugins/tool/stylelint_tool_plugin.py b/src/statick_tool/plugins/tool/stylelint.py similarity index 100% rename from src/statick_web/plugins/tool/stylelint_tool_plugin.py rename to src/statick_tool/plugins/tool/stylelint.py diff --git a/rsc/.eslintrc b/src/statick_tool/rsc/.eslintrc similarity index 100% rename from rsc/.eslintrc rename to src/statick_tool/rsc/.eslintrc diff --git a/rsc/.htmllintrc b/src/statick_tool/rsc/.htmllintrc similarity index 100% rename from rsc/.htmllintrc rename to src/statick_tool/rsc/.htmllintrc diff --git a/rsc/.jshintrc b/src/statick_tool/rsc/.jshintrc similarity index 100% rename from rsc/.jshintrc rename to src/statick_tool/rsc/.jshintrc diff --git a/rsc/.stylelintrc b/src/statick_tool/rsc/.stylelintrc similarity index 100% rename from rsc/.stylelintrc rename to src/statick_tool/rsc/.stylelintrc diff --git a/rsc/eslint-profile.yaml b/src/statick_tool/rsc/eslint-profile.yaml similarity index 100% rename from rsc/eslint-profile.yaml rename to src/statick_tool/rsc/eslint-profile.yaml diff --git a/rsc/htmllint-profile.yaml b/src/statick_tool/rsc/htmllint-profile.yaml similarity index 100% rename from rsc/htmllint-profile.yaml rename to src/statick_tool/rsc/htmllint-profile.yaml diff --git a/rsc/jshint-profile.yaml b/src/statick_tool/rsc/jshint-profile.yaml similarity index 100% rename from rsc/jshint-profile.yaml rename to src/statick_tool/rsc/jshint-profile.yaml diff --git a/rsc/stylelint-profile.yaml b/src/statick_tool/rsc/stylelint-profile.yaml similarity index 100% rename from rsc/stylelint-profile.yaml rename to src/statick_tool/rsc/stylelint-profile.yaml diff --git a/rsc/web-config.yaml b/src/statick_tool/rsc/web-config.yaml similarity index 100% rename from rsc/web-config.yaml rename to src/statick_tool/rsc/web-config.yaml diff --git a/rsc/web-profile.yaml b/src/statick_tool/rsc/web-profile.yaml similarity index 100% rename from rsc/web-profile.yaml rename to src/statick_tool/rsc/web-profile.yaml diff --git a/src/statick_web/plugins/discovery/css_discovery_plugin.yapsy-plugin b/src/statick_web/plugins/discovery/css_discovery_plugin.yapsy-plugin deleted file mode 100644 index c7ee669..0000000 --- a/src/statick_web/plugins/discovery/css_discovery_plugin.yapsy-plugin +++ /dev/null @@ -1,3 +0,0 @@ -[Core] -Name = CSS Discovery Plugin -Module = css_discovery_plugin diff --git a/src/statick_web/plugins/discovery/html_discovery_plugin.yapsy-plugin b/src/statick_web/plugins/discovery/html_discovery_plugin.yapsy-plugin deleted file mode 100644 index 3709de0..0000000 --- a/src/statick_web/plugins/discovery/html_discovery_plugin.yapsy-plugin +++ /dev/null @@ -1,3 +0,0 @@ -[Core] -Name = HTML Discovery Plugin -Module = html_discovery_plugin diff --git a/src/statick_web/plugins/discovery/javascript_discovery_plugin.yapsy-plugin b/src/statick_web/plugins/discovery/javascript_discovery_plugin.yapsy-plugin deleted file mode 100644 index 4615f89..0000000 --- a/src/statick_web/plugins/discovery/javascript_discovery_plugin.yapsy-plugin +++ /dev/null @@ -1,3 +0,0 @@ -[Core] -Name = JavaScript Discovery Plugin -Module = javascript_discovery_plugin diff --git a/src/statick_web/plugins/tool/eslint_tool_plugin.yapsy-plugin b/src/statick_web/plugins/tool/eslint_tool_plugin.yapsy-plugin deleted file mode 100644 index a64ce9d..0000000 --- a/src/statick_web/plugins/tool/eslint_tool_plugin.yapsy-plugin +++ /dev/null @@ -1,3 +0,0 @@ -[Core] -Name = ESLint Tool Plugin -Module = eslint_tool_plugin diff --git a/src/statick_web/plugins/tool/htmllint_tool_plugin.yapsy-plugin b/src/statick_web/plugins/tool/htmllint_tool_plugin.yapsy-plugin deleted file mode 100644 index a4dd101..0000000 --- a/src/statick_web/plugins/tool/htmllint_tool_plugin.yapsy-plugin +++ /dev/null @@ -1,3 +0,0 @@ -[Core] -Name = HTMLLint Tool Plugin -Module = htmllint_tool_plugin diff --git a/src/statick_web/plugins/tool/jshint_tool_plugin.yapsy-plugin b/src/statick_web/plugins/tool/jshint_tool_plugin.yapsy-plugin deleted file mode 100644 index 417de52..0000000 --- a/src/statick_web/plugins/tool/jshint_tool_plugin.yapsy-plugin +++ /dev/null @@ -1,3 +0,0 @@ -[Core] -Name = JSHint Tool Plugin -Module = jshint_tool_plugin diff --git a/src/statick_web/plugins/tool/stylelint_tool_plugin.yapsy-plugin b/src/statick_web/plugins/tool/stylelint_tool_plugin.yapsy-plugin deleted file mode 100644 index beb11b2..0000000 --- a/src/statick_web/plugins/tool/stylelint_tool_plugin.yapsy-plugin +++ /dev/null @@ -1,3 +0,0 @@ -[Core] -Name = stylelint Tool Plugin -Module = stylelint_tool_plugin diff --git a/tests/discovery/css_discovery_plugin/test_css_discovery_plugin.py b/tests/discovery/css_discovery_plugin/test_css_discovery_plugin.py index 8e28ea9..618a731 100644 --- a/tests/discovery/css_discovery_plugin/test_css_discovery_plugin.py +++ b/tests/discovery/css_discovery_plugin/test_css_discovery_plugin.py @@ -1,38 +1,26 @@ """Unit tests for the CSS discovery plugin.""" import os +import sys -from yapsy.PluginManager import PluginManager - -import statick_tool -from statick_tool.discovery_plugin import DiscoveryPlugin from statick_tool.exceptions import Exceptions from statick_tool.package import Package -from statick_tool.plugins.discovery.css_discovery_plugin import CSSDiscoveryPlugin +from statick_tool.plugins.discovery.css import CSSDiscoveryPlugin + +if sys.version_info < (3, 10): + from importlib_metadata import entry_points +else: + from importlib.metadata import entry_points def test_css_plugin_found(): """Test that the plugin manager finds the css discovery plugin.""" - manager = PluginManager() - # Get the path to statick_tool/__init__.py, get the directory part, and - # add 'plugins' to that to get the standard plugins dir - manager.setPluginPlaces( - [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")] - ) - manager.setCategoriesFilter( - { - "Discovery": DiscoveryPlugin, - } - ) - manager.collectPlugins() - # Verify that a plugin's get_name() function returns "css" - assert any( - plugin_info.plugin_object.get_name() == "css" - for plugin_info in manager.getPluginsOfCategory("Discovery") - ) - # While we're at it, verify that a plugin is named CSS Discovery Plugin + discovery_plugins = {} + plugins = entry_points(group="statick_tool.plugins.discovery") + for plugin_type in plugins: + plugin = plugin_type.load() + discovery_plugins[plugin_type.name] = plugin() assert any( - plugin_info.name == "CSS Discovery Plugin" - for plugin_info in manager.getPluginsOfCategory("Discovery") + plugin.get_name() == "css" for _, plugin in list(discovery_plugins.items()) ) diff --git a/tests/discovery/html_discovery_plugin/test_html_discovery_plugin.py b/tests/discovery/html_discovery_plugin/test_html_discovery_plugin.py index 02efabd..258b147 100644 --- a/tests/discovery/html_discovery_plugin/test_html_discovery_plugin.py +++ b/tests/discovery/html_discovery_plugin/test_html_discovery_plugin.py @@ -1,39 +1,26 @@ """Unit tests for the HTML discovery plugin.""" - import os +import sys -from yapsy.PluginManager import PluginManager - -import statick_tool -from statick_tool.discovery_plugin import DiscoveryPlugin from statick_tool.exceptions import Exceptions from statick_tool.package import Package -from statick_tool.plugins.discovery.html_discovery_plugin import HTMLDiscoveryPlugin +from statick_tool.plugins.discovery.html import HTMLDiscoveryPlugin + +if sys.version_info < (3, 10): + from importlib_metadata import entry_points +else: + from importlib.metadata import entry_points def test_html_plugin_found(): """Test that the plugin manager finds the html discovery plugin.""" - manager = PluginManager() - # Get the path to statick_tool/__init__.py, get the directory part, and - # add 'plugins' to that to get the standard plugins dir - manager.setPluginPlaces( - [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")] - ) - manager.setCategoriesFilter( - { - "Discovery": DiscoveryPlugin, - } - ) - manager.collectPlugins() - # Verify that a plugin's get_name() function returns "html" - assert any( - plugin_info.plugin_object.get_name() == "html" - for plugin_info in manager.getPluginsOfCategory("Discovery") - ) - # While we're at it, verify that a plugin is named html Discovery Plugin + discovery_plugins = {} + plugins = entry_points(group="statick_tool.plugins.discovery") + for plugin_type in plugins: + plugin = plugin_type.load() + discovery_plugins[plugin_type.name] = plugin() assert any( - plugin_info.name == "HTML Discovery Plugin" - for plugin_info in manager.getPluginsOfCategory("Discovery") + plugin.get_name() == "html" for _, plugin in list(discovery_plugins.items()) ) diff --git a/tests/discovery/javascript_discovery_plugin/test_javascript_discovery_plugin.py b/tests/discovery/javascript_discovery_plugin/test_javascript_discovery_plugin.py index 1e0ac98..66881ff 100644 --- a/tests/discovery/javascript_discovery_plugin/test_javascript_discovery_plugin.py +++ b/tests/discovery/javascript_discovery_plugin/test_javascript_discovery_plugin.py @@ -1,40 +1,26 @@ """Unit tests for the JavaScript discovery plugin.""" import os +import sys -from yapsy.PluginManager import PluginManager - -import statick_tool -from statick_tool.discovery_plugin import DiscoveryPlugin from statick_tool.exceptions import Exceptions from statick_tool.package import Package -from statick_tool.plugins.discovery.javascript_discovery_plugin import ( - JavaScriptDiscoveryPlugin, -) +from statick_tool.plugins.discovery.javascript import JavaScriptDiscoveryPlugin + +if sys.version_info < (3, 10): + from importlib_metadata import entry_points +else: + from importlib.metadata import entry_points def test_javascript_plugin_found(): """Test that the plugin manager finds the JavaScript discovery plugin.""" - manager = PluginManager() - # Get the path to statick_tool/__init__.py, get the directory part, and - # add 'plugins' to that to get the standard plugins dir - manager.setPluginPlaces( - [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")] - ) - manager.setCategoriesFilter( - { - "Discovery": DiscoveryPlugin, - } - ) - manager.collectPlugins() - # Verify that a plugin's get_name() function returns "javascript" - assert any( - plugin_info.plugin_object.get_name() == "javascript" - for plugin_info in manager.getPluginsOfCategory("Discovery") - ) - # While we're at it, verify that a plugin is named javascript Discovery Plugin + discovery_plugins = {} + plugins = entry_points(group="statick_tool.plugins.discovery") + for plugin_type in plugins: + plugin = plugin_type.load() + discovery_plugins[plugin_type.name] = plugin() assert any( - plugin_info.name == "JavaScript Discovery Plugin" - for plugin_info in manager.getPluginsOfCategory("Discovery") + plugin.get_name() == "javascript" for _, plugin in list(discovery_plugins.items()) ) diff --git a/tests/tool/eslint_tool_plugin/test_eslint_tool_plugin.py b/tests/tool/eslint_tool_plugin/test_eslint_tool_plugin.py index 5797b72..e92476f 100644 --- a/tests/tool/eslint_tool_plugin/test_eslint_tool_plugin.py +++ b/tests/tool/eslint_tool_plugin/test_eslint_tool_plugin.py @@ -1,19 +1,22 @@ """Unit tests for the eslint plugin.""" import argparse -import os -import subprocess - import mock +import os import pytest -from yapsy.PluginManager import PluginManager +import subprocess +import sys import statick_tool from statick_tool.config import Config from statick_tool.package import Package from statick_tool.plugin_context import PluginContext -from statick_tool.plugins.tool.eslint_tool_plugin import ESLintToolPlugin +from statick_tool.plugins.tool.eslint import ESLintToolPlugin from statick_tool.resources import Resources -from statick_tool.tool_plugin import ToolPlugin + +if sys.version_info < (3, 10): + from importlib_metadata import entry_points +else: + from importlib.metadata import entry_points def setup_eslint_tool_plugin(test_package="valid_package"): @@ -42,27 +45,13 @@ def setup_eslint_tool_plugin(test_package="valid_package"): def test_eslint_tool_plugin_found(): """Test that the plugin manager can find the eslint plugin.""" - manager = PluginManager() - # Get the path to statick_tool/__init__.py, get the directory part, and - # add 'plugins' to that to get the standard plugins dir - manager.setPluginPlaces( - [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")] - ) - manager.setCategoriesFilter( - { - "Tool": ToolPlugin, - } - ) - manager.collectPlugins() - # Verify that a plugin's get_name() function returns "eslint" - assert any( - plugin_info.plugin_object.get_name() == "eslint" - for plugin_info in manager.getPluginsOfCategory("Tool") - ) - # While we're at it, verify that a plugin is named ESLint Tool Plugin + tool_plugins = {} + plugins = entry_points(group="statick_tool.plugins.tool") + for plugin_type in plugins: + plugin = plugin_type.load() + tool_plugins[plugin_type.name] = plugin() assert any( - plugin_info.name == "ESLint Tool Plugin" - for plugin_info in manager.getPluginsOfCategory("Tool") + plugin.get_name() == "eslint" for _, plugin in list(tool_plugins.items()) ) @@ -136,7 +125,7 @@ def test_eslint_tool_plugin_parse_invalid(): assert not issues -@mock.patch("statick_tool.plugins.tool.eslint_tool_plugin.subprocess.check_output") +@mock.patch("statick_tool.plugins.tool.eslint.subprocess.check_output") def test_eslint_tool_plugin_scan_calledprocesserror(mock_subprocess_check_output): """ Test what happens when a CalledProcessError is raised (usually means eslint hit an error). @@ -167,7 +156,7 @@ def test_eslint_tool_plugin_scan_calledprocesserror(mock_subprocess_check_output @mock.patch( - "statick_tool.plugins.tool.eslint_tool_plugin.subprocess.check_output" + "statick_tool.plugins.tool.eslint.subprocess.check_output" ) def test_eslint_tool_plugin_scan_nodejs_error(mock_subprocess_check_output): """ @@ -203,7 +192,7 @@ def test_eslint_tool_plugin_scan_nodejs_error(mock_subprocess_check_output): assert issues is None -@mock.patch("statick_tool.plugins.tool.eslint_tool_plugin.subprocess.check_output") +@mock.patch("statick_tool.plugins.tool.eslint.subprocess.check_output") def test_eslint_tool_plugin_scan_oserror(mock_subprocess_check_output): """ Test what happens when an OSError is raised (usually means eslint doesn't exist). diff --git a/tests/tool/htmllint_tool_plugin/test_htmllint_tool_plugin.py b/tests/tool/htmllint_tool_plugin/test_htmllint_tool_plugin.py index 57b56e6..3d920e8 100644 --- a/tests/tool/htmllint_tool_plugin/test_htmllint_tool_plugin.py +++ b/tests/tool/htmllint_tool_plugin/test_htmllint_tool_plugin.py @@ -1,19 +1,22 @@ """Unit tests for the htmllint plugin.""" import argparse -import os -import subprocess - import mock +import os import pytest -from yapsy.PluginManager import PluginManager +import subprocess +import sys import statick_tool from statick_tool.config import Config from statick_tool.package import Package from statick_tool.plugin_context import PluginContext -from statick_tool.plugins.tool.htmllint_tool_plugin import HTMLLintToolPlugin +from statick_tool.plugins.tool.htmllint import HTMLLintToolPlugin from statick_tool.resources import Resources -from statick_tool.tool_plugin import ToolPlugin + +if sys.version_info < (3, 10): + from importlib_metadata import entry_points +else: + from importlib.metadata import entry_points def setup_htmllint_tool_plugin(): @@ -42,27 +45,13 @@ def setup_htmllint_tool_plugin(): def test_htmllint_tool_plugin_found(): """Test that the plugin manager can find the htmllint plugin.""" - manager = PluginManager() - # Get the path to statick_tool/__init__.py, get the directory part, and - # add 'plugins' to that to get the standard plugins dir - manager.setPluginPlaces( - [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")] - ) - manager.setCategoriesFilter( - { - "Tool": ToolPlugin, - } - ) - manager.collectPlugins() - # Verify that a plugin's get_name() function returns "htmllint" - assert any( - plugin_info.plugin_object.get_name() == "htmllint" - for plugin_info in manager.getPluginsOfCategory("Tool") - ) - # While we're at it, verify that a plugin is named htmllint Tool Plugin + tool_plugins = {} + plugins = entry_points(group="statick_tool.plugins.tool") + for plugin_type in plugins: + plugin = plugin_type.load() + tool_plugins[plugin_type.name] = plugin() assert any( - plugin_info.name == "HTMLLint Tool Plugin" - for plugin_info in manager.getPluginsOfCategory("Tool") + plugin.get_name() == "htmllint" for _, plugin in list(tool_plugins.items()) ) @@ -119,7 +108,7 @@ def test_htmllint_tool_plugin_parse_invalid(): assert not issues -@mock.patch("statick_tool.plugins.tool.htmllint_tool_plugin.subprocess.check_output") +@mock.patch("statick_tool.plugins.tool.htmllint.subprocess.check_output") def test_htmllint_tool_plugin_scan_calledprocesserror(mock_subprocess_check_output): """ Test what happens when a CalledProcessError is raised (usually means htmllint hit an error). @@ -147,7 +136,7 @@ def test_htmllint_tool_plugin_scan_calledprocesserror(mock_subprocess_check_outp @mock.patch( - "statick_tool.plugins.tool.htmllint_tool_plugin.subprocess.check_output" + "statick_tool.plugins.tool.htmllint.subprocess.check_output" ) def test_htmllint_tool_plugin_scan_nodejs_error(mock_subprocess_check_output): """ @@ -180,7 +169,7 @@ def test_htmllint_tool_plugin_scan_nodejs_error(mock_subprocess_check_output): assert issues is None -@mock.patch("statick_tool.plugins.tool.htmllint_tool_plugin.subprocess.check_output") +@mock.patch("statick_tool.plugins.tool.htmllint.subprocess.check_output") def test_htmllint_tool_plugin_scan_oserror(mock_subprocess_check_output): """ Test what happens when an OSError is raised (usually means htmllint doesn't exist). diff --git a/tests/tool/jshint_tool_plugin/test_jshint_tool_plugin.py b/tests/tool/jshint_tool_plugin/test_jshint_tool_plugin.py index 5fa88d8..0509362 100644 --- a/tests/tool/jshint_tool_plugin/test_jshint_tool_plugin.py +++ b/tests/tool/jshint_tool_plugin/test_jshint_tool_plugin.py @@ -1,19 +1,22 @@ """Unit tests for the jshint plugin.""" import argparse -import os -import subprocess - import mock +import os import pytest -from yapsy.PluginManager import PluginManager +import subprocess +import sys import statick_tool from statick_tool.config import Config from statick_tool.package import Package from statick_tool.plugin_context import PluginContext -from statick_tool.plugins.tool.jshint_tool_plugin import JSHintToolPlugin +from statick_tool.plugins.tool.jshint import JSHintToolPlugin from statick_tool.resources import Resources -from statick_tool.tool_plugin import ToolPlugin + +if sys.version_info < (3, 10): + from importlib_metadata import entry_points +else: + from importlib.metadata import entry_points def setup_jshint_tool_plugin(): @@ -42,27 +45,13 @@ def setup_jshint_tool_plugin(): def test_jshint_tool_plugin_found(): """Test that the plugin manager can find the jshint plugin.""" - manager = PluginManager() - # Get the path to statick_tool/__init__.py, get the directory part, and - # add 'plugins' to that to get the standard plugins dir - manager.setPluginPlaces( - [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")] - ) - manager.setCategoriesFilter( - { - "Tool": ToolPlugin, - } - ) - manager.collectPlugins() - # Verify that a plugin's get_name() function returns "jshint" - assert any( - plugin_info.plugin_object.get_name() == "jshint" - for plugin_info in manager.getPluginsOfCategory("Tool") - ) - # While we're at it, verify that a plugin is named jshint Tool Plugin + tool_plugins = {} + plugins = entry_points(group="statick_tool.plugins.tool") + for plugin_type in plugins: + plugin = plugin_type.load() + tool_plugins[plugin_type.name] = plugin() assert any( - plugin_info.name == "JSHint Tool Plugin" - for plugin_info in manager.getPluginsOfCategory("Tool") + plugin.get_name() == "jshint" for _, plugin in list(tool_plugins.items()) ) @@ -122,7 +111,7 @@ def test_jshint_tool_plugin_parse_invalid(): assert not issues -@mock.patch("statick_tool.plugins.tool.jshint_tool_plugin.subprocess.check_output") +@mock.patch("statick_tool.plugins.tool.jshint.subprocess.check_output") def test_jshint_tool_plugin_scan_calledprocesserror(mock_subprocess_check_output): """ Test what happens when a CalledProcessError is raised (usually means jshint hit an error). @@ -152,7 +141,7 @@ def test_jshint_tool_plugin_scan_calledprocesserror(mock_subprocess_check_output assert not issues -@mock.patch("statick_tool.plugins.tool.jshint_tool_plugin.subprocess.check_output") +@mock.patch("statick_tool.plugins.tool.jshint.subprocess.check_output") def test_jshint_tool_plugin_scan_oserror(mock_subprocess_check_output): """ Test what happens when an OSError is raised (usually means jshint doesn't exist). diff --git a/tests/tool/stylelint_tool_plugin/test_stylelint_tool_plugin.py b/tests/tool/stylelint_tool_plugin/test_stylelint_tool_plugin.py index 266659f..e24ff8c 100644 --- a/tests/tool/stylelint_tool_plugin/test_stylelint_tool_plugin.py +++ b/tests/tool/stylelint_tool_plugin/test_stylelint_tool_plugin.py @@ -1,19 +1,22 @@ """Unit tests for the stylelint plugin.""" import argparse -import os -import subprocess - import mock +import os import pytest -from yapsy.PluginManager import PluginManager +import subprocess +import sys import statick_tool from statick_tool.config import Config from statick_tool.package import Package from statick_tool.plugin_context import PluginContext -from statick_tool.plugins.tool.stylelint_tool_plugin import StylelintToolPlugin +from statick_tool.plugins.tool.stylelint import StylelintToolPlugin from statick_tool.resources import Resources -from statick_tool.tool_plugin import ToolPlugin + +if sys.version_info < (3, 10): + from importlib_metadata import entry_points +else: + from importlib.metadata import entry_points def setup_stylelint_tool_plugin(): @@ -42,27 +45,13 @@ def setup_stylelint_tool_plugin(): def test_stylelint_tool_plugin_found(): """Test that the plugin manager can find the stylelint plugin.""" - manager = PluginManager() - # Get the path to statick_tool/__init__.py, get the directory part, and - # add 'plugins' to that to get the standard plugins dir - manager.setPluginPlaces( - [os.path.join(os.path.dirname(statick_tool.__file__), "plugins")] - ) - manager.setCategoriesFilter( - { - "Tool": ToolPlugin, - } - ) - manager.collectPlugins() - # Verify that a plugin's get_name() function returns "stylelint" - assert any( - plugin_info.plugin_object.get_name() == "stylelint" - for plugin_info in manager.getPluginsOfCategory("Tool") - ) - # While we're at it, verify that a plugin is named stylelint Tool Plugin + tool_plugins = {} + plugins = entry_points(group="statick_tool.plugins.tool") + for plugin_type in plugins: + plugin = plugin_type.load() + tool_plugins[plugin_type.name] = plugin() assert any( - plugin_info.name == "stylelint Tool Plugin" - for plugin_info in manager.getPluginsOfCategory("Tool") + plugin.get_name() == "stylelint" for _, plugin in list(tool_plugins.items()) ) @@ -125,7 +114,7 @@ def test_stylelint_tool_plugin_parse_invalid(): assert not issues -@mock.patch("statick_tool.plugins.tool.stylelint_tool_plugin.subprocess.check_output") +@mock.patch("statick_tool.plugins.tool.stylelint.subprocess.check_output") def test_stylelint_tool_plugin_scan_calledprocesserror(mock_subprocess_check_output): """ Test what happens when a CalledProcessError is raised (usually means stylelint hit an error). @@ -155,7 +144,7 @@ def test_stylelint_tool_plugin_scan_calledprocesserror(mock_subprocess_check_out assert not issues -@mock.patch("statick_tool.plugins.tool.stylelint_tool_plugin.subprocess.check_output") +@mock.patch("statick_tool.plugins.tool.stylelint.subprocess.check_output") def test_stylelint_tool_plugin_scan_oserror(mock_subprocess_check_output): """ Test what happens when an OSError is raised (usually means stylelint doesn't exist). diff --git a/tox.ini b/tox.ini index aa1c4c7..f99fc5f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,26 +1,9 @@ [tox] -envlist = py38, py39, py310, py311 +envlist = py38, py39, py310, py311, py312 skip_missing_interpreters = true [pytest] -flake8-max-line-length = 9000 -norecursedirs = .tox - -# To work with black some items must be ignored. -# https://github.com/psf/black#how-black-wraps-lines -[flake8] -exclude = .tox -ignore = E203, E231, W503 - -# To work with black a specific configuration is required. -# https://github.com/psf/black#how-black-wraps-lines -[isort] -known_first_party = statick_tool -multi_line_output = 3 -include_trailing_comma = True -force_grid_wrap = 0 -use_parentheses = True -line_length = 88 +norecursedirs = .tox build [gh-actions] python = @@ -28,33 +11,20 @@ python = 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [testenv] changedir = {toxinidir}/output-{envname} passenv = CI setenv = PY_IGNORE_IMPORTMISMATCH = 1 deps = - flake8<5 # Pin until https://github.com/tholo/pytest-flake8/issues/87 is fixed. - flake8-pep3101 - pycodestyle<2.9.0 # Pin until https://github.com/tholo/pytest-flake8/issues/87 is fixed. - pydocstyle - pytest - pytest-cov - pytest-flake8 - pytest-isort .[test] commands = - pydocstyle ../src/ - pycodestyle --ignore=E203,E501,W503 ../src/ - pytest --flake8 --isort \ - --cov=statick_tool.plugins.discovery.css_discovery_plugin \ - --cov=statick_tool.plugins.discovery.html_discovery_plugin \ - --cov=statick_tool.plugins.discovery.javascript_discovery_plugin \ - --cov=statick_tool.plugins.tool.eslint_tool_plugin \ - --cov=statick_tool.plugins.tool.htmllint_tool_plugin \ - --cov=statick_tool.plugins.tool.jshint_tool_plugin \ - --cov=statick_tool.plugins.tool.stylelint_tool_plugin \ + pytest \ + --cov={toxinidir}/src/statick_tool \ --cov-report term-missing \ --doctest-modules \ + --junit-xml=statick-{envname}-junit.xml \ + --junit-prefix={envname} \ {toxinidir} {posargs} coverage xml From 9270e3459fbd26cde9bdc0dbf1f51101abc707dd Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Sat, 25 Nov 2023 18:53:36 -0800 Subject: [PATCH 02/12] Dependency cleanup. --- .github/workflows/publish.yaml | 48 +++++++--------------------------- pyproject.toml | 15 +++-------- tox.ini | 2 -- 3 files changed, 13 insertions(+), 52 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 851dd32..dc1239a 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -10,55 +10,25 @@ jobs: build-n-publish: name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/statick-web + permissions: + id-token: write steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.11' - - - uses: actions/cache@v3 - if: startsWith(runner.os, 'Linux') - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - uses: actions/cache@v3 - if: startsWith(runner.os, 'macOS') - with: - path: ~/Library/Caches/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - uses: actions/cache@v3 - if: startsWith(runner.os, 'Windows') - with: - path: ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Install tools - run: | - python -m pip install --upgrade setuptools - python -m pip install --upgrade wheel + cache: 'pip' - name: Build a binary wheel and a source tarball run: | - python setup.py sdist bdist_wheel - - - name: Publish distribution 📦 to Test PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_TEST_TOKEN }} - repository_url: https://test.pypi.org/legacy/ + pip install -q build + python -m build - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index 14673a6..25c6683 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools"] +requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" [project] @@ -52,15 +52,9 @@ stylelint = "statick_tool.plugins.tool.stylelint:StylelintToolPlugin" [project.optional-dependencies] test = [ "coverage", - "flake8-pep3101", - "flake8<5", # Pin until https://github.com/tholo/pytest-flake8/issues/87 is fixed. "mock", - "mypy", - "pycodestyle<2.9.0", # Pin until https://github.com/tholo/pytest-flake8/issues/87 is fixed. - "pydocstyle", "pytest", "pytest-cov", - "setuptools", "statick", "statick-md", "tox", @@ -69,7 +63,6 @@ test = [ docs = [ "yaml-1.3", ] -dist = [ - "setuptools", - "wheel", -] + +[tool.isort] +profile = "black" diff --git a/tox.ini b/tox.ini index f99fc5f..f21c33c 100644 --- a/tox.ini +++ b/tox.ini @@ -15,8 +15,6 @@ python = [testenv] changedir = {toxinidir}/output-{envname} -passenv = CI -setenv = PY_IGNORE_IMPORTMISMATCH = 1 deps = .[test] commands = From 292aeb91a6e7155ccb87fc2bb70f17767c31f595 Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Tue, 10 Sep 2024 06:17:27 -0700 Subject: [PATCH 03/12] Update GitHub action versions. Use stdlib-plugins branch for statick dependency. Remove all __init__.py files as they collide with main statick files. --- .github/workflows/tests.yaml | 30 ++----------------- pyproject.toml | 5 ++-- src/statick_tool/__init__.py | 1 - src/statick_tool/plugins/__init__.py | 1 - .../plugins/discovery/__init__.py | 1 - src/statick_tool/plugins/tool/__init__.py | 1 - 6 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 src/statick_tool/__init__.py delete mode 100644 src/statick_tool/plugins/__init__.py delete mode 100644 src/statick_tool/plugins/discovery/__init__.py delete mode 100644 src/statick_tool/plugins/tool/__init__.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index b965857..f762b32 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -18,41 +18,17 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: '16' - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - uses: actions/cache@v3 - if: startsWith(runner.os, 'Linux') - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - uses: actions/cache@v3 - if: startsWith(runner.os, 'macOS') - with: - path: ~/Library/Caches/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - uses: actions/cache@v3 - if: startsWith(runner.os, 'Windows') - with: - path: ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/pyproject.toml b/pyproject.toml index 25c6683..222f97f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ dependencies = [ "importlib_metadata", - "statick", + "statick@git+https://github.com/tdenewiler/statick@stdlib-plugins", ] [tool.setuptools.package-data] @@ -55,8 +55,7 @@ test = [ "mock", "pytest", "pytest-cov", - "statick", - "statick-md", + "statick-md@git+https://github.com/tdenewiler/statick-md@stdlib-plugins", "tox", "tox-gh-actions", ] diff --git a/src/statick_tool/__init__.py b/src/statick_tool/__init__.py deleted file mode 100644 index 5da5b0e..0000000 --- a/src/statick_tool/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Statick tool.""" diff --git a/src/statick_tool/plugins/__init__.py b/src/statick_tool/plugins/__init__.py deleted file mode 100644 index 9a6d2e7..0000000 --- a/src/statick_tool/plugins/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Web plugins for Statick.""" diff --git a/src/statick_tool/plugins/discovery/__init__.py b/src/statick_tool/plugins/discovery/__init__.py deleted file mode 100644 index 9cef358..0000000 --- a/src/statick_tool/plugins/discovery/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Web file discovery plugins.""" diff --git a/src/statick_tool/plugins/tool/__init__.py b/src/statick_tool/plugins/tool/__init__.py deleted file mode 100644 index a4744d1..0000000 --- a/src/statick_tool/plugins/tool/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Web tool plugins.""" From 929e5f3cd856a56fd14ee86866c513ca2fa27ebe Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Tue, 10 Sep 2024 06:21:39 -0700 Subject: [PATCH 04/12] Simplify dependency installation in workflow. --- .github/workflows/tests.yaml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f762b32..34950dd 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -31,17 +31,10 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip - python -m pip install --upgrade setuptools - python -m pip install --upgrade wheel - python -m pip install --upgrade coverage - python -m pip install --upgrade mypy - python -m pip install --upgrade statick - python -m pip install --upgrade statick-md - python -m pip install --upgrade tox - python -m pip install --upgrade tox-gh-actions - python -m pip install --upgrade virtualenv - python -m pip install -r requirements.txt + pip install --upgrade pip + pip install . + pip install .[test] + pip install .[docs] # Have to install newer version from non-apt source due to SSL library compatibility issues. - name: Install tools (Linux) From 0c92831844da341b86cac8b879788fabbd40727d Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Mon, 14 Oct 2024 20:48:05 -0700 Subject: [PATCH 05/12] Drop Python 3.8, add Python 3.13. --- .github/workflows/tests.yaml | 10 +++++----- pyproject.toml | 4 ++-- tox.ini | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 34950dd..9aea8e4 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -14,8 +14,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, ubuntu-20.04, ubuntu-22.04, windows-latest] - python-version: ['3.8', '3.9', '3.10', '3.11'] + os: [macos-latest, ubuntu-22.04, ubuntu-24.04, windows-latest] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v4 @@ -38,7 +38,7 @@ jobs: # Have to install newer version from non-apt source due to SSL library compatibility issues. - name: Install tools (Linux) - if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' + if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' run: | npm install -g eslint # eslint plugins and configs should be installed locally @@ -71,12 +71,12 @@ jobs: fail_ci_if_error: false - name: Statick Documentation - if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' + if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' run: | statick . --check --profile documentation.yaml - name: Self check - if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' + if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' run: | mkdir statick-output statick . --output-directory statick-output --check --profile self_check.yaml diff --git a/pyproject.toml b/pyproject.toml index 222f97f..c0e3dfe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,16 +8,16 @@ authors = [{name = "NIWC Pacific"}] description="Statick analysis plugins for Web (css, html, js) files." version = "0.1.3" readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.9" license = {text = "CC0-1.0"} classifiers = [ "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Software Development :: Quality Assurance", "Topic :: Software Development :: Testing", "Typing :: Typed", diff --git a/tox.ini b/tox.ini index f21c33c..14ff8b9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py38, py39, py310, py311, py312 +envlist = py39, py310, py311, py312, py313 skip_missing_interpreters = true [pytest] @@ -7,11 +7,11 @@ norecursedirs = .tox build [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 3.11: py311 3.12: py312 + 3.13: py313 [testenv] changedir = {toxinidir}/output-{envname} From ce139f74ed3d4ddd4a2a1adf90e0095d840c08da Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Mon, 14 Oct 2024 21:11:51 -0700 Subject: [PATCH 06/12] Add ubuntu-20.04. --- .github/workflows/tests.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 9aea8e4..15a2955 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, ubuntu-22.04, ubuntu-24.04, windows-latest] + os: [macos-latest, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, windows-latest] python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] steps: @@ -38,7 +38,7 @@ jobs: # Have to install newer version from non-apt source due to SSL library compatibility issues. - name: Install tools (Linux) - if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' + if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' run: | npm install -g eslint # eslint plugins and configs should be installed locally @@ -71,12 +71,12 @@ jobs: fail_ci_if_error: false - name: Statick Documentation - if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' + if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' run: | statick . --check --profile documentation.yaml - name: Self check - if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' + if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' run: | mkdir statick-output statick . --output-directory statick-output --check --profile self_check.yaml From 5f81842fbad24061ffd175d73bf9938d3610b45f Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Fri, 3 Jan 2025 12:22:46 -0800 Subject: [PATCH 07/12] Simplify pip install command. --- .github/workflows/tests.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f1819d3..67f07d6 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -32,9 +32,7 @@ jobs: - name: Install dependencies run: | pip install --upgrade pip - pip install . - pip install .[test] - pip install .[docs] + pip install .[docs,test] # Have to install newer version from non-apt source due to SSL library compatibility issues. - name: Install tools (Linux) From 2dabfce8918a57f0fbdef1ad79d9f965bfd05547 Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Sat, 4 Jan 2025 15:44:20 -0800 Subject: [PATCH 08/12] Add codecov configuration file. Ignore unit test line coverage. --- .codecov.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .codecov.yml diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..4aa137b --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,7 @@ +coverage: + status: + project: + default: + target: 0% + threshold: null + From ab0b699892589772d87a30fae6030b68812f0b8c Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Sat, 4 Jan 2025 15:51:19 -0800 Subject: [PATCH 09/12] Update .codecov.yml to remove extra empty line. --- .codecov.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.codecov.yml b/.codecov.yml index 4aa137b..dc436e9 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -4,4 +4,3 @@ coverage: default: target: 0% threshold: null - From 497d163e1c4fdfe44fbea5e46329856533d55bee Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Mon, 6 Jan 2025 08:35:41 -0800 Subject: [PATCH 10/12] Use runner.os to simplify Linux-specific action steps. --- .github/workflows/tests.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 67f07d6..eb7c9fa 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -36,7 +36,7 @@ jobs: # Have to install newer version from non-apt source due to SSL library compatibility issues. - name: Install tools (Linux) - if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' + if: runner.os == 'Linux' run: | npm install -g eslint # eslint plugins and configs should be installed locally @@ -62,7 +62,7 @@ jobs: mypy --ignore-missing-imports --strict src/ - name: Tox - if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' + if: runner.os == 'Linux' run: | npm list npm list --prefix $HOME/.node_modules @@ -75,12 +75,12 @@ jobs: fail_ci_if_error: false - name: Statick Documentation - if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' + if: runner.os == 'Linux' run: | statick . --check --profile documentation.yaml - name: Self check - if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' + if: runner.os == 'Linux' run: | mkdir statick-output statick . --output-directory statick-output --check --profile self_check.yaml From a88c1859f023bb93a5db52483d34f4bf12e4b038 Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Thu, 9 Jan 2025 07:24:58 -0800 Subject: [PATCH 11/12] Update changelog. --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index beb7587..5e8e665 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## Unreleased +### Added + +- Support for Python 3.12 and 3.13. +- Use of `pyproject.toml` instead of `setup.py` and `requirements.txt`. +- Supports new plugin discovery mechanism for the main Statick tool. + - Switched from yapsy to setuptools for plugin mechanism. (sscpac/statick#508) + +### Changed + +- Disabled code coverage requirements in CI for now. + - Unable to get line coverage working with new plugin mechanism. + Unit tests still work to find problems. +- Rename plugin modules so they are shorter and less redundant. + +### Removed + +- No longer support Python 3.8. + ## v0.2.0 - 2025-01-03 ### Changed From 85a4eea7bd4dae55ac5b03199cd4d6621bb3ef68 Mon Sep 17 00:00:00 2001 From: Thomas Denewiler Date: Mon, 20 Jan 2025 13:51:02 -0800 Subject: [PATCH 12/12] Use latest statick release as dependency. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7e836f6..57fb93f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ dependencies = [ "importlib_metadata", - "statick@git+https://github.com/tdenewiler/statick@stdlib-plugins", + "statick", ] [tool.setuptools.package-data]