summary refs log tree commit diff
path: root/pkgs/development/python-modules/ansible-lint/default.nix
blob: 8388cd33e084dfc426e436b8965c00b4d3b56d11 (plain) (blame)
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
{ lib
, stdenv
, fetchPypi
, buildPythonPackage
, isPy27
, ansible
, pyyaml
, ruamel-yaml
, rich
, pytestCheckHook
, pytest-xdist
, git
, wcmatch
, enrich
, python
}:

buildPythonPackage rec {
  pname = "ansible-lint";
  version = "5.0.2";
  disabled = isPy27;
  format = "pyproject";

  src = fetchPypi {
    inherit pname version;
    sha256 = "sha256-vgt/KqNozTPaON/I19SybBZuo7bbl3Duq5dTBTMlj44=";
  };

  postPatch = ''
    substituteInPlace src/ansiblelint/file_utils.py \
      --replace 'raise RuntimeError("Unable to determine file type for %s" % pathex)' 'return "playbook"'
  '';

  buildInputs = [ python ];

  propagatedBuildInputs = [ ansible enrich pyyaml rich ruamel-yaml wcmatch ];

  checkInputs = [ pytestCheckHook pytest-xdist git ];

  preCheck = ''
    # ansible wants to write to $HOME and crashes if it can't
    export HOME=$(mktemp -d)
    export PATH=$PATH:${lib.makeBinPath [ ansible ]}

    # 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
  '';

  disabledTests = [
    # requires network
    "test_prerun_reqs_v1"
    "test_prerun_reqs_v2"
    # Assertion error with negative numbers; maybe requieres an ansible update?
    "test_negative"
    "test_example"
    "test_playbook"
    "test_included_tasks"
    "test_long_line"

    "test_get_yaml_files_umlaut"
    "test_run_inside_role_dir"
    "test_role_handler_positive"
  ];

  # fails to run tests due to issues with temporary directory
  doCheck = !stdenv.isDarwin;

  makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ ansible ]}" ];

  meta = with lib; {
    homepage = "https://github.com/ansible-community/ansible-lint";
    description = "Best practices checker for Ansible";
    license = licenses.mit;
    maintainers = with maintainers; [ sengaya SuperSandro2000 ];
  };
}