diff --git a/.github/workflows/notify-issues.yml b/.github/workflows/notify-issues.yml index c4d89657..1c6ace8d 100644 --- a/.github/workflows/notify-issues.yml +++ b/.github/workflows/notify-issues.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Send issue notification to Slack - uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3 + uses: slackapi/slack-github-action@0d95c9a7becc1e6e297d76df9bc735c44f4cbcbc # v3.0.5 with: webhook: ${{ secrets.SLACK_WEBHOOK_URL_ISSUE }} webhook-type: incoming-webhook diff --git a/.github/workflows/notify-pr.yml b/.github/workflows/notify-pr.yml index 0335e6a6..e82b93b4 100644 --- a/.github/workflows/notify-pr.yml +++ b/.github/workflows/notify-pr.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Send pull request notification to Slack if: github.event.pull_request.draft == false - uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3 + uses: slackapi/slack-github-action@0d95c9a7becc1e6e297d76df9bc735c44f4cbcbc # v3.0.5 with: webhook: ${{ secrets.SLACK_WEBHOOK_URL_PR }} webhook-type: incoming-webhook diff --git a/.github/workflows/notify-release.yml b/.github/workflows/notify-release.yml index 778db7e9..83b190e4 100644 --- a/.github/workflows/notify-release.yml +++ b/.github/workflows/notify-release.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Send release notification to Slack - uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3 + uses: slackapi/slack-github-action@0d95c9a7becc1e6e297d76df9bc735c44f4cbcbc # v3.0.5 with: webhook: ${{ secrets.SLACK_WEBHOOK_URL_RELEASE }} webhook-type: incoming-webhook diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 8a6cf9b4..3a5ef483 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -75,6 +75,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard (optional). # Commenting out will disable upload of results to your repo's Code Scanning dashboard - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3 + uses: github/codeql-action/upload-sarif@99df26d4f13ea111d4ec1a7dddef6063f76b97e9 # v4.37.0 with: sarif_file: results.sarif diff --git a/packages/aws-durable-execution-sdk-python-examples/scripts/generate_sam_template.py b/packages/aws-durable-execution-sdk-python-examples/scripts/generate_sam_template.py index 93e09489..478006a4 100644 --- a/packages/aws-durable-execution-sdk-python-examples/scripts/generate_sam_template.py +++ b/packages/aws-durable-execution-sdk-python-examples/scripts/generate_sam_template.py @@ -7,6 +7,7 @@ DEFAULT_FUNCTION_NAME_PREFIX = "DurablePythonExample-" +DEFAULT_DURABLE_LOGGING_CONFIG: dict[str, str] = {"LogFormat": "JSON"} LOG_RETENTION_DAYS = 7 @@ -78,8 +79,13 @@ def build_template(examples: list[dict[str, Any]]) -> dict[str, Any]: if "durableConfig" in example: properties["DurableConfig"] = example["durableConfig"] + logging_config: dict[str, Any] = dict(DEFAULT_DURABLE_LOGGING_CONFIG) + else: + logging_config = {} + + if "loggingConfig" in example: + logging_config.update(example["loggingConfig"]) - logging_config: dict[str, Any] = dict(example.get("loggingConfig", {})) logging_config["LogGroup"] = {"Ref": f"{logical_id}LogGroup"} properties["LoggingConfig"] = logging_config diff --git a/packages/aws-durable-execution-sdk-python-examples/test/test_generate_sam_template.py b/packages/aws-durable-execution-sdk-python-examples/test/test_generate_sam_template.py new file mode 100644 index 00000000..5f8ef3de --- /dev/null +++ b/packages/aws-durable-execution-sdk-python-examples/test/test_generate_sam_template.py @@ -0,0 +1,56 @@ +"""Tests for SAM template generation.""" + +import importlib.util +from pathlib import Path + + +SCRIPT_PATH = ( + Path(__file__).resolve().parents[1] / "scripts" / "generate_sam_template.py" +) +SPEC = importlib.util.spec_from_file_location("generate_sam_template", SCRIPT_PATH) +assert SPEC is not None +assert SPEC.loader is not None +generate_sam_template = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(generate_sam_template) + + +def test_build_template_adds_default_json_logging_to_durable_functions(): + template = generate_sam_template.build_template( + [ + { + "handler": "hello_world.handler", + "description": "A durable example", + "durableConfig": { + "RetentionPeriodInDays": 7, + "ExecutionTimeout": 300, + }, + }, + { + "handler": "logger_example.handler", + "description": "A durable example with custom logging", + "durableConfig": { + "RetentionPeriodInDays": 7, + "ExecutionTimeout": 300, + }, + "loggingConfig": {"ApplicationLogLevel": "INFO"}, + }, + { + "handler": "plain_lambda.handler", + "description": "A non-durable example", + }, + ] + ) + + resources = template["Resources"] + assert resources["HelloWorld"]["Properties"]["LoggingConfig"] == { + "LogFormat": "JSON", + "LogGroup": {"Ref": "HelloWorldLogGroup"}, + } + assert resources["LoggerExample"]["Properties"]["LoggingConfig"] == { + "LogFormat": "JSON", + "ApplicationLogLevel": "INFO", + "LogGroup": {"Ref": "LoggerExampleLogGroup"}, + } + assert resources["PlainLambda"]["Properties"]["LoggingConfig"] == { + "LogGroup": {"Ref": "PlainLambdaLogGroup"}, + } diff --git a/packages/aws-durable-execution-sdk-python-examples/test/test_log_group_deployment.py b/packages/aws-durable-execution-sdk-python-examples/test/test_log_group_deployment.py index 78a3f21c..9e18bbbe 100644 --- a/packages/aws-durable-execution-sdk-python-examples/test/test_log_group_deployment.py +++ b/packages/aws-durable-execution-sdk-python-examples/test/test_log_group_deployment.py @@ -45,6 +45,7 @@ def test_build_template_creates_lambda_log_group_with_seven_day_retention(): } assert template["Resources"]["HelloWorld"]["DependsOn"] == ["HelloWorldLogGroup"] assert template["Resources"]["HelloWorld"]["Properties"]["LoggingConfig"] == { + "LogFormat": "JSON", "LogGroup": {"Ref": "HelloWorldLogGroup"}, }