about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/aws-sam-cli/default.nix
blob: 5ab92dbe8b18dccb7167c509d30347f65252ada6 (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
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
152
153
154
155
{ lib
, python3
, fetchFromGitHub
, git
, testers
, aws-sam-cli
, nix-update-script
, enableTelemetry ? false
}:

python3.pkgs.buildPythonApplication rec {
  pname = "aws-sam-cli";
  version = "1.110.0";
  pyproject = true;

  disabled = python3.pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "aws";
    repo = "aws-sam-cli";
    rev = "refs/tags/v${version}";
    hash = "sha256-FJHHEsdi2uGP9/GxrANsVEuxZiS4M4BPBGoARQBQpkA=";
  };

  nativeBuildInputs = with python3.pkgs; [
    pythonRelaxDepsHook
    setuptools
  ];

  pythonRelaxDeps = [
    "aws-lambda-builders"
    "aws-sam-translator"
    "boto3-stubs"
    "cfn-lint"
    "cookiecutter"
    "docker"
    "jsonschema"
    "pyopenssl"
    "rich"
    "ruamel-yaml"
    "tomlkit"
    "tzlocal"
  ];

  propagatedBuildInputs = with python3.pkgs; [
    aws-lambda-builders
    aws-sam-translator
    boto3
    boto3-stubs
    cfn-lint
    chevron
    click
    cookiecutter
    dateparser
    docker
    flask
    jsonschema
    pyopenssl
    pyyaml
    requests
    rich
    ruamel-yaml
    tomlkit
    typing-extensions
    tzlocal
    watchdog
  ] ++ (with python3.pkgs.boto3-stubs.optional-dependencies; [
    apigateway
    cloudformation
    ecr
    iam
    kinesis
    lambda
    s3
    schemas
    secretsmanager
    signer
    sqs
    stepfunctions
    sts
    xray
  ]);

  postFixup = ''
    # Disable telemetry: https://github.com/aws/aws-sam-cli/issues/1272
    wrapProgram $out/bin/sam \
      --set SAM_CLI_TELEMETRY ${if enableTelemetry then "1" else "0"} \
      --prefix PATH : $out/bin:${lib.makeBinPath [ git ]}
  '';

  nativeCheckInputs = with python3.pkgs; [
    filelock
    flaky
    parameterized
    psutil
    pytest-timeout
    pytest-xdist
    pytestCheckHook
  ];

  preCheck = ''
    export HOME=$(mktemp -d)
    export PATH="$PATH:$out/bin:${lib.makeBinPath [ git ]}"
  '';

  pytestFlagsArray = [
    "tests"
    # Disable warnings
    "-W"
    "ignore::DeprecationWarning"
  ];

  disabledTestPaths = [
    # Disable tests that requires networking or complex setup
    "tests/end_to_end"
    "tests/integration"
    "tests/regression"
    "tests/smoke"
    "tests/unit/lib/telemetry"
    # Disable flaky tests
    "tests/unit/lib/samconfig/test_samconfig.py"
  ];

  disabledTests = [
    # Disable flaky tests
    "test_update_stage"
    "test_delete_deployment"
    "test_request_with_no_data"
  ];

  pythonImportsCheck = [
    "samcli"
  ];

  passthru = {
    tests.version = testers.testVersion {
      package = aws-sam-cli;
      command = "sam --version";
    };
    updateScript = nix-update-script {
      extraArgs = [ "--version-regex" "^v([0-9.]+)$" ];
    };
  };

  __darwinAllowLocalNetworking = true;

  meta = with lib; {
    description = "CLI tool for local development and testing of Serverless applications";
    homepage = "https://github.com/aws/aws-sam-cli";
    changelog = "https://github.com/aws/aws-sam-cli/releases/tag/v${version}";
    license = licenses.asl20;
    mainProgram = "sam";
    maintainers = with maintainers; [ lo1tuma anthonyroussel ];
  };
}