summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/aw/aws-sam-cli/package.nix
blob: 6498cfcb1a2897fe9e264a7d09a86286a93b3518 (plain)
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
{
  lib,
  python3,
  fetchFromGitHub,
  git,
  testers,
  aws-sam-cli,
  nix-update-script,
  enableTelemetry ? false,
}:

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

  src = fetchFromGitHub {
    owner = "aws";
    repo = "aws-sam-cli";
    tag = "v${version}";
    hash = "sha256-tEsKNhEAMQCsFemsb2Epnc6pVd2kDvOEceMhldqNZn4=";
  };

  build-system = with python3.pkgs; [ setuptools ];

  pythonRelaxDeps = [
    "aws_lambda_builders"
    "aws-sam-translator"
    "boto3"
    "boto3-stubs"
    "cfn-lint"
    "click"
    "cookiecutter"
    "docker"
    "jsonschema"
    "pyopenssl"
    "requests"
    "rich"
    "ruamel-yaml"
    "tomlkit"
    "tzlocal"
    "watchdog"
  ];

  dependencies =
    with python3.pkgs;
    [
      aws-lambda-builders
      aws-sam-translator
      boto3
      boto3-stubs
      cfn-lint
      chevron
      click
      cookiecutter
      dateparser
      docker
      flask
      jsonschema
      pyopenssl
      python-dotenv
      pyyaml
      requests
      rich
      ruamel-yaml
      tomlkit
      typing-extensions
      tzlocal
      watchdog
    ]
    ++ (
      with python3.pkgs.boto3-stubs.optional-dependencies;
      lib.concatLists [
        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
    jaraco-text
    parameterized
    psutil
    pytest-timeout
    pytest-xdist
    pytestCheckHook
  ];

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

  pytestFlags = [
    # Disable warnings
    "-Wignore::DeprecationWarning"
  ];

  enabledTestPaths = [ "tests" ];

  disabledTestPaths = [
    # Disable tests that requires networking or complex setup
    "tests/end_to_end"
    "tests/integration"
    "tests/regression"
    "tests/smoke"
    "tests/unit/lib/telemetry"
    "tests/unit/hook_packages/terraform/hooks/prepare/"
    "tests/unit/lib/observability/cw_logs/"
    "tests/unit/lib/build_module/"
    # Disable flaky tests
    "tests/unit/cli/test_main.py"
    "tests/unit/commands/samconfig/test_samconfig.py"
    "tests/unit/local/docker/test_lambda_image.py"
    # Tests are failing
    "tests/unit/commands/local/lib/"
    "tests/unit/local/lambda_service/test_local_lambda_http_service.py"
    "tests/unit/local/apigw/test_local_apigw_service.py"
    "tests/unit/local/apigw/test_event_constructor.py"
  ];

  disabledTests = [
    # Disable flaky tests
    "test_update_stage"
    "test_delete_deployment"
    "test_request_with_no_data"
    "test_import_should_succeed_for_a_defined_hidden_package_540_pkg_resources_py2_warn"
    "test_updates_imageuri_when_pointing_to_local_archive"
    "test_subcommand_help_0_invoke"
    "TestCli"
    "TestImportModuleProxy"
  ];

  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 = {
    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 = lib.licenses.asl20;
    mainProgram = "sam";
    maintainers = with lib.maintainers; [
      lo1tuma
      anthonyroussel
    ];
  };
}