Skip to content

Commit 3b4c40a

Browse files
authored
feat: add support for durable functions (aws#8479)
1 parent 205ce59 commit 3b4c40a

252 files changed

Lines changed: 12740 additions & 842 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/integration-tests.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
- local-invoke
5252
- local-start1
5353
- local-start2
54+
- durable-functions
5455
- other-and-e2e
5556
exclude:
5657
# no-container mode only applies to build-integ test suites
@@ -66,6 +67,8 @@ jobs:
6667
test_suite: local-start1
6768
- container_runtime: no-container
6869
test_suite: local-start2
70+
- container_runtime: no-container
71+
test_suite: durable-functions
6972
- container_runtime: no-container
7073
test_suite: other-and-e2e
7174

@@ -374,13 +377,16 @@ jobs:
374377
pytest -vv tests/integration/sync -n 6 --reruns 3 --dist loadscope --json-report --json-report-file=TEST_REPORT-integration-sync-${{ matrix.container_runtime }}.json
375378
;;
376379
"local-invoke")
377-
pytest -vv --reruns 3 tests/integration/local/invoke tests/integration/local/generate_event --json-report --json-report-file=TEST_REPORT-integration-local-invoke-${{ matrix.container_runtime }}.json
380+
pytest -vv --reruns 3 tests/integration/local/invoke tests/integration/local/generate_event --ignore tests/integration/local/invoke/test_invoke_durable.py --json-report --json-report-file=TEST_REPORT-integration-local-invoke-${{ matrix.container_runtime }}.json
378381
;;
379382
"local-start1")
380-
pytest -vv --reruns 3 tests/integration/local/start_api --ignore tests/integration/local/start_api/test_start_api_with_terraform_application.py --json-report --json-report-file=TEST_REPORT-integration-local-start1-${{ matrix.container_runtime }}.json
383+
pytest -vv --reruns 3 tests/integration/local/start_api --ignore tests/integration/local/start_api/test_start_api_with_terraform_application.py --ignore tests/integration/local/start_api/test_start_api_durable.py --json-report --json-report-file=TEST_REPORT-integration-local-start1-${{ matrix.container_runtime }}.json
381384
;;
382385
"local-start2")
383-
pytest -vv --reruns 3 tests/integration/local/start_lambda tests/integration/local/start_api/test_start_api_with_terraform_application.py --json-report --json-report-file=TEST_REPORT-integration-local-start2-${{ matrix.container_runtime }}.json
386+
pytest -vv --reruns 3 tests/integration/local/start_lambda tests/integration/local/start_api/test_start_api_with_terraform_application.py --ignore tests/integration/local/start_lambda/test_start_lambda_durable.py --json-report --json-report-file=TEST_REPORT-integration-local-start2-${{ matrix.container_runtime }}.json
387+
;;
388+
"durable-functions")
389+
pytest -vv --reruns 3 tests/integration/local/invoke/test_invoke_durable.py tests/integration/local/start_api/test_start_api_durable.py tests/integration/local/start_lambda/test_start_lambda_durable.py tests/integration/local/callback/test_callback.py tests/integration/local/execution/test_execution.py --json-report --json-report-file=TEST_REPORT-integration-durable-functions-${{ matrix.container_runtime }}.json
384390
;;
385391
"other-and-e2e")
386392
pytest -vv -n 4 --reruns 4 --dist loadgroup tests/integration tests/end_to_end --ignore=tests/integration/buildcmd --ignore=tests/integration/delete --ignore=tests/integration/deploy --ignore=tests/integration/package --ignore=tests/integration/sync --ignore=tests/integration/local --json-report --json-report-file=TEST_REPORT-integration-others-${{ matrix.container_runtime }}.json

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,4 +422,7 @@ samcli/lib/init/templates/cookiecutter-aws-sam-hello-java-gradle/**/.gradle/
422422
.build
423423

424424
.kiro
425-
mise.toml
425+
mise.toml
426+
427+
# Durable executions
428+
**/.durable-executions-local/

