Skip to content
Merged
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
31 changes: 31 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# coverage.py setup
[run]
command_line = tests discover -s tests -t . --locals
branch = True
source = project_template
omit =
# Auto generated by witchver
project_template/version.py

[report]
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain about missing debug-only code:
def __repr__
if self\.debug

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError

# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:
except ImportError
ignore_errors = True
precision = 2
show_missing = True
fail_under = 100

66 changes: 66 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Coverage

on:
push:
branches:
- master
paths-ignore:
- "**.md"

jobs:
coverage:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [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 dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[test]
- name: Test
run: |
python -m coverage run &> testing.log
if python -m coverage json ; then
echo "COLOR=green" >> $GITHUB_ENV
else
echo "COLOR=red" >> $GITHUB_ENV
fi


CMD="import json; print(json.load(open('coverage.json'))['totals']['percent_covered_display'] + '%')"
echo "COVERAGE=$(python -c "$CMD")" >> $GITHUB_ENV

REF=${{ github.ref }}
echo "github.ref: $REF"
IFS='/' read -ra PATHS <<< "$REF"
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}"
echo $BRANCH_NAME
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV
- name: Upload test configuration
uses: actions/upload-artifact@v2
if: always()
with:
name: testing.${{ matrix.python-version }}
path: |
testing.log
test_log.json
coverage.json
.coverage
- name: Create badge
uses: schneegans/dynamic-badges-action@v1.0.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 36d9705addcd44fb0fccec1d23dc1338
filename: PythonProjectTemplate__${{ env.BRANCH }}.json
label: Test Coverage
message: ${{ env.COVERAGE }}
color: ${{ env.COLOR }}
namedLogo: Coverage
35 changes: 35 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Pylint

on:
push:
branches:
- master
paths-ignore:
- "**.md"
pull_request:
branches:
- master
paths-ignore:
- "**.md"

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: [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 dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pylint
- name: Lint
run: |
python -m pylint project_template tests tools setup.py
43 changes: 23 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python package test
name: Unit Test

on:
push:
Expand All @@ -13,28 +13,31 @@ on:
- "**.md"

jobs:
build:
test:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip')"
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.7", "3.8", "3.9", "3.10"]

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 dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pylint
python -m pip install .
- name: Lint
run: |
python -m pylint project_template/ tests tools setup.py
- name: Test
run: |
python setup.py test
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[test]
- name: Test
run: |
python -m coverage run &> testing.log
- name: Upload test configuration
uses: actions/upload-artifact@v2
if: always()
with:
name: testing.${{ matrix.python-version }}
path: |
testing.log
test_log.json
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# IDE files
*.vscode
*.code-workspace

# Build artifacts
Expand All @@ -10,4 +9,10 @@ build
.eggs
dist
*.c
version.py
version.py

# Test artifacts
.test
.coverage
coverage.json
test_log.json
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"ms-python.vscode-pylance",
"streetsidesoftware.code-spell-checker",
"ms-python.isort",
"ms-python.python"
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cSpell.words": [ ],
"python.formatting.provider": "yapf",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true
}
51 changes: 43 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,83 @@
# Project Title

[![Unit Test][unittest-image]][unittest-url] [![Pylint][pylint-image]][pylint-url] [![Coverage][coverage-image]][coverage-url]
Short description of project goes here.

----
---

## Environment

List of dependencies for package to run.

### Required
* List required installations

- List required installations

### Optional
* List optional installations
----

- List optional installations

---

## Installation / Build / Deployment

Install module

```bash
> python -m pip install .
```

For development, install as a link to repository such that code changes are used.

```bash
> python -m pip install -e .
```

Execute module

```bash
> python -m project_template
```
----

---

## Usage

Explain how to use your project.

```Python
Give example use cases
```
----

---

## Running Tests

Explain how to run the automated tests.

```bash
> python setup.py test
```
----

---

## Development

Code development of this project adheres to [Google Python Guide](https://google.github.io/styleguide/pyguide.html)

### Styling

Use `yapf` to format files, based on Google's guide with the exception of indents being 2 spaces.

---

## Versioning
Versioning of this projects adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and is implemented using git tags.

Versioning of this projects adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and is implemented using git tags.

[unittest-image]: https://github.com/WattsUp/PythonProjectTemplate/actions/workflows/test.yml/badge.svg
[unittest-url]: https://github.com/WattsUp/PythonProjectTemplate/actions/workflows/test.yml
[pylint-image]: https://github.com/WattsUp/PythonProjectTemplate/actions/workflows/lint.yml/badge.svg
[pylint-url]: https://github.com/WattsUp/PythonProjectTemplate/actions/workflows/lint.yml
[coverage-image]: https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/WattsUp/36d9705addcd44fb0fccec1d23dc1338/raw/PythonProjectTemplate__heads_master.json
[coverage-url]: https://github.com/WattsUp/PythonProjectTemplate/actions/workflows/coverage.yml
6 changes: 2 additions & 4 deletions project_template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
Template repository for jump starting Python projects.
"""

from . import version
from project_template.version import __version__

__version__ = version.version_full
from project_template import math

__all__ = ['math']

from . import math
2 changes: 0 additions & 2 deletions project_template/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
return outputs.
"""

from __future__ import annotations


def add_int(a: int, b: int) -> int:
"""Add two integers together
Expand Down
13 changes: 3 additions & 10 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ disable=abstract-method,
global-statement,
hex-method,
idiv-method,
implicit-str-concat-in-sequence,
implicit-str-concat,
import-error,
import-self,
import-star-module-level,
Expand All @@ -89,7 +89,6 @@ disable=abstract-method,
long-suffix,
map-builtin-not-iterating,
misplaced-comparison-constant,
missing-function-docstring,
metaclass-assignment,
next-method-called,
next-method-defined,
Expand Down Expand Up @@ -214,7 +213,7 @@ inlinevar-rgx=^[a-z][a-z0-9_]*$
class-rgx=^_?[A-Z][a-zA-Z0-9]*$

# Regular expression matching correct module names
module-rgx=^(_?[a-z][a-z0-9_]*|__init__)$
module-rgx=^(_?[a-z][a-z0-9_]*|__init__|__main__)$

# Regular expression matching correct method names
method-rgx=(?x)^(?:(?P<exempt>_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase|tearDownTestCase|setupSelf|tearDownClass|setUpClass|(test|assert)_*[A-Z0-9][a-zA-Z0-9_]*|next)|(?P<camel_case>_{0,2}[A-Z][a-zA-Z0-9_]*)|(?P<snake_case>_{0,2}[a-z][a-z0-9_]*))$
Expand All @@ -225,7 +224,7 @@ no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test)$

# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=10
docstring-min-length=0


[TYPECHECK]
Expand Down Expand Up @@ -273,12 +272,6 @@ ignore-long-lines=(?x)(
# else.
single-line-if-stmt=yes

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=

# Maximum number of lines in a module
max-module-lines=99999

Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[build-system]
requires = ["setuptools", "wheel"]
requires = [
"setuptools",
"wheel",
"witch-ver"
]
Loading