Skip to content

Commit

Permalink
test: add lint & test tooling for Aider
Browse files Browse the repository at this point in the history
Aider (the AI coding assistant) can run and react to linter and test
output automatically. I use Aider occasionally, so this helps in that
workflow.
  • Loading branch information
akaihola committed Oct 5, 2024
1 parent 05b10b4 commit 2b90627
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AIDER_LINT_CMD=./run-lint.sh
AIDER_TEST_CMD=./run-tests.sh
34 changes: 34 additions & 0 deletions run-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

VENV=$HOME/.virtualenvs/darker
PIP=${VENV}/bin/pip
[ ! -f ${PIP} ] && python -m venv ${VENV} && ${PIP} install -U pip
${PIP} install -q -e '.[color,test,release]'
${PIP} uninstall -q -y ruff

ensure() { command -v $1 >/dev/null || ${PIP} install -q $1; }

ensure black
ensure codespell

errors=0

source ${VENV}/bin/activate
for file in "$@"; do
case "$file" in
*.py)
darker --quiet --isort --revision origin/main "$file" || errors=$?
graylint --quiet --revision origin/main \
--lint mypy \
--lint "ruff check" \
--lint "codespell" \
"$file" || errors=$?
;;
*.sh|*.md|*.rst|*.txt)
codespell "$file" || errors=$?
;;
esac
done
deactivate

exit $errors
11 changes: 11 additions & 0 deletions run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

VENV=$HOME/.virtualenvs/darker
PIP=${VENV}/bin/pip
[ ! -f ${PIP} ] && python -m venv ${VENV} && ${PIP} install -U pip
${PIP} install -q -e '.[color,test,release]'

errors=0
${VENV}/bin/pytest || errors=$?

exit $errors

0 comments on commit 2b90627

Please sign in to comment.