-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
.pre-commit-config.yaml
151 lines (136 loc) · 4.07 KB
/
.pre-commit-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
fail_fast: true
default_install_hook_types: [pre-commit, pre-push]
ci:
skip:
- twine-check
- changelog-bump
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
exclude: .bumpversion.cfg
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
- repo: https://github.com/crate-ci/typos
rev: v1.26.0
hooks:
- id: typos
args: []
verbose: true
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.12.0
hooks:
- id: mypy
files: jsonargparse.*/.*.py
stages: [pre-push]
additional_dependencies:
[
types-PyYAML,
types-requests,
]
verbose: true
- repo: local
hooks:
- id: twine-check
name: twine check [on bumpversion]
entry: bash -c '
set -e;
if [ "${BUMPVERSION_NEW_VERSION+x}" = "" ]; then
echo "$(tput setaf 6) Skipped, only runs when bumping version $(tput sgr0)";
else
python3 -m build --wheel;
twine check dist/*.whl;
fi'
language: system
pass_filenames: false
verbose: true
- id: changelog-bump
name: changelog bump [on bumpversion]
entry: bash -c '
set -e;
if [ "${BUMPVERSION_NEW_VERSION+x}" = "" ]; then
echo "$(tput setaf 6) Skipped, only runs when bumping version $(tput sgr0)";
else
CHANGELOG=$(grep -E "^v.+\..+\..+ \(....-..-..\)" CHANGELOG.rst | head -n 1);
EXPECTED="v$BUMPVERSION_NEW_VERSION ($(date -u +%Y-%m-%d))";
if [ "$CHANGELOG" != "$EXPECTED" ] && [ $(echo $BUMPVERSION_NEW_VERSION | grep -cE "[0-9.]+(\.dev|rc)[0-9]+") = 0 ]; then
if [ $(grep -c "^v$BUMPVERSION_NEW_VERSION " CHANGELOG.rst) = 1 ]; then
echo "Updating the date for v$BUMPVERSION_NEW_VERSION in CHANGELOG.rst";
sed -i "s|^v$BUMPVERSION_NEW_VERSION .*|$EXPECTED|" CHANGELOG.rst;
git add CHANGELOG.rst;
else
echo "Expected release in CHANGELOG.rst to be "$EXPECTED" or not have a definitive date.";
exit 1;
fi
fi
fi'
language: system
pass_filenames: false
verbose: true
- id: tox
name: tox --parallel
entry: tox --parallel
stages: [pre-push]
language: system
pass_filenames: false
verbose: true
- id: test-without-future-annotations
name: test-without-future-annotations
entry: bash -c '
set -e;
if [ $(pip3 list 2>/dev/null | grep -F "$(pwd)" | grep -c ^jsonargparse) = 0 ]; then
echo "$(tput setaf 6) Skipped, jsonargparse not installed as editable $(tput sgr0)";
else
TEST_DIR=$(mktemp -d -t _jsonargparse_tests_XXXXXX);
cleanup () { rm -rf "$TEST_DIR"; };
trap cleanup EXIT;
cp jsonargparse_tests/*.py "$TEST_DIR";
cd "$TEST_DIR";
sed -i "/^from __future__ import annotations$/d" *.py;
pytest $TEST_DIR;
fi'
stages: [pre-push]
language: system
pass_filenames: false
verbose: true
- id: doctest
name: sphinx-build -M doctest sphinx sphinx/_build sphinx/index.rst
entry: bash -c '
set -e;
if [ "$(which sphinx-build)" = "" ]; then
echo "$(tput setaf 6) Skipped, sphinx-build command not found $(tput sgr0)";
else
sphinx-build -M doctest sphinx sphinx/_build sphinx/index.rst;
fi'
stages: [pre-push]
language: system
pass_filenames: false
verbose: true
- id: coverage
name: pytest -v -s --cov --cov-report=term --cov-report=html
entry: pytest -v -s --cov --cov-report=term --cov-report=html
stages: [pre-push]
language: system
pass_filenames: false
verbose: true