Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow configuration for pre-commit.ci #1735

Merged
merged 1 commit into from Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions pre_commit/clientlib.py
Expand Up @@ -297,9 +297,13 @@ def warn_unknown_keys_repo(
'exclude',
'fail_fast',
'minimum_pre_commit_version',
'ci',
),
warn_unknown_keys_root,
),

# do not warn about configuration for pre-commit.ci
cfgv.OptionalNoDefault('ci', cfgv.check_type(dict)),
)


Expand Down
14 changes: 14 additions & 0 deletions tests/clientlib_test.py
Expand Up @@ -166,6 +166,20 @@ def test_validate_warn_on_unknown_keys_at_top_level(tmpdir, caplog):
]


def test_ci_map_key_allowed_at_top_level(caplog):
cfg = {
'ci': {'skip': ['foo']},
'repos': [{'repo': 'meta', 'hooks': [{'id': 'identity'}]}],
}
cfgv.validate(cfg, CONFIG_SCHEMA)
assert not caplog.record_tuples


def test_ci_key_must_be_map():
with pytest.raises(cfgv.ValidationError):
cfgv.validate({'ci': 'invalid', 'repos': []}, CONFIG_SCHEMA)


def test_validate_optional_sensible_regex(caplog):
config_obj = {
'id': 'flake8',
Expand Down