mirror of
				https://github.com/craigerl/aprsd.git
				synced 2025-11-03 21:20:23 -05:00 
			
		
		
		
	Added pre-commit hooks
This patch adds pre-commit hook support to ensure code passes basic checks prior to allowing a commit.
This commit is contained in:
		
							parent
							
								
									8bd8b95b35
								
							
						
					
					
						commit
						75f610d971
					
				
							
								
								
									
										18
									
								
								.pre-commit-config.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								.pre-commit-config.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					repos:
 | 
				
			||||||
 | 
					-   repo: https://github.com/pre-commit/pre-commit-hooks
 | 
				
			||||||
 | 
					    rev: v3.2.0
 | 
				
			||||||
 | 
					    hooks:
 | 
				
			||||||
 | 
					    -   id: trailing-whitespace
 | 
				
			||||||
 | 
					    -   id: end-of-file-fixer
 | 
				
			||||||
 | 
					    -   id: check-yaml
 | 
				
			||||||
 | 
					    -   id: check-added-large-files
 | 
				
			||||||
 | 
					-   repo: https://github.com/psf/black
 | 
				
			||||||
 | 
					    rev: 19.3b0
 | 
				
			||||||
 | 
					    hooks:
 | 
				
			||||||
 | 
					    -   id: black
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-   repo: https://gitlab.com/pycqa/flake8
 | 
				
			||||||
 | 
					    rev: 3.8.1
 | 
				
			||||||
 | 
					    hooks:
 | 
				
			||||||
 | 
					      - id: flake8
 | 
				
			||||||
 | 
					        additional_dependencies: [flake8-bugbear]
 | 
				
			||||||
@ -4,6 +4,8 @@ CHANGES
 | 
				
			|||||||
v1.5.0
 | 
					v1.5.0
 | 
				
			||||||
------
 | 
					------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* Added pre-commit hooks
 | 
				
			||||||
 | 
					* Update Changelog for v1.5.0
 | 
				
			||||||
* Added QueryPlugin resend all delayed msgs or Flush
 | 
					* Added QueryPlugin resend all delayed msgs or Flush
 | 
				
			||||||
* Added QueryPlugin
 | 
					* Added QueryPlugin
 | 
				
			||||||
* Added support to save/load MsgTrack on exit/start
 | 
					* Added support to save/load MsgTrack on exit/start
 | 
				
			||||||
 | 
				
			|||||||
@ -414,4 +414,3 @@ Provide a csv list of pypi installable plugins.  Then make sure the plugin
 | 
				
			|||||||
python file is in your /plugins volume and the plugin will be installed at
 | 
					python file is in your /plugins volume and the plugin will be installed at
 | 
				
			||||||
container startup.  The plugin may have dependencies that are required.
 | 
					container startup.  The plugin may have dependencies that are required.
 | 
				
			||||||
