-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(usb-bridge): add usb-bridge project (#11468)
* Addeed the shell of the usb-bridge project * Added github workflow for testing and linting usb-bridge * Added simple CLI module with option to set log level * Added pytest.ini to trigger coverage generation
- Loading branch information
Showing
19 changed files
with
1,168 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# This workflow runs tests and lint on non-release branches pushed that alter | ||
# the usb-bridge subpackage | ||
|
||
name: 'USB-Bridge test/lint' | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'usb-bridge/**/*' | ||
- 'Makefile' | ||
- 'scripts/**/*.mk' | ||
- 'scripts/**/*.py' | ||
- '.github/workflows/usb-bridge-lint-test.yaml' | ||
- '.github/actions/python/**' | ||
branches: # ignore any release-related thing (handled elsewhere) | ||
- 'edge' | ||
tags-ignore: | ||
- '*' | ||
pull_request: | ||
types: [opened, reopened, synchronize, ready_for_review] | ||
paths: | ||
- 'usb-bridge/**/*' | ||
- 'Makefile' | ||
- 'scripts/**/*.mk' | ||
- 'scripts/**/*.py' | ||
- '.github/workflows/usb-bridge-lint-test.yaml' | ||
- '.github/actions/python/**' | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.ref_name != 'edge' || github.run_id}}-${{ github.ref_type != 'tag' || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
lint: | ||
name: 'usb-bridge linting' | ||
timeout-minutes: 10 | ||
runs-on: 'ubuntu-22.04' | ||
steps: | ||
- uses: 'actions/checkout@v3' | ||
- uses: 'actions/setup-node@v3' | ||
with: | ||
node-version: '14' | ||
- uses: 'actions/setup-python@v4' | ||
with: | ||
python-version: '3.7' | ||
|
||
- uses: './.github/actions/python/setup' | ||
with: | ||
project: 'usb-bridge' | ||
- name: Lint | ||
run: make -C usb-bridge lint | ||
test: | ||
name: 'usb-bridge package tests' | ||
timeout-minutes: 10 | ||
needs: [lint] | ||
runs-on: 'ubuntu-22.04' | ||
steps: | ||
- uses: 'actions/checkout@v3' | ||
- uses: 'actions/setup-node@v3' | ||
with: | ||
node-version: '14' | ||
- uses: 'actions/setup-python@v4' | ||
with: | ||
python-version: '3.7' | ||
- uses: './.github/actions/python/setup' | ||
with: | ||
project: 'usb-bridge' | ||
- name: Test | ||
run: make -C usb-bridge test | ||
- uses: 'codecov/codecov-action@v3' | ||
with: | ||
files: ./usb-bridge/coverage.xml | ||
flags: usb-bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[report] | ||
exclude_lines = | ||
@overload | ||
if TYPE_CHECKING: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[flake8] | ||
|
||
# max cyclomatic complexity | ||
max-complexity = 9 | ||
|
||
extend-ignore = | ||
# defer formatting concerns to black | ||
# E203: space around `:` operator | ||
# E501: maximum line length | ||
E203, | ||
E501, | ||
# do not require type annotations for self nor cls | ||
ANN101, | ||
ANN102 | ||
# do not require docstring for __init__, put them on the class | ||
D107, | ||
|
||
# configure flake8-docstrings | ||
# https://pypi.org/project/flake8-docstrings/ | ||
docstring-convention = google | ||
|
||
noqa-require-code = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This is generated by setuptools | ||
pyproject.toml | ||
|
||
# This is generated by sdist | ||
LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# makefile for usb-tcp bridge for OT-3 | ||
|
||
include ../scripts/push.mk | ||
include ../scripts/python.mk | ||
|
||
# using bash instead of /bin/bash in SHELL prevents macOS optimizing away our PATH update | ||
SHELL := bash | ||
|
||
PATH := $(shell cd .. && yarn bin):$(PATH) | ||
SHX := npx shx | ||
|
||
# add yarn CLI dev deps to PATH (for cross platform POSIX commands via shx) | ||
PATH := $(shell cd .. && yarn bin):$(PATH) | ||
|
||
# These variables can be overriden when make is invoked to customize the | ||
# behavior of pytest. For instance, | ||
# make test tests=tests/ot3usb/abcd.py would run only the | ||
# specified test | ||
tests ?= tests | ||
test_opts ?= | ||
sdist_file = $(call python_get_sdistname,ot3usb) | ||
# Host key location for buildroot robot | ||
br_ssh_key ?= $(default_ssh_key) | ||
# Other SSH args for buildroot robots | ||
br_ssh_opts ?= $(default_ssh_opts) | ||
|
||
.PHONY: setup | ||
setup: | ||
$(pipenv) sync $(pipenv_opts) | ||
$(pipenv) run pip freeze | ||
|
||
.PHONY: clean | ||
clean: | ||
$(SHX) rm -rf \ | ||
build \ | ||
dist \ | ||
.coverage \ | ||
coverage.xml \ | ||
'*.egg-info' \ | ||
'**/__pycache__' \ | ||
'**/*.pyc' | ||
|
||
.PHONY: teardown | ||
teardown: | ||
$(pipenv) --rm | ||
|
||
.PHONY: test | ||
test: | ||
$(python) -m pytest $(test_opts) $(tests) | ||
|
||
.PHONY: lint | ||
lint: | ||
$(python) -m mypy ot3usb tests | ||
$(python) -m black --check ./ot3usb ./tests | ||
$(python) -m flake8 ot3usb tests | ||
|
||
.PHONY: format | ||
format: | ||
$(python) -m black ot3usb tests | ||
|
||
.PHONY: sdist | ||
sdist: clean | ||
$(python) setup.py sdist | ||
$(SHX) rm -rf build | ||
$(SHX) ls dist | ||
|
||
.PHONY: push-ot3 | ||
push-ot3: sdist | ||
$(call push-python-sdist,$(host),,$(br_ssh_opts),dist/$(sdist_file),/opt/ot3usb,ot3usb) | ||
# todo (fs, 2022-09-15): add a restart when appropriate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
typing-extensions = "==3.10.0.0" | ||
pyserial = "==3.5" | ||
|
||
[dev-packages] | ||
ot3usb = {path = ".", editable = true} | ||
flake8 = "~=3.9.0" | ||
flake8-annotations = "~=2.6.2" | ||
flake8-docstrings = "~=1.6.0" | ||
flake8-noqa = "~=1.1.0" | ||
pytest = "==6.1.0" | ||
pytest-watch = "~=4.2.0" | ||
pytest-cov = "==2.10.1" | ||
pytest-aiohttp = "==0.3.0" | ||
coverage = "==5.1" | ||
# atomicwrites and colorama are pytest dependencies on windows, | ||
# spec'd here to force lockfile inclusion | ||
# https://github.com/pypa/pipenv/issues/4408#issuecomment-668324177 | ||
atomicwrites = {version="==1.4.0", sys_platform="== 'win32'"} | ||
colorama = {version="==0.4.4", sys_platform="== 'win32'"} | ||
mypy = "==0.940" | ||
black = "==22.3.0" | ||
decoy = "~=1.10" | ||
|
||
[requires] | ||
python_version = "3.7" |
Oops, something went wrong.