2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
2023-05-24 13:37:59 +00:00
|
|
|
, python3
|
2021-05-20 23:08:51 +00:00
|
|
|
, fetchPypi
|
2023-05-24 13:37:59 +00:00
|
|
|
, ansible
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
python3.pkgs.buildPythonApplication rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "ansible-lint";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "6.17.1";
|
2021-04-05 15:23:46 +00:00
|
|
|
format = "pyproject";
|
2023-01-11 07:51:40 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-804zPzVVyZ/zTHePYdRw0eOh623HYJDQ3XuVsslHRcI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
postPatch = ''
|
|
|
|
# it is fine if lint tools are missing
|
|
|
|
substituteInPlace conftest.py \
|
|
|
|
--replace "sys.exit(1)" ""
|
|
|
|
'';
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
nativeBuildInputs = with python3.pkgs; [
|
|
|
|
setuptools
|
2021-05-20 23:08:51 +00:00
|
|
|
setuptools-scm
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
propagatedBuildInputs = with python3.pkgs; [
|
|
|
|
# https://github.com/ansible/ansible-lint/blob/master/.config/requirements.in
|
2022-03-30 09:31:56 +00:00
|
|
|
ansible-core
|
2023-07-15 17:15:38 +00:00
|
|
|
ansible-compat
|
2022-09-30 11:47:45 +00:00
|
|
|
black
|
|
|
|
filelock
|
2022-06-16 17:23:12 +00:00
|
|
|
jsonschema
|
2023-05-24 13:37:59 +00:00
|
|
|
packaging
|
2021-05-20 23:08:51 +00:00
|
|
|
pyyaml
|
|
|
|
rich
|
|
|
|
ruamel-yaml
|
2023-05-24 13:37:59 +00:00
|
|
|
subprocess-tee
|
2021-05-20 23:08:51 +00:00
|
|
|
wcmatch
|
|
|
|
yamllint
|
|
|
|
];
|
2021-04-05 15:23:46 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
# tests can't be easily run without installing things from ansible-galaxy
|
|
|
|
doCheck = false;
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
nativeCheckInputs = with python3.pkgs; [
|
2022-03-30 09:31:56 +00:00
|
|
|
flaky
|
2021-05-20 23:08:51 +00:00
|
|
|
pytest-xdist
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
2021-04-05 15:23:46 +00:00
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
# ansible wants to write to $HOME and crashes if it can't
|
2020-04-24 23:36:52 +00:00
|
|
|
export HOME=$(mktemp -d)
|
2023-05-24 13:37:59 +00:00
|
|
|
export PATH=$PATH:${lib.makeBinPath [ ansible ]}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
# create a working ansible-lint executable
|
|
|
|
export PATH=$PATH:$PWD/src/ansiblelint
|
|
|
|
ln -rs src/ansiblelint/__main__.py src/ansiblelint/ansible-lint
|
|
|
|
patchShebangs src/ansiblelint/__main__.py
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
# create symlink like in the git repo so test_included_tasks does not fail
|
|
|
|
ln -s ../roles examples/playbooks/roles
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
disabledTests = [
|
|
|
|
# requires network
|
2021-10-06 13:57:05 +00:00
|
|
|
"test_cli_auto_detect"
|
|
|
|
"test_install_collection"
|
2021-04-05 15:23:46 +00:00
|
|
|
"test_prerun_reqs_v1"
|
|
|
|
"test_prerun_reqs_v2"
|
2021-10-06 13:57:05 +00:00
|
|
|
"test_require_collection_wrong_version"
|
|
|
|
# re-execs ansible-lint which does not works correct
|
|
|
|
"test_custom_kinds"
|
|
|
|
"test_run_inside_role_dir"
|
|
|
|
"test_run_multiple_role_path_no_trailing_slash"
|
|
|
|
"test_runner_exclude_globs"
|
|
|
|
"test_discover_lintables_umlaut"
|
2021-04-05 15:23:46 +00:00
|
|
|
];
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ ansible ]}" ];
|
2021-04-05 15:23:46 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Best practices checker for Ansible";
|
2023-01-11 07:51:40 +00:00
|
|
|
homepage = "https://github.com/ansible/ansible-lint";
|
|
|
|
changelog = "https://github.com/ansible/ansible-lint/releases/tag/v${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
2022-10-30 15:09:59 +00:00
|
|
|
maintainers = with maintainers; [ sengaya ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|