Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/notify-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/notify-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/notify-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


DEFAULT_FUNCTION_NAME_PREFIX = "DurablePythonExample-"
DEFAULT_DURABLE_LOGGING_CONFIG: dict[str, str] = {"LogFormat": "JSON"}
LOG_RETENTION_DAYS = 7


Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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"},
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}

Expand Down
Loading