The plugin file should be copied to /plugins for loading by aprsd
 | 
					The plugin file should be copied to /plugins for loading by aprsd
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -383,10 +383,7 @@ def server(loglevel, quiet, disable_validation, config_file, flush):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    rx_msg_queue = queue.Queue(maxsize=20)
 | 
					    rx_msg_queue = queue.Queue(maxsize=20)
 | 
				
			||||||
    tx_msg_queue = queue.Queue(maxsize=20)
 | 
					    tx_msg_queue = queue.Queue(maxsize=20)
 | 
				
			||||||
    msg_queues = {
 | 
					    msg_queues = {"rx": rx_msg_queue, "tx": tx_msg_queue}
 | 
				
			||||||
        "rx": rx_msg_queue,
 | 
					 | 
				
			||||||
        "tx": tx_msg_queue,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    rx_thread = threads.APRSDRXThread(msg_queues=msg_queues, config=config)
 | 
					    rx_thread = threads.APRSDRXThread(msg_queues=msg_queues, config=config)
 | 
				
			||||||
    tx_thread = threads.APRSDTXThread(msg_queues=msg_queues, config=config)
 | 
					    tx_thread = threads.APRSDTXThread(msg_queues=msg_queues, config=config)
 | 
				
			||||||
 | 
				
			|||||||
@ -217,10 +217,7 @@ class TextMessage(Message):
 | 
				
			|||||||
    def __repr__(self):
 | 
					    def __repr__(self):
 | 
				
			||||||
        """Build raw string to send over the air."""
 | 
					        """Build raw string to send over the air."""
 | 
				
			||||||
        return "{}>APRS::{}:{}{{{}\n".format(
 | 
					        return "{}>APRS::{}:{}{{{}\n".format(
 | 
				
			||||||
            self.fromcall,
 | 
					            self.fromcall, self.tocall.ljust(9), self._filter_for_send(), str(self.id)
 | 
				
			||||||
            self.tocall.ljust(9),
 | 
					 | 
				
			||||||
            self._filter_for_send(),
 | 
					 | 
				
			||||||
            str(self.id),
 | 
					 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
 | 
				
			|||||||
@ -70,7 +70,7 @@ class PluginManager(object):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        self.obj_list = []
 | 
					        self.obj_list = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for path, subdirs, files in os.walk(dir_path):
 | 
					        for path, _subdirs, files in os.walk(dir_path):
 | 
				
			||||||
            for name in files:
 | 
					            for name in files:
 | 
				
			||||||
                if fnmatch.fnmatch(name, pattern):
 | 
					                if fnmatch.fnmatch(name, pattern):
 | 
				
			||||||
                    LOG.debug("MODULE? '{}' '{}'".format(name, path))
 | 
					                    LOG.debug("MODULE? '{}' '{}'".format(name, path))
 | 
				
			||||||
 | 
				
			|||||||
@ -2,8 +2,6 @@
 | 
				
			|||||||
import sys
 | 
					import sys
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pytest
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
from aprsd import email
 | 
					from aprsd import email
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if sys.version_info >= (3, 2):
 | 
					if sys.version_info >= (3, 2):
 | 
				
			||||||
@ -12,7 +10,7 @@ else:
 | 
				
			|||||||
    import mock
 | 
					    import mock
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class testMain(unittest.TestCase):
 | 
					class TestMain(unittest.TestCase):
 | 
				
			||||||
    @mock.patch("aprsd.email._imap_connect")
 | 
					    @mock.patch("aprsd.email._imap_connect")
 | 
				
			||||||
    @mock.patch("aprsd.email._smtp_connect")
 | 
					    @mock.patch("aprsd.email._smtp_connect")
 | 
				
			||||||
    def test_validate_email(self, imap_mock, smtp_mock):
 | 
					    def test_validate_email(self, imap_mock, smtp_mock):
 | 
				
			||||||
 | 
				
			|||||||
@ -1,16 +1,13 @@
 | 
				
			|||||||
# -*- coding: utf-8 -*-
 | 
					# -*- coding: utf-8 -*-
 | 
				
			||||||
import sys
 | 
					 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
from unittest import mock
 | 
					from unittest import mock
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pytest
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import aprsd
 | 
					import aprsd
 | 
				
			||||||
from aprsd import plugin
 | 
					from aprsd import plugin
 | 
				
			||||||
from aprsd.fuzzyclock import fuzzy
 | 
					from aprsd.fuzzyclock import fuzzy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class testPlugin(unittest.TestCase):
 | 
					class TestPlugin(unittest.TestCase):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        self.fromcall = "KFART"
 | 
					        self.fromcall = "KFART"
 | 
				
			||||||
        self.ack = 1
 | 
					        self.ack = 1
 | 
				
			||||||
@ -41,11 +38,11 @@ class testPlugin(unittest.TestCase):
 | 
				
			|||||||
        self.assertEqual(expected, actual)
 | 
					        self.assertEqual(expected, actual)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @mock.patch("time.localtime")
 | 
					    @mock.patch("time.localtime")
 | 
				
			||||||
    def test_Time(self, mock_time):
 | 
					    def test_time(self, mock_time):
 | 
				
			||||||
        fake_time = mock.MagicMock()
 | 
					        fake_time = mock.MagicMock()
 | 
				
			||||||
        h = fake_time.tm_hour = 16
 | 
					        h = fake_time.tm_hour = 16
 | 
				
			||||||
        m = fake_time.tm_min = 12
 | 
					        m = fake_time.tm_min = 12
 | 
				
			||||||
        s = fake_time.tm_sec = 55
 | 
					        fake_time.tm_sec = 55
 | 
				
			||||||
        mock_time.return_value = fake_time
 | 
					        mock_time.return_value = fake_time
 | 
				
			||||||
        time_plugin = plugin.TimePlugin(self.config)
 | 
					        time_plugin = plugin.TimePlugin(self.config)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -66,7 +63,7 @@ class testPlugin(unittest.TestCase):
 | 
				
			|||||||
        self.assertEqual(expected, actual)
 | 
					        self.assertEqual(expected, actual)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @mock.patch("time.localtime")
 | 
					    @mock.patch("time.localtime")
 | 
				
			||||||
    def test_Ping(self, mock_time):
 | 
					    def test_ping(self, mock_time):
 | 
				
			||||||
        fake_time = mock.MagicMock()
 | 
					        fake_time = mock.MagicMock()
 | 
				
			||||||
        h = fake_time.tm_hour = 16
 | 
					        h = fake_time.tm_hour = 16
 | 
				
			||||||
        m = fake_time.tm_min = 12
 | 
					        m = fake_time.tm_min = 12
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								tox.ini
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								tox.ini
									
									
									
									
									
								
							@ -28,7 +28,7 @@ commands = sphinx-build -b html docs/source docs/html
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[testenv:pep8]
 | 
					[testenv:pep8]
 | 
				
			||||||
commands =
 | 
					commands =
 | 
				
			||||||
  flake8 {posargs} aprsd
 | 
					  flake8 {posargs} aprsd tests
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[testenv:fast8]
 | 
					[testenv:fast8]
 | 
				
			||||||
basepython = python3
 | 
					basepython = python3
 | 
				
			||||||
@ -43,7 +43,7 @@ skip_install = true
 | 
				
			|||||||
deps =
 | 
					deps =
 | 
				
			||||||
    -r{toxinidir}/dev-requirements.txt
 | 
					    -r{toxinidir}/dev-requirements.txt
 | 
				
			||||||
commands =
 | 
					commands =
 | 
				
			||||||
    flake8 aprsd
 | 
					    flake8 aprsd tests
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[flake8]
 | 
					[flake8]
 | 
				
			||||||
max-line-length = 99
 | 
					max-line-length = 99
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user