-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
226 additions
and
0 deletions.
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,39 @@ | ||
name: QA | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: linting & spelling | ||
runs-on: ubuntu-latest | ||
env: | ||
TERM: xterm-256color | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python '3,11' | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install Dependencies | ||
run: | | ||
make dev-deps | ||
- name: Run Quality Assurance | ||
run: | | ||
make qa | ||
- name: Run Code Checks | ||
run: | | ||
make check | ||
- name: Run Bash Code Checks | ||
run: | | ||
make shellcheck |
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,40 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Python ${{ matrix.python }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python: ['3.9', '3.10', '3.11'] | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
|
||
- name: Install Dependencies | ||
run: | | ||
make dev-deps | ||
- name: Run Tests | ||
run: | | ||
make pytest | ||
- name: Coverage | ||
if: ${{ matrix.python == '3.9' }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
python -m pip install coveralls | ||
coveralls --service=github |
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,20 @@ | ||
build/ | ||
_build/ | ||
*.o | ||
*.so | ||
*.a | ||
*.py[cod] | ||
*.egg-info | ||
dist/ | ||
__pycache__ | ||
.DS_Store | ||
*.deb | ||
*.dsc | ||
*.build | ||
*.changes | ||
*.orig.* | ||
packaging/*tar.xz | ||
library/debian/ | ||
.coverage | ||
.pytest_cache | ||
.tox |
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,24 @@ | ||
.PHONY: usage check pytest qa build-deps check | ||
usage: | ||
@echo "Usage: make <target>, where target is one of:\n" | ||
@echo "dev-deps: install Python dev dependencies" | ||
@echo "check: perform basic integrity checks on the codebase" | ||
@echo "shellcheck: perform check on shell scripts" | ||
@echo "qa: run linting and package QA" | ||
@echo "pytest: run Python test fixtures" | ||
|
||
dev-deps: | ||
python3 -m pip install -r requirements-dev.txt | ||
sudo apt install dos2unix shellcheck | ||
|
||
check: | ||
@bash check.sh | ||
|
||
shellcheck: | ||
shellcheck *.sh | ||
|
||
qa: | ||
tox -e qa | ||
|
||
pytest: | ||
tox -e py |
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,34 @@ | ||
#!/bin/bash | ||
|
||
# This script handles some basic QA checks on the source | ||
|
||
TERM=${TERM:="xterm-256color"} | ||
|
||
success() { | ||
echo -e "$(tput setaf 2)$1$(tput sgr0)" | ||
} | ||
|
||
inform() { | ||
echo -e "$(tput setaf 6)$1$(tput sgr0)" | ||
} | ||
|
||
warning() { | ||
echo -e "$(tput setaf 1)$1$(tput sgr0)" | ||
} | ||
inform "Checking for trailing whitespace..." | ||
if grep -IUrn --color "[[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO; then | ||
warning "Trailing whitespace found!" | ||
exit 1 | ||
else | ||
success "No trailing whitespace found." | ||
fi | ||
printf "\n" | ||
|
||
inform "Checking for DOS line-endings..." | ||
if grep -lIUrn --color $'\r' --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile; then | ||
warning "DOS line-endings found!" | ||
exit 1 | ||
else | ||
success "No DOS line-endings found." | ||
fi | ||
printf "\n" |
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 @@ | ||
check-manifest | ||
ruff | ||
codespell | ||
isort | ||
tox |
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,39 @@ | ||
import glob | ||
import json | ||
|
||
import pytest | ||
|
||
|
||
def validate_alt_mode(data): | ||
# name = data["name"] | ||
mode_type = data.get("type", "") | ||
|
||
assert mode_type != "" | ||
assert not mode_type.endswith("?") | ||
|
||
|
||
def validate_pin(data): | ||
alt_modes = data.get("alt_modes", []) | ||
|
||
for alt_mode in alt_modes: | ||
validate_alt_mode(alt_mode) | ||
|
||
|
||
def validate_header(data): | ||
width = data["width"] | ||
height = data["height"] | ||
# orientation = data["orientation"] | ||
pins = data["pins"] | ||
|
||
assert width * height == len(pins) | ||
|
||
for pin in pins: | ||
validate_pin(pin) | ||
|
||
|
||
@pytest.mark.parametrize('board_file', glob.glob("boards/*.json")) | ||
def test_validate_board_json_files(board_file): | ||
data = json.load(open(board_file, "r")) | ||
|
||
for name, header in data["headers"].items(): | ||
validate_header(header) |
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,25 @@ | ||
[tox] | ||
envlist = py,qa | ||
skip_missing_interpreters = True | ||
isolated_build = true | ||
minversion = 4.0.0 | ||
|
||
[testenv] | ||
commands = | ||
coverage run -m pytest -v -r wsx | ||
coverage report | ||
deps = | ||
mock | ||
pytest>=3.1 | ||
pytest-cov | ||
build | ||
|
||
[testenv:qa] | ||
commands = | ||
isort --check . | ||
ruff check . | ||
codespell . | ||
deps = | ||
ruff | ||
codespell | ||
isort |