Skip to content

Commit

Permalink
Merge pull request #74 from hnez/ci-streamline
Browse files Browse the repository at this point in the history
CI: streamline and add build and codespell targets
  • Loading branch information
SmithChart authored May 6, 2024
2 parents 838945b + c7380ba commit 57e91b2
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 81 deletions.
2 changes: 2 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[codespell]
skip = ./.git,./*.egg-info,./.pybuild,./build,./env,./venv,./envs,./dist
14 changes: 0 additions & 14 deletions .github/workflows/black.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/check-and-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Check and Build

on: [push, pull_request]

jobs:
black:
name: Python black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make qa-black

codespell:
name: Codespell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make qa-codespell

flake8:
name: Python flake8
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make qa-flake8

pytest:
name: Python pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make qa-pytest

build:
name: Python Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
25 changes: 0 additions & 25 deletions .github/workflows/flake8.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/pytest.yml

This file was deleted.

66 changes: 44 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,69 @@ PYTHON=python3

PYTHON_ENV_ROOT=envs
PYTHON_PACKAGING_VENV=$(PYTHON_ENV_ROOT)/$(PYTHON)-packaging-env
PYTHON_TESTING_ENV=$(PYTHON_ENV_ROOT)/$(PYTHON)-qa-env

.PHONY: clean
PYTHON_QA_ENV=$(PYTHON_ENV_ROOT)/$(PYTHON)-qa-env

# packaging environment #######################################################
.PHONY: packaging-env build _release

$(PYTHON_PACKAGING_VENV)/.created: REQUIREMENTS.packaging.txt
rm -rf $(PYTHON_PACKAGING_VENV) && \
$(PYTHON) -m venv $(PYTHON_PACKAGING_VENV) && \
. $(PYTHON_PACKAGING_VENV)/bin/activate && \
pip install --upgrade pip && \
pip install -r REQUIREMENTS.packaging.txt
$(PYTHON) -m pip install --upgrade pip && \
$(PYTHON) -m pip install -r REQUIREMENTS.packaging.txt
date > $(PYTHON_PACKAGING_VENV)/.created

packaging-env: $(PYTHON_PACKAGING_VENV)/.created

sdist: packaging-env
build: packaging-env
. $(PYTHON_PACKAGING_VENV)/bin/activate && \
rm -rf dist *.egg-info && \
./setup.py sdist

_release: sdist
_release: build
. $(PYTHON_PACKAGING_VENV)/bin/activate && \
twine upload dist/*
$(PYTHON) -m twine upload dist/*

# helper ######################################################################
.PHONY: clean envs

clean:
rm -rf $(PYTHON_ENV_ROOT)

envs: env packaging-env
envs: packaging-env qa-env

# testing #####################################################################
$(PYTHON_TESTING_ENV)/.created: REQUIREMENTS.qa.txt
rm -rf $(PYTHON_TESTING_ENV) && \
$(PYTHON) -m venv $(PYTHON_TESTING_ENV) && \
. $(PYTHON_TESTING_ENV)/bin/activate && \
pip install pip --upgrade && \
pip install -r ./REQUIREMENTS.qa.txt && \
date > $(PYTHON_TESTING_ENV)/.created

qa: $(PYTHON_TESTING_ENV)/.created
. $(PYTHON_TESTING_ENV)/bin/activate && \
black --check --diff . && \
flake8 && \
python3 -m pytest -vv
.PHONY: qa qa-env qa-black qa-codespell qa-flake8 qa-pytest

$(PYTHON_QA_ENV)/.created: REQUIREMENTS.qa.txt
rm -rf $(PYTHON_QA_ENV) && \
$(PYTHON) -m venv $(PYTHON_QA_ENV) && \
. $(PYTHON_QA_ENV)/bin/activate && \
$(PYTHON) -m pip install pip --upgrade && \
$(PYTHON) -m pip install -r ./REQUIREMENTS.qa.txt && \
date > $(PYTHON_QA_ENV)/.created

qa-env: $(PYTHON_QA_ENV)/.created

qa: qa-black qa-codespell qa-flake8 qa-pytest

qa-black: qa-env
. $(PYTHON_QA_ENV)/bin/activate && \
$(PYTHON) -m black --check --diff .

qa-codespell: qa-env
. $(PYTHON_QA_ENV)/bin/activate && \
codespell

qa-codespell-fix: qa-env
. $(PYTHON_QA_ENV)/bin/activate && \
codespell -w

qa-flake8: qa-env
. $(PYTHON_QA_ENV)/bin/activate && \
$(PYTHON) -m flake8

qa-pytest: qa-env
. $(PYTHON_QA_ENV)/bin/activate && \
$(PYTHON) -m pytest -vv
1 change: 1 addition & 0 deletions REQUIREMENTS.qa.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
black
codespell
flake8
flake8-pyproject
flake8-bugbear
Expand Down
4 changes: 2 additions & 2 deletions usbsdmux/usb2642.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def _call_IOCTL(self, command, sg_dxfer, databuffer):
command -- SCSI Command payload to send. 16-Byte buffer containing the SCSI
command parameters.
sg_dxfer -- _SG_DXFER_*: Direction of the SCSI transfer
databuffer -- 512 byte long buffer to be written oder read
databuffer -- 512 byte long buffer to be written or read
"""
sgio, sense = self._get_SGIO(command, sg_dxfer, databuffer)
# print("SGIO:")
Expand Down Expand Up @@ -390,7 +390,7 @@ def write_read_to(self, i2cAddr, writeData, readLength):
* writeData[1]
* ...
* I2C-Repeated Start
* I2C-Slave address wit R/W = R (1)
* I2C-Slave address with R/W = R (1)
* readData[0]
* readData[1]
* ...
Expand Down
2 changes: 1 addition & 1 deletion usbsdmux/usb2642eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class _EepromStruct(ctypes.Structure):
("LUN_PWR_LB", ctypes.c_uint8), # 0xA4 LUN Power Lo byte
("LUN_PWR_HB", ctypes.c_uint8), # 0xA5 LUN Power Hi byte
("reserved1", ctypes.c_uint8 * (0xBF - 0xA6)), # 0xA6 .. 0xBE reserved
("DEV3_ID_STR", ctypes.c_uint8 * (0xC6 - 0xBF)), # 0xBF .. 0xC5 Card Reader Identifyer String
("DEV3_ID_STR", ctypes.c_uint8 * (0xC6 - 0xBF)), # 0xBF .. 0xC5 Card Reader Identifier String
("INQ_VEN_STR", ctypes.c_uint8 * (0xCE - 0xC6)), # 0xC6 .. 0xCD Inquiry Vendor String
("INQ_PRD_STR", ctypes.c_uint8 * (0xD3 - 0xCE)), # 0xCE .. 0xD2 48QFN Inquiry Product String
("DYN_NUM_LUN", ctypes.c_uint8), # 0xD3 Dynamic Number of LUNs
Expand Down

0 comments on commit 57e91b2

Please sign in to comment.