Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imports, workflows, and coverage #139

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Release

on:
push:
# release on tag push
tags:
- '*'

jobs:
wheels:

runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
env:
PYTHONIOENCODING: utf-8
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, '3.10']

steps:
- name: Set git crlf/eol
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install tox tox-gh-actions

- name: Build dist pkgs
run: |
tox -e build

- name: Upload artifacts
if: matrix.python-version == 3.8 && runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: wheels
path: |
./dist/*.whl
./dist/*.tar.gz

create_release:
name: Create Release
needs: [wheels]
runs-on: ubuntu-20.04

steps:
- name: Get version
id: get_version
run: |
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo ${{ env.VERSION }}

- uses: actions/checkout@v3
with:
fetch-depth: 0

# download all artifacts to project dir
- uses: actions/download-artifact@v3

- name: Generate changes file
uses: sarnold/gitchangelog-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN}}

- name: Create release
id: create_release
uses: softprops/action-gh-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
name: Release v${{ env.VERSION }}
body_path: CHANGES.md
draft: false
prerelease: false
files: |
wheels/tft*.whl
wheels/tft*.tar.gz

docs:
name: Release docs
needs: [create_release]
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Add python requirements
run: |
python -m pip install --upgrade pip
pip install tox

- name: Build docs
run: |
tox -e docs-lint
tox -e docs

- uses: actions/upload-artifact@v3
with:
name: ApiDocsHTML
path: "doc/_build/html/"

- name: set nojekyll for github
run: |
sudo touch doc/_build/html/.nojekyll

# - name: Deploy docs to gh-pages
# if: ${{ github.event_name == 'push' }}
# uses: JamesIves/github-pages-deploy-action@v4
# with:
# folder: doc/_build/html/
87 changes: 50 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,59 @@
---
name: Test

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
workflow_dispatch:
pull_request:
branches:
- master
push:
branches: [ master ]

jobs:
test:
name: ${{ matrix.os }} / Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
build:

runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
PYTHONIOENCODING: utf-8
PIP_DOWNLOAD_CACHE: ${{ github.workspace }}/../.pip_download_cache
strategy:
fail-fast: false
matrix:
os: [Debian]
python-version: [3.6, 3.7, 3.8]

os: [ubuntu-20.04, macos-12]
python-version: [3.7, 3.9, '3.10', '3.11']
steps:
- uses: actions/checkout@master

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox

- name: Lint with tox
run: tox -e lint

- name: Test with tox
run: tox

- name: Run tox pkg
run: tox -e pkg

- name: Make docs
run: tox -e docs
- name: Set git crlf/eol
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions

- name: Lint with tox
run: tox -e lint

- name: Run tests
run: |
tox
env:
PLATFORM: ${{ matrix.os }}

- name: Build pkg
run: tox -e build

- name: Make docs
run: tox -e docs
12 changes: 10 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

import tftpy

if sys.version_info < (3, 10):
from importlib_metadata import version
else:
from importlib.metadata import version

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down Expand Up @@ -48,9 +53,12 @@
# built documents.
#
# The short X.Y version.
version = ".".join(tftpy.__version__.split(".")[:2])
#version = ".".join(tftpy.__version__.split(".")[:2])
# The full version, including alpha/beta/rc tags.
release = tftpy.__version__
#release = tftpy.__version__

release = version('tftpy')
version = '.'.join(release.split('.')[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
65 changes: 63 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,69 @@ build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-v -rxX --tb=long --color=yes --junitxml=build/results.xml --cov-report=xml --cov"
log_cli = false
doctest_optionflags = ["ELLIPSIS", "NORMALIZE_WHITESPACE",]
addopts = "--strict-markers -rxX --tb=long --color=yes"
markers = "subscript"
testpaths = [
"t/",
"t/test.py",
]

[tool.coverage.run]
branch = true
source = [
"tftpy/",
".tox/py*/lib/python*/site-packages/",
]
omit = [
"t/*",
".tox",
]

[tool.coverage.paths]
source = ["tftpy"]

[tool.coverage.report]
fail_under = 70
show_missing = true
exclude_lines = [
"pragma: no cover",
"raise NotImplementedError",
"raise AssertionError",
"if typing.TYPE_CHECKING:",
"if TYPE_CHECKING:",
]
omit = [
"t/*",
]

[tool.black]
line-length = 90
skip-string-normalization = true
include = '\.py$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| docs
| dist
| t
)/
'''

[tool.pycln]
all = true

[tool.isort]
line_length = 72
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def read_file(fname):
},
setup_requires=[
"setuptools_scm[toml]",
"setuptools_scm_git_archive >= 1.0",
"importlib_resources;python_version<'3.8'",
],
python_requires=">=3.6",
classifiers=[
Expand Down
File renamed without changes.
21 changes: 12 additions & 9 deletions tftpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,27 @@

import sys

import pkg_resources
from . import TftpContexts, TftpPacketFactory, TftpPacketTypes, TftpStates
from .TftpClient import TftpClient
from .TftpServer import TftpServer
from .TftpShared import *

if sys.version_info < (3, 8):
from importlib_metadata import version, PackageNotFoundError
else:
from importlib.metadata import version, PackageNotFoundError


# Make sure that this is at least Python 3
required_version = (3, 0)
if sys.version_info < required_version:
raise ImportError("Requires at least Python 3.0")

from . import TftpContexts, TftpPacketFactory, TftpPacketTypes, TftpStates
from . import __name__ as pkg_name
from .TftpClient import TftpClient
from .TftpServer import TftpServer
from .TftpShared import *


def _get_version():
try:
pkg_version = pkg_resources.get_distribution(pkg_name).version
except pkg_resources.DistributionNotFound:
pkg_version = version("tftpy")
except PackageNotFoundError:
pkg_version = None
return pkg_version

Expand Down
Loading