Skip to content

Commit

Permalink
rewrite for new pytak
Browse files Browse the repository at this point in the history
  • Loading branch information
ampledata committed Jun 9, 2022
1 parent a588542 commit 43de2c6
Show file tree
Hide file tree
Showing 13 changed files with 329 additions and 352 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ jobs:
- name: Build Debian/Apt bdist_deb
run: |
export REPO_NAME=$(echo ${github.repository} | awk -F"/" '{print $2}')
python3 setup.py --command-packages=stdeb.command bdist_deb
ls -al deb_dist/
cp deb_dist/python3-aprscot_*_all.deb deb_dist/python3-aprscot_latest_all.deb
cp deb_dist/python3-${REPO_NAME}_*_all.deb deb_dist/python3-${REPO_NAME}_latest_all.deb
- uses: actions/upload-artifact@master
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Publish package to PyPI

name: Publish package to PYPI

on: push
on:
push:
tags:
- '*'

jobs:
deploy:
Expand All @@ -12,23 +13,18 @@ jobs:

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
python3 -m pip install --upgrade pip
python3 -m pip install setuptools wheel twine
- name: Build
run: |
python setup.py sdist bdist_wheel
python3 setup.py sdist bdist_wheel
- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
Expand Down
66 changes: 0 additions & 66 deletions .github/workflows/python-test.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/python-test_and_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint & Test Code

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install test requirements
run: |
make install_test_requirements
- name: Install package itself (editable)
run: |
make editable
- name: Lint with pylint
run: |
make pylint
- name: Lint with flake8
run: |
make flake8
- name: Test with pytest-cov
run: |
make test_cov
90 changes: 46 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,76 +1,78 @@
# Makefile for Python APRS Cursor-on-Target Gateway.
#
# Source:: https://github.com/ampledata/aprscot
# Copyright 2022 Greg Albrecht <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author:: Greg Albrecht W2GMD <[email protected]>
# Copyright:: Copyright 2022 Greg Albrecht
# License:: Apache License, Version 2.0
#


this_app = aprscot
.DEFAULT_GOAL := all

all: editable

all: develop

install_requirements:
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
develop:
python3 setup.py develop

install_requirements_test:
pip install -r requirements_test.txt
editable:
python3 -m pip install -e .

develop:
pip install -e .
install_test_requirements:
python3 -m pip install -r requirements_test.txt

install:
python setup.py install
python3 setup.py install

uninstall:
pip uninstall -y aprscot
python3 -m pip uninstall -y $(this_app)

reinstall: uninstall install

remember_test:
@echo
@echo "Hello from the Makefile..."
@echo "Don't forget to run: 'make install_requirements_test'"
@echo
publish:
python3 setup.py publish

clean:
@rm -rf *.egg* build dist *.py[oc] */*.py[co] cover doctest_pypi.cfg \
nosetests.xml pylint.log output.xml flake8.log tests.log \
test-result.xml htmlcov fab.log .coverage */__pycache__/

# Publishing:
test-result.xml htmlcov fab.log .coverage __pycache__ \
*/__pycache__

build: remember_test
python3 -m build --sdist --wheel

twine_check: remember_test build
twine check dist/*

upload: remember_test build
twine upload dist/*

publish: build twine_check upload

# Tests:

pep8: remember_test
# flake8 --max-complexity 12 --exit-zero *.py */*.py
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
pep8:
flake8 --max-line-length=88 --extend-ignore=E203 --exit-zero $(this_app)/*.py

flake8: pep8

lint: remember_test
lint:
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
-r n *.py */*.py || exit 0
--max-line-length=88 -r n $(this_app)/*.py || exit 0

pylint: lint

pytest: remember_test
checkmetadata:
python3 setup.py check -s --restructuredtext

mypy:
mypy --strict .

pytest:
pytest

test: lint pep8 pytest
test: editable install_test_requirements pytest

test_cov:
pytest --cov=$(this_app)

black:
black .
39 changes: 28 additions & 11 deletions aprscot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# APRS Cursor-on-Target Gateway.
#
# Copyright 2022 Greg Albrecht <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author:: Greg Albrecht W2GMD <[email protected]>
#

"""
APRS Cursor-on-Target Gateway.
~~~~
:author: Greg Albrecht W2GMD <[email protected]>
:copyright: Copyright 2022 Greg Albrecht
:license: Apache License, Version 2.0
:source: <https://github.com/ampledata/aprscot>
"""

from .constants import (LOG_FORMAT, LOG_LEVEL, DEFAULT_APRSIS_PORT, # NOQA
DEFAULT_COT_TYPE, DEFAULT_COT_STALE,
DEFAULT_APRSIS_HOST, DEFAULT_APRSIS_CALLSIGN,
DEFAULT_APRSIS_FILTER)

from .functions import aprs_to_cot # NOQA
from .constants import ( # NOQA
LOG_FORMAT,
LOG_LEVEL,
DEFAULT_APRSIS_PORT,
DEFAULT_COT_TYPE,
DEFAULT_COT_STALE,
DEFAULT_APRSIS_HOST,
DEFAULT_APRSIS_CALLSIGN,
DEFAULT_APRSIS_FILTER,
)

from .functions import aprs_to_cot, create_tasks # NOQA

from .classes import APRSWorker # NOQA

Expand Down
Loading

0 comments on commit 43de2c6

Please sign in to comment.