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
16 changes: 9 additions & 7 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,19 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install pipenv
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install pipenv
- name: Install dependencies
run: |
pipenv install --dev --python $(which python)
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
make flake8
pipenv run make flake8
- name: Lint Docs with Pydocstyle
run: |
make docstyle
pipenv run make docstyle
- name: Send running tests notification
if: ${{ inputs.notehub_notify }}
run: |
Expand All @@ -77,13 +79,13 @@ jobs:
DD_SERVICE: note-python
DD_ENV: ci
run: |
coverage run -m pytest --ddtrace --ddtrace-patch-all --ignore=test/hitl
pipenv run coverage run -m pytest --ddtrace --ddtrace-patch-all --ignore=test/hitl
- name: Publish to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ inputs.coveralls }}
run: |
coveralls --service=github
pipenv run coveralls --service=github

- name: Check if the job has succeeded
if: ${{ success() && inputs.notehub_notify }}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ on:

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -22,13 +20,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install build twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
- name: Check if the job has failed
if: ${{ failure() }}
Expand Down
33 changes: 9 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,31 @@
# define VENV_NAME to use a specific virtual environment. It defaults to `env`.
VENV_NAME?=env
VENV_ACTIVATE=$(VENV_NAME)/bin/activate
PYTHON=python
# the target to activate the virtual environment. Only defined if it exists.

# check if the VENV file exists, if it does assume that's been made active
ifneq ("$(wildcard ${VENV_ACTIVATE})","")
RUN_VENV_ACTIVATE=. ${VENV_ACTIVATE}
PYTHON = ${VENV_NAME}/bin/python3
endif
# Use pipenv for virtual environment management
PYTHON=python3

default: precommit

precommit: docstyle flake8

test:
${RUN_VENV_ACTIVATE}
${PYTHON} -m pytest test --cov=notecard --ignore=test/hitl
pipenv run pytest test --cov=notecard --ignore=test/hitl

docstyle:
${RUN_VENV_ACTIVATE}
${PYTHON} -m pydocstyle notecard/ examples/ mpy_board/
pipenv run pydocstyle notecard/ examples/ mpy_board/

flake8:
${RUN_VENV_ACTIVATE}
# E722 Do not use bare except, specify exception instead https://www.flake8rules.com/rules/E722.html
# F401 Module imported but unused https://www.flake8rules.com/rules/F401.html
# F403 'from module import *' used; unable to detect undefined names https://www.flake8rules.com/rules/F403.html
# W503 Line break occurred before a binary operator https://www.flake8rules.com/rules/W503.html
# E501 Line too long (>79 characters) https://www.flake8rules.com/rules/E501.html
${PYTHON} -m flake8 --exclude=notecard/md5.py test/ notecard/ examples/ mpy_board/ --count --ignore=E722,F401,F403,W503,E501,E502 --show-source --statistics
pipenv run flake8 --exclude=notecard/md5.py test/ notecard/ examples/ mpy_board/ --count --ignore=E722,F401,F403,W503,E501,E502 --show-source --statistics

coverage:
${RUN_VENV_ACTIVATE}
${PYTHON} -m pytest test --ignore=test/hitl --doctest-modules --junitxml=junit/test-results.xml --cov=notecard --cov-report=xml --cov-report=html
pipenv run pytest test --ignore=test/hitl --doctest-modules --junitxml=junit/test-results.xml --cov=notecard --cov-report=xml --cov-report=html

run_build:
${RUN_VENV_ACTIVATE}
${PYTHON} -m setup sdist bdist_wheel
pipenv run python -m build

deploy:
${RUN_VENV_ACTIVATE}
${PYTHON} -m twine upload -r "pypi" --config-file .pypirc 'dist/*'
pipenv run python -m twine upload -r "pypi" --config-file .pypirc 'dist/*'

.PHONY: precommit venv test coverage run_build deploy
.PHONY: precommit test coverage run_build deploy
24 changes: 24 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
filelock = "==3.0.12"

[dev-packages]
future = "==0.18.3"
iso8601 = "==0.1.12"
pyserial = "==3.4"
python-periphery = "==2.3.0"
pyyaml = "==6.0.1"
flake8 = "==6.1.0"
pytest = "==7.0.1"
pytest-cov = "==2.8.1"
pydocstyle = "==5.0.2"
packaging = ">=20.4"
pre-commit = "*"
coveralls = "==3.3.1"
ddtrace = "==2.21.1"
build = "*"
twine = "*"
Loading