Skip to content

Commit

Permalink
Update pre-commit lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kmagusiak committed Sep 2, 2023
1 parent 1fa7ba5 commit 84a6c77
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
# for xmllint
sudo apt-get update
sudo apt-get install -y --no-install-recommends libxml2-utils
- name: Run pre-commit checks
run: |
./pre-commit lint
21 changes: 12 additions & 9 deletions addons/template/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,25 @@ pre_commit() {
isort --check-only .
}

lint_text() {
if find -name '*.xml' -type f -print0 | xargs -0 \
grep --files-with-matches --max-count 5 --line-number -P '^\t'
then
echo '... should be indented with spaces'
return 1
fi
find -name '*.xml' -type f -print0 | xargs --no-run-if-empty -0 -n1 -P5 \
python3 -c 'import xml.etree.ElementTree as ET; import sys; ET.parse(sys.argv[1])'
}

format() {
black .
isort .
}

lint() {
pre_commit

# xmllint for files
if type xmllint &> /dev/null
then
find -name '*.xml' -type f | xargs xmllint -noout
else
echo "xmllint not installed"
exit 1
fi
lint_text
# Skipping: import-error (odoo not available in github actions)
pylint -d import-error \
$(find -name '__manifest__.py' -exec dirname '{}' ';' | sort)
Expand Down

0 comments on commit 84a6c77

Please sign in to comment.