Linux Foundation Administrators | 14b8edb | 2018-01-25 13:00:42 -0800 | [diff] [blame] | 1 | [tox] |
| 2 | minversion = 1.6 |
Eric Ball | 9ecb7ad | 2024-09-12 12:52:26 -0700 | [diff] [blame] | 3 | envlist = pre-commit |
Linux Foundation Administrators | 14b8edb | 2018-01-25 13:00:42 -0800 | [diff] [blame] | 4 | skipsdist = true |
| 5 | |
Eric Ball | 9ecb7ad | 2024-09-12 12:52:26 -0700 | [diff] [blame] | 6 | [testenv:jenkins-jobs] |
Linux Foundation Administrators | 14b8edb | 2018-01-25 13:00:42 -0800 | [diff] [blame] | 7 | deps = |
Eric Ball | 9ecb7ad | 2024-09-12 12:52:26 -0700 | [diff] [blame] | 8 | jenkins-job-builder=={env:JJB_VERSION:6.4.1} |
Linux Foundation Administrators | 14b8edb | 2018-01-25 13:00:42 -0800 | [diff] [blame] | 9 | commands = |
Eric Ball | 9ecb7ad | 2024-09-12 12:52:26 -0700 | [diff] [blame] | 10 | jenkins-jobs {posargs:--help} |
Linux Foundation Administrators | 14b8edb | 2018-01-25 13:00:42 -0800 | [diff] [blame] | 11 | |
Eric Ball | 9ecb7ad | 2024-09-12 12:52:26 -0700 | [diff] [blame] | 12 | [testenv:pre-commit-install] |
| 13 | basepython = python3 |
| 14 | deps = pre-commit |
| 15 | commands = |
| 16 | pre-commit install |
| 17 | pre-commit install --hook-type commit-msg |
Linux Foundation Administrators | 14b8edb | 2018-01-25 13:00:42 -0800 | [diff] [blame] | 18 | |
Eric Ball | 9ecb7ad | 2024-09-12 12:52:26 -0700 | [diff] [blame] | 19 | [testenv:pre-commit-uninstall] |
| 20 | basepython = python3 |
| 21 | deps = pre-commit |
| 22 | commands = |
| 23 | pre-commit uninstall |
| 24 | pre-commit uninstall --hook-type commit-msg |
| 25 | |
| 26 | [testenv:pre-commit] |
| 27 | description = Precommit checks for black, gitlint, etc. |
| 28 | allowlist_externals = |
| 29 | /bin/sh |
| 30 | deps = |
| 31 | pre-commit |
| 32 | passenv = HOME |
| 33 | commands = |
| 34 | pre-commit run --all-files --show-diff-on-failure |
| 35 | /bin/sh -c 'if ! git config --get user.name > /dev/null; then \ |
| 36 | git config --global --add user.name "CI"; \ |
| 37 | touch .git/REMOVE_USERNAME; fi' |
| 38 | /bin/sh -c 'if ! git config --get user.email > /dev/null; then \ |
| 39 | git config --global --add user.email "ci@example.org"; \ |
| 40 | touch .git/REMOVE_USEREMAIL; fi' |
| 41 | /bin/sh -c "if [ -f .git/COMMIT_EDITMSG ]; then \ |
| 42 | cp .git/COMMIT_EDITMSG .git/COMMIT_MSGTOX; else \ |
| 43 | git log HEAD -n1 --pretty=%B > .git/COMMIT_MSGTOX; fi" |
| 44 | pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_MSGTOX |
| 45 | /bin/sh -c "rm -f .git/COMMIT_MSGTOX" |
| 46 | /bin/sh -c "if [ -f .git/REMOVE_USERNAME ]; then \ |
| 47 | git config --global --unset user.name; \ |
| 48 | rm -f .git/REMOVE_USERNAME; fi" |
| 49 | /bin/sh -c "if [ -f .git/REMOVE_USEREMAIL ]; then \ |
| 50 | git config --global --unset user.email; \ |
| 51 | rm -f .git/REMOVE_USEREMAIL; fi" |