Skip to content

Commit

Permalink
ci: lint Python files
Browse files Browse the repository at this point in the history
  • Loading branch information
sethfischer committed Jun 12, 2021
1 parent 8733e77 commit 23a398f
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 4 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install Poetry
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
python get-poetry.py -y
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Install dependencies
run: poetry install --no-interaction

- name: Lint Cpp source
run: |
sudo apt-get -y install clang-format
Expand All @@ -19,6 +33,9 @@ jobs:
sudo apt-get -y install scour
make lint-svg
- name: Lint Python files
run: poetry run make lint-python

- name: Lint shell scripts
run: |
sudo apt-get -y install shellcheck
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ git-hooks: .git/hooks/pre-commit
install --mode=700 $< $@

.PHONY: lint
lint: lint-c lint-shell lint-svg
lint: lint-c lint-python lint-shell lint-svg

.PHONY: lint-c lint-shell lint-svg
lint-c lint-shell lint-svg:
.PHONY: lint-c lint-python lint-shell lint-svg
lint-c lint-python lint-shell lint-svg:
./$@.sh
9 changes: 9 additions & 0 deletions lint-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -o errexit -o noclobber -o nounset

directory="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

git ls-files -z -- "${directory}/**.py" | xargs --no-run-if-empty --null flake8
git ls-files -z -- "${directory}/**.py" | xargs --no-run-if-empty --null black --check
git ls-files -z -- "${directory}/**.py" | xargs --no-run-if-empty --null isort --check-only
197 changes: 196 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ sphinx-rtd-theme = "^0.5.2"

[tool.poetry.dev-dependencies]
platformio = "^5.1.1"
black = "^21.6b0"
flake8 = "^3.9.2"
isort = "^5.8.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
doctests = true
max-complexity = 6
max-line-length = 88

0 comments on commit 23a398f

Please sign in to comment.