2019-02-24 21:53:30 +00:00
|
|
|
{ lib
|
2023-05-15 23:03:21 +00:00
|
|
|
, python3
|
2021-05-14 00:48:03 +00:00
|
|
|
, fetchPypi
|
2023-05-15 23:03:21 +00:00
|
|
|
, ansible
|
2019-02-24 21:53:30 +00:00
|
|
|
}:
|
|
|
|
|
2023-05-15 23:03:21 +00:00
|
|
|
python3.pkgs.buildPythonApplication rec {
|
2019-02-24 21:53:30 +00:00
|
|
|
pname = "ansible-lint";
|
2023-10-20 06:51:58 +00:00
|
|
|
version = "6.21.1";
|
2021-03-07 18:18:07 +00:00
|
|
|
format = "pyproject";
|
2023-01-04 07:44:55 +00:00
|
|
|
|
2019-02-24 21:53:30 +00:00
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2023-10-20 06:51:58 +00:00
|
|
|
hash = "sha256-Bf/G38jzy79W9/l3CzQ2/HkJutXB11Rw76BkUx8C324=";
|
2019-02-24 21:53:30 +00:00
|
|
|
};
|
|
|
|
|
2022-03-29 17:29:27 +00:00
|
|
|
postPatch = ''
|
|
|
|
# it is fine if lint tools are missing
|
|
|
|
substituteInPlace conftest.py \
|
|
|
|
--replace "sys.exit(1)" ""
|
|
|
|
'';
|
|
|
|
|
2023-05-15 23:03:21 +00:00
|
|
|
nativeBuildInputs = with python3.pkgs; [
|
2023-05-15 22:55:58 +00:00
|
|
|
setuptools
|
2021-05-14 00:54:05 +00:00
|
|
|
setuptools-scm
|
|
|
|
];
|
2021-03-07 18:18:07 +00:00
|
|
|
|
2023-05-15 23:03:21 +00:00
|
|
|
propagatedBuildInputs = with python3.pkgs; [
|
2023-05-15 22:55:58 +00:00
|
|
|
# https://github.com/ansible/ansible-lint/blob/master/.config/requirements.in
|
2022-03-29 17:29:27 +00:00
|
|
|
ansible-core
|
2023-06-09 13:12:42 +00:00
|
|
|
ansible-compat
|
2022-09-14 21:36:01 +00:00
|
|
|
black
|
|
|
|
filelock
|
2022-05-11 12:28:38 +00:00
|
|
|
jsonschema
|
2023-05-15 22:55:58 +00:00
|
|
|
packaging
|
2021-05-14 00:48:03 +00:00
|
|
|
pyyaml
|
|
|
|
rich
|
|
|
|
ruamel-yaml
|
2023-05-15 22:55:58 +00:00
|
|
|
subprocess-tee
|
2021-05-14 00:48:03 +00:00
|
|
|
wcmatch
|
|
|
|
yamllint
|
|
|
|
];
|
|
|
|
|
2022-03-29 17:29:27 +00:00
|
|
|
# tests can't be easily run without installing things from ansible-galaxy
|
|
|
|
doCheck = false;
|
|
|
|
|
2023-05-15 23:03:21 +00:00
|
|
|
nativeCheckInputs = with python3.pkgs; [
|
2022-03-29 17:29:27 +00:00
|
|
|
flaky
|
2021-05-14 00:48:03 +00:00
|
|
|
pytest-xdist
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
2021-03-07 18:18:07 +00:00
|
|
|
preCheck = ''
|
|
|
|
# ansible wants to write to $HOME and crashes if it can't
|
2020-01-02 21:59:09 +00:00
|
|
|
export HOME=$(mktemp -d)
|
2023-05-15 23:03:21 +00:00
|
|
|
export PATH=$PATH:${lib.makeBinPath [ ansible ]}
|
2019-02-24 21:53:30 +00:00
|
|
|
|
2021-03-07 18:18:07 +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-14 00:48:03 +00:00
|
|
|
|
|
|
|
# create symlink like in the git repo so test_included_tasks does not fail
|
|
|
|
ln -s ../roles examples/playbooks/roles
|
2019-02-24 21:53:30 +00:00
|
|
|
'';
|
|
|
|
|
2021-03-07 18:18:07 +00:00
|
|
|
disabledTests = [
|
|
|
|
# requires network
|
2021-10-04 22:01:33 +00:00
|
|
|
"test_cli_auto_detect"
|
|
|
|
"test_install_collection"
|
2021-03-07 18:18:07 +00:00
|
|
|
"test_prerun_reqs_v1"
|
|
|
|
"test_prerun_reqs_v2"
|
2021-10-04 22:01:33 +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-03-07 18:18:07 +00:00
|
|
|
];
|
|
|
|
|
2023-05-15 23:03:21 +00:00
|
|
|
makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ ansible ]}" ];
|
2021-03-07 18:18:07 +00:00
|
|
|
|
2019-02-24 21:53:30 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Best practices checker for Ansible";
|
2023-01-04 07:44:55 +00:00
|
|
|
homepage = "https://github.com/ansible/ansible-lint";
|
|
|
|
changelog = "https://github.com/ansible/ansible-lint/releases/tag/v${version}";
|
2019-02-24 21:53:30 +00:00
|
|
|
license = licenses.mit;
|
2022-10-25 13:49:15 +00:00
|
|
|
maintainers = with maintainers; [ sengaya ];
|
2019-02-24 21:53:30 +00:00
|
|
|
};
|
|
|
|
}
|