samcli/cli/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def cli(ctx):
142142
if ctx and getattr(ctx, "command_path", None) == "samdev":
143143
from samcli.cli.import_module_proxy import attach_import_module_proxy
144144

145-
LOG.info("Attaching import module proxy for analyzing dynamic imports")
145+
LOG.debug("Attaching import module proxy for analyzing dynamic imports")
146146
attach_import_module_proxy()
147147

148148
gc = GlobalConfig()

samcli/cli/types.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,23 @@ def convert(
633633
return {resource_id: [excluded_path]}
634634

635635

636+
class DurableExecutionArnType(click.ParamType):
637+
"""
638+
Custom Parameter Type for Durable Execution ARN validation.
639+
"""
640+
641+
name = "string"
642+
pattern = (
643+
r"^arn:([a-zA-Z0-9-]+):lambda:([a-zA-Z0-9-]+):(\d{12}):function:([a-zA-Z0-9_-]+):"
644+
r"(\$LATEST(?:\.PUBLISHED)?|[0-9]+)/durable-execution/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$"
645+
)
646+
647+
def convert(self, value, param, ctx):
648+
if not re.match(self.pattern, value):
649+
raise click.BadParameter(f"Invalid Durable Execution ARN format: {value}")
650+
return value
651+
652+
636653
class TextWithSpaces:
637654
def __init__(self, text) -> None:
638655
self.text = text

samcli/commands/common/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
Shared options for callback fail commands
3+
"""
4+
5+
from typing import Dict, List
6+
7+
# Common options between local and remote callback fail commands
8+
COMMON_CALLBACK_FAIL_OPTIONS: List[str] = ["error_data", "stack_trace", "error_type", "error_message"]
9+
10+
# Common options info
11+
COMMON_CALLBACK_FAIL_OPTIONS_INFO: Dict[str, Dict] = {
12+
"Callback Options": {"option_names": {opt: {"rank": idx} for idx, opt in enumerate(COMMON_CALLBACK_FAIL_OPTIONS)}}
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""
2+
Shared options for callback heartbeat commands
3+
"""
4+
5+
from typing import Dict, List
6+
7+
# Common options between local and remote callback heartbeat commands
8+
COMMON_CALLBACK_HEARTBEAT_OPTIONS: List[str] = []
9+
10+
# Common options info
11+
COMMON_CALLBACK_HEARTBEAT_OPTIONS_INFO: Dict[str, Dict] = {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Shared options for callback succeed commands
3+
"""
4+
5+
from typing import Dict, List
6+
7+
# Common options between local and remote callback succeed commands
8+
COMMON_CALLBACK_SUCCEED_OPTIONS: List[str] = ["result"]
9+
10+
# Common options info
11+
COMMON_CALLBACK_SUCCEED_OPTIONS_INFO: Dict[str, Dict] = {
12+
"Callback Options": {
13+
"option_names": {opt: {"rank": idx} for idx, opt in enumerate(COMMON_CALLBACK_SUCCEED_OPTIONS)}
14+
}
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""
2+
Shared options for execution get commands
3+
"""
4+
5+
from typing import Dict, List
6+
7+
from samcli.cli.core.options import add_common_options_info
8+
9+
# Common options between local and remote execution get commands
10+
COMMON_EXECUTION_GET_FORMATTING_OPTIONS: List[str] = ["format"]
11+
12+
# Common options info with common options included
13+
COMMON_EXECUTION_GET_FORMATTING_OPTIONS_INFO: Dict[str, Dict] = {
14+
"Formatting Options": {
15+
"option_names": {opt: {"rank": idx} for idx, opt in enumerate(COMMON_EXECUTION_GET_FORMATTING_OPTIONS)}
16+
},
17+
}
18+
add_common_options_info(COMMON_EXECUTION_GET_FORMATTING_OPTIONS_INFO)

0 commit comments

Comments
 (0)