Skip to content

Commit

Permalink
Merge from aws/aws-sam-cli/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-sam-cli-bot authored Nov 14, 2024
2 parents a1607b3 + e204a3d commit 91956e9
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 22 deletions.
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ regex!=2021.10.8
tzlocal==5.2

#Adding cfn-lint dependency for SAM validate
cfn-lint~=1.18.4
cfn-lint~=1.19.0

# Type checking boto3 objects
boto3-stubs[apigateway,cloudformation,ecr,iam,lambda,s3,schemas,secretsmanager,signer,stepfunctions,sts,xray,sqs,kinesis]==1.35.56
6 changes: 3 additions & 3 deletions requirements/reproducible-linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ cffi==1.17.1 \
--hash=sha256:f7f5baafcc48261359e14bcd6d9bff6d4b28d9103847c9e136694cb0501aef87 \
--hash=sha256:fc48c783f9c87e60831201f2cce7f3b2e4846bf4d8728eabe54d60700b318a0b
# via cryptography
cfn-lint==1.18.4 \
--hash=sha256:73dadc33d6a91c69651cb08fe919138ab4e2f6cf1be1e361f7c6dcbccd1527ba \
--hash=sha256:76741e76fa26f31bfacc3eb465eddd93ad535838d84fbc6dd092817d8e22d57f
cfn-lint==1.19.0 \
--hash=sha256:63835e083f7831e54c512bce4808754df221b5895aed9a114c71879d1cc4ebff \
--hash=sha256:9c43a6b866915df6d2ac5584000ef05e53c67624809808c2cebd3dc6154b7c14
# via aws-sam-cli (setup.py)
chardet==5.2.0 \
--hash=sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7 \
Expand Down
6 changes: 3 additions & 3 deletions requirements/reproducible-mac.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ cffi==1.17.1 \
--hash=sha256:f7f5baafcc48261359e14bcd6d9bff6d4b28d9103847c9e136694cb0501aef87 \
--hash=sha256:fc48c783f9c87e60831201f2cce7f3b2e4846bf4d8728eabe54d60700b318a0b
# via cryptography
cfn-lint==1.18.4 \
--hash=sha256:73dadc33d6a91c69651cb08fe919138ab4e2f6cf1be1e361f7c6dcbccd1527ba \
--hash=sha256:76741e76fa26f31bfacc3eb465eddd93ad535838d84fbc6dd092817d8e22d57f
cfn-lint==1.19.0 \
--hash=sha256:63835e083f7831e54c512bce4808754df221b5895aed9a114c71879d1cc4ebff \
--hash=sha256:9c43a6b866915df6d2ac5584000ef05e53c67624809808c2cebd3dc6154b7c14
# via aws-sam-cli (setup.py)
chardet==5.2.0 \
--hash=sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7 \
Expand Down
6 changes: 3 additions & 3 deletions requirements/reproducible-win.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ cffi==1.17.1 \
--hash=sha256:f7f5baafcc48261359e14bcd6d9bff6d4b28d9103847c9e136694cb0501aef87 \
--hash=sha256:fc48c783f9c87e60831201f2cce7f3b2e4846bf4d8728eabe54d60700b318a0b
# via cryptography
cfn-lint==1.18.4 \
--hash=sha256:73dadc33d6a91c69651cb08fe919138ab4e2f6cf1be1e361f7c6dcbccd1527ba \
--hash=sha256:76741e76fa26f31bfacc3eb465eddd93ad535838d84fbc6dd092817d8e22d57f
cfn-lint==1.19.0 \
--hash=sha256:63835e083f7831e54c512bce4808754df221b5895aed9a114c71879d1cc4ebff \
--hash=sha256:9c43a6b866915df6d2ac5584000ef05e53c67624809808c2cebd3dc6154b7c14
# via aws-sam-cli (setup.py)
chardet==5.2.0 \
--hash=sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7 \
Expand Down
2 changes: 1 addition & 1 deletion samcli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
SAM CLI version
"""

__version__ = "1.128.0"
__version__ = "1.129.0"
23 changes: 14 additions & 9 deletions samcli/commands/init/init_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,21 @@ def _get_manifest(self):
"""
try:
response = requests.get(MANIFEST_URL, timeout=10)
body = response.text
# if the commit is not exist then MANIFEST_URL will be invalid, fall back to use manifest in latest commit
if response.status_code == Status.NOT_FOUND.value:
LOG.warning(
"Request to MANIFEST_URL: %s failed, the commit hash in this url maybe invalid, "
"Using manifest.json in the latest commit instead.",
MANIFEST_URL,
)
if not response.ok:
# if the commit is not exist then MANIFEST_URL will be invalid,
# fall back to use manifest in latest commit
if response.status_code == Status.NOT_FOUND.value:
LOG.warning(
"Request to MANIFEST_URL: %s failed, the commit hash in this url maybe invalid, "
"Using manifest.json in the latest commit instead.",
MANIFEST_URL,
)
else:
LOG.debug(
"Request to MANIFEST_URL: %s failed, with %s status code", MANIFEST_URL, response.status_code
)
raise ManifestNotFoundException()

body = response.text
except (requests.Timeout, requests.ConnectionError, ManifestNotFoundException):
LOG.debug("Request to get Manifest failed, attempting to clone the repository")
self.clone_templates_repo()
Expand Down
2 changes: 1 addition & 1 deletion samcli/runtime_config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"app_template_repo_commit": "994ec01c08fa415ed20258d72cb7f750b8b8211d"
"app_template_repo_commit": "a22d509a91e0ceca3eb596ab13d5ebe76ff0a894"
}
1 change: 1 addition & 0 deletions tests/integration/validate/test_validate_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def test_lint_supported_runtimes(self):
"python3.10",
"python3.11",
"python3.12",
"python3.13",
"ruby3.2",
"ruby3.3",
]
Expand Down
20 changes: 19 additions & 1 deletion tests/unit/commands/init/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pathlib import Path
from typing import Dict, Any
from unittest import TestCase
from unittest.mock import patch, ANY
from unittest.mock import patch, ANY, Mock

import botocore.exceptions
import click
Expand Down Expand Up @@ -2204,6 +2204,24 @@ def test_must_return_runtime_from_base_image_name(self):
runtime = get_runtime(IMAGE, base_image)
self.assertEqual(runtime, expected_runtime[index])

@patch("samcli.commands.init.init_templates.requests")
@patch.object(InitTemplates, "__init__", MockInitTemplates.__init__)
def test_must_fallback_for_non_ok_http_response(self, requests_mock):
requests_mock.get.return_value = Mock(ok=False)
requests_mock.Timeout = requests.Timeout
requests_mock.ConnectionError = requests.ConnectionError

template = InitTemplates()
with mock.patch.object(
template, "clone_templates_repo", wraps=template.clone_templates_repo
) as mocked_clone_templates_repo:
with mock.patch.object(
template, "get_manifest_path", wraps=template.get_manifest_path
) as mocked_get_manifest_path:
template.get_preprocessed_manifest()
mocked_clone_templates_repo.assert_called_once()
mocked_get_manifest_path.assert_called_once()

@patch("samcli.commands.init.init_templates.InitTemplates._get_manifest")
@patch.object(InitTemplates, "__init__", MockInitTemplates.__init__)
def test_must_process_manifest(self, _get_manifest_mock):
Expand Down

0 comments on commit 91956e9

Please sign in to comment.