Skip to content

Commit f77f59d

Browse files
Initial commit
0 parents  commit f77f59d

35 files changed

+1647
-0
lines changed

.coveragerc

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Configuration for python coverage package
2+
[run]
3+
branch = True
4+
omit =
5+
*/tests/*,
6+
.venv/*,
7+
.idea/*,
8+
setup*,
9+
.eggs/*
10+
.tox/*,
11+
build/*,
12+
dist/*,
13+
version.py
14+
15+
[report]
16+
# include = src/*
17+
include = be_upy_blink/*
18+
# Regexes for lines to exclude from consideration
19+
20+
ignore_errors = True
21+
22+
[html]
23+
directory = reports/coverage/html
24+
skip_empty = True
25+
26+
[xml]
27+
output = reports/coverage/coverage.xml
28+
29+
[json]
30+
output = reports/coverage/coverage.json
31+
pretty_print = True
32+
show_contexts = True

.editorconfig

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
charset = utf-8
9+
end_of_line = lf
10+
indent_style = space
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
# 4 space indentation
15+
[*.py]
16+
indent_size = 4
17+
18+
[*.yml]
19+
indent_size = 2
20+
21+
[*.{md,rst}]
22+
indent_size = 4
23+
trim_trailing_whitespace = false

.flake8

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Configuration for flake8 analysis
2+
[flake8]
3+
# Set the maximum length that any line (with some exceptions) may be.
4+
# max-line-length = 120
5+
6+
# Set the maximum length that a comment or docstring line may be.
7+
# max-doc-length = 120
8+
9+
# Set the maximum allowed McCabe complexity value for a block of code.
10+
# max-complexity = 15
11+
12+
# Specify a list of codes to ignore.
13+
# D107: Missing docstring in __init__
14+
# D400: First line should end with a period
15+
# W504: line break after binary operator -> Cannot break line with a long pathlib Path
16+
# D204: 1 blank line required after class docstring
17+
ignore = D107, D400, W504, D204
18+
19+
# Specify a list of mappings of files and the codes that should be ignored for the entirety of the file.
20+
per-file-ignores =
21+
tests/*:D101,D102,D104
22+
23+
# Provide a comma-separated list of glob patterns to exclude from checks.
24+
exclude =
25+
# No need to traverse our git directory
26+
.git,
27+
# Python virtual environments
28+
.venv,
29+
# tox virtual environments
30+
.tox,
31+
# There's no value in checking cache directories
32+
__pycache__,
33+
# The conf file is mostly autogenerated, ignore it
34+
docs/conf.py,
35+
# This contains our built documentation
36+
build,
37+
# This contains builds that we don't want to check
38+
dist,
39+
# We don't use __init__.py for scripts
40+
__init__.py
41+
# example testing folder before going live
42+
thinking
43+
.idea
44+
# custom scripts, not being part of the distribution
45+
libs_external
46+
sdist_upip.py
47+
setup.py
48+
update_version.py
49+
50+
# Provide a comma-separated list of glob patterns to add to the list of excluded ones.
51+
# extend-exclude =
52+
# legacy/,
53+
# vendor/
54+
55+
# Provide a comma-separate list of glob patterns to include for checks.
56+
# filename =
57+
# example.py,
58+
# another-example*.py
59+
60+
# Enable PyFlakes syntax checking of doctests in docstrings.
61+
doctests = False
62+
63+
# Specify which files are checked by PyFlakes for doctest syntax.
64+
# include-in-doctest =
65+
# dir/subdir/file.py,
66+
# dir/other/file.py
67+
68+
# Specify which files are not to be checked by PyFlakes for doctest syntax.
69+
# exclude-from-doctest =
70+
# tests/*
71+
72+
# Enable off-by-default extensions.
73+
# enable-extensions =
74+
# H111,
75+
# G123
76+
77+
# If True, report all errors, even if it is on the same line as a # NOQA comment.
78+
disable-noqa = False
79+
80+
# Specify the number of subprocesses that Flake8 will use to run checks in parallel.
81+
jobs = auto
82+
83+
# Also print output to stdout if output-file has been configured.
84+
tee = True
85+
86+
# Count the number of occurrences of each error/warning code and print a report.
87+
statistics = True
88+
89+
# Print the total number of errors.
90+
count = True
91+
92+
# Print the source code generating the error/warning in question.
93+
show-source = True
94+
95+
# Decrease the verbosity of Flake8’s output. Each time you specify it, it will print less and less information.
96+
quiet = 0
97+
98+
# Select the formatter used to display errors to the user.
99+
format = pylint
100+
101+
[pydocstyle]
102+
# choose the basic list of checked errors by specifying an existing convention. Possible conventions: pep257, numpy, google.
103+
convention = pep257
104+
105+
# check only files that exactly match <pattern> regular expression
106+
# match = (?!test_).*\.py
107+
108+
# search only dirs that exactly match <pattern> regular expression
109+
# match_dir = [^\.].*
110+
111+
# ignore any functions or methods that are decorated by a function with a name fitting the <decorators> regular expression.
112+
# ignore_decorators =

.github/workflows/release.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
3+
# this file is *not* meant to cover or endorse the use of GitHub Actions, but
4+
# rather to help make automated releases for this project
5+
6+
name: Upload Python Package
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
- name: Set up Python
23+
uses: actions/setup-python@v3
24+
with:
25+
python-version: '3.9'
26+
- name: Install build dependencies
27+
run: |
28+
if [ -f requirements-deploy.txt ]; then pip install -r requirements-deploy.txt; fi
29+
- name: Build package
30+
run: |
31+
changelog2version \
32+
--changelog_file changelog.md \
33+
--version_file be_upy_blink/version.py \
34+
--version_file_type py \
35+
--debug
36+
python setup.py sdist
37+
rm dist/*.orig
38+
# sdist call create non conform twine files *.orig, remove them
39+
- name: Publish package
40+
uses: pypa/gh-action-pypi-publish@release/v1.5
41+
with:
42+
password: ${{ secrets.PYPI_API_TOKEN }}
43+
skip_existing: true
44+
verbose: true
45+
print_hash: true
46+
- name: 'Create changelog based release'
47+
uses: brainelectronics/changelog-based-release@v1
48+
with:
49+
# note you'll typically need to create a personal access token
50+
# with permissions to create releases in the other repo
51+
# or you set the "contents" permissions to "write" as in this example
52+
changelog-path: changelog.md
53+
tag-name-prefix: ''
54+
tag-name-extension: ''
55+
release-name-prefix: ''
56+
release-name-extension: ''
57+
draft-release: true
58+
prerelease: false

.github/workflows/test-release.yaml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
3+
# this file is *not* meant to cover or endorse the use of GitHub Actions, but
4+
# rather to help make automated test releases for this project
5+
6+
name: Upload Python Package to test.pypi.org
7+
8+
on: [pull_request]
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
test-deploy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
- name: Set up Python
20+
uses: actions/setup-python@v3
21+
with:
22+
python-version: '3.9'
23+
- name: Install build dependencies
24+
run: |
25+
if [ -f requirements-deploy.txt ]; then pip install -r requirements-deploy.txt; fi
26+
- name: Build package
27+
run: |
28+
changelog2version \
29+
--changelog_file changelog.md \
30+
--version_file be_upy_blink/version.py \
31+
--version_file_type py \
32+
--additional_version_info="-rc${{ github.run_number }}.dev${{ github.event.number }}" \
33+
--debug
34+
python setup.py sdist
35+
- name: Test built package
36+
# sdist call creates non twine conform "*.orig" files, remove them
37+
run: |
38+
rm dist/*.orig
39+
twine check dist/*.tar.gz
40+
- name: Archive build package artifact
41+
uses: actions/upload-artifact@v3
42+
with:
43+
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
44+
# ${{ github.repository }} and ${{ github.ref_name }} can't be used
45+
# for artifact name due to unallowed '/'
46+
name: dist_repo.${{ github.event.repository.name }}_sha.${{ github.sha }}_build.${{ github.run_number }}
47+
path: dist/*.tar.gz
48+
retention-days: 14
49+
- name: Publish package
50+
uses: pypa/gh-action-pypi-publish@release/v1.5
51+
with:
52+
repository_url: https://test.pypi.org/legacy/
53+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
54+
skip_existing: true
55+
verbose: true
56+
print_hash: true
57+
- name: 'Create changelog based prerelease'
58+
uses: brainelectronics/changelog-based-release@v1
59+
with:
60+
# note you'll typically need to create a personal access token
61+
# with permissions to create releases in the other repo
62+
# or you set the "contents" permissions to "write" as in this example
63+
changelog-path: changelog.md
64+
tag-name-prefix: ''
65+
tag-name-extension: '-rc${{ github.run_number }}.dev${{ github.event.number }}'
66+
release-name-prefix: ''
67+
release-name-extension: '-rc${{ github.run_number }}.dev${{ github.event.number }}'
68+
draft-release: true
69+
prerelease: true

.github/workflows/test.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
3+
# This workflow will install Python dependencies, run tests and lint with a
4+
# specific Python version
5+
# For more information see:
6+
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
7+
8+
name: Test Python package
9+
10+
on:
11+
push:
12+
# branches: [ $default-branch ]
13+
branches-ignore:
14+
- 'main'
15+
- 'develop'
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
- name: Set up Python
27+
uses: actions/setup-python@v3
28+
with:
29+
python-version: '3.9'
30+
- name: Install test dependencies
31+
run: |
32+
pip install -r requirements-test.txt
33+
- name: Lint with flake8
34+
run: |
35+
flake8 .
36+
- name: Lint with yamllint
37+
run: |
38+
yamllint .
39+
- name: Install deploy dependencies
40+
run: |
41+
python -m pip install --upgrade pip
42+
if [ -f requirements-deploy.txt ]; then pip install -r requirements-deploy.txt; fi
43+
- name: Build package
44+
run: |
45+
changelog2version \
46+
--changelog_file changelog.md \
47+
--version_file be_upy_blink/version.py \
48+
--version_file_type py \
49+
--debug
50+
python setup.py sdist
51+
rm dist/*.orig
52+
- name: Test built package
53+
run: |
54+
twine check dist/*

.github/workflows/unittest.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
3+
# this file is *not* meant to cover or endorse the use of GitHub Actions, but
4+
# rather to help run automated tests for this project
5+
6+
name: Unittest Python Package
7+
8+
on: [push, pull_request]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
test-and-coverage:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-python@v3
19+
with:
20+
python-version: '3.9'
21+
- name: Execute tests
22+
run: |
23+
pip install -r requirements-test.txt
24+
python create_report_dirs.py
25+
nose2 --config tests/unittest.cfg
26+
- name: Create coverage report
27+
run: |
28+
coverage xml
29+
- name: Upload coverage to Codecov
30+
uses: codecov/codecov-action@v3
31+
with:
32+
token: ${{ secrets.CODECOV_TOKEN }}
33+
files: ./reports/coverage/coverage.xml
34+
flags: unittests
35+
fail_ci_if_error: true
36+
# path_to_write_report: ./reports/coverage/codecov_report.txt
37+
verbose: true

0 commit comments

Comments
 (0)