diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3c66f09..2b6dbbc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,4 +7,4 @@ jobs: ci: uses: Sea-Haven-Industries/.github/.github/workflows/ci-python-sam.yaml@main with: - source-dirs: "src" + source-dirs: "src/slack-bot src/weekly-post src/roster-sync src/shared/python/shared" diff --git a/src/roster_sync.py b/src/roster-sync/app.py similarity index 97% rename from src/roster_sync.py rename to src/roster-sync/app.py index 72bfb68..fa53420 100644 --- a/src/roster_sync.py +++ b/src/roster-sync/app.py @@ -12,8 +12,8 @@ from zoneinfo import ZoneInfo import boto3 -from src.three_cx_client import ThreeCXClient -from src.schedule import ShiftSchedule +from shared.three_cx_client import ThreeCXClient +from shared.schedule import ShiftSchedule logger = logging.getLogger() logger.setLevel(logging.INFO) diff --git a/src/roster-sync/requirements.txt b/src/roster-sync/requirements.txt new file mode 100644 index 0000000..fc95321 --- /dev/null +++ b/src/roster-sync/requirements.txt @@ -0,0 +1,2 @@ +boto3>=1.43.6 +requests>=2.33.1 diff --git a/src/__init__.py b/src/shared/python/shared/__init__.py similarity index 100% rename from src/__init__.py rename to src/shared/python/shared/__init__.py diff --git a/src/blocks.py b/src/shared/python/shared/blocks.py similarity index 100% rename from src/blocks.py rename to src/shared/python/shared/blocks.py diff --git a/src/schedule.py b/src/shared/python/shared/schedule.py similarity index 100% rename from src/schedule.py rename to src/shared/python/shared/schedule.py diff --git a/src/three_cx_client.py b/src/shared/python/shared/three_cx_client.py similarity index 100% rename from src/three_cx_client.py rename to src/shared/python/shared/three_cx_client.py diff --git a/src/shared/requirements.txt b/src/shared/requirements.txt new file mode 100644 index 0000000..fc95321 --- /dev/null +++ b/src/shared/requirements.txt @@ -0,0 +1,2 @@ +boto3>=1.43.6 +requests>=2.33.1 diff --git a/src/app.py b/src/slack-bot/app.py similarity index 99% rename from src/app.py rename to src/slack-bot/app.py index 0dd8f51..3ff804c 100644 --- a/src/app.py +++ b/src/slack-bot/app.py @@ -10,14 +10,14 @@ from zoneinfo import ZoneInfo import boto3 from slack_bolt import App -from src.blocks import ( +from shared.blocks import ( build_help_blocks, build_pay_summary_blocks, build_roster_blocks, build_shift_change_message, build_week_schedule, ) -from src.schedule import FALLBACK_EXTENSION, ShiftSchedule +from shared.schedule import FALLBACK_EXTENSION, ShiftSchedule logger = logging.getLogger(__name__) EASTERN = ZoneInfo("America/New_York") diff --git a/src/handler.py b/src/slack-bot/handler.py similarity index 97% rename from src/handler.py rename to src/slack-bot/handler.py index 08a3f3d..32fb37c 100644 --- a/src/handler.py +++ b/src/slack-bot/handler.py @@ -6,7 +6,7 @@ import os import boto3 from slack_bolt.adapter.aws_lambda import SlackRequestHandler -from src.app import create_app +from app import create_app logger = logging.getLogger() logger.setLevel(logging.INFO) diff --git a/requirements.txt b/src/slack-bot/requirements.txt similarity index 69% rename from requirements.txt rename to src/slack-bot/requirements.txt index cd1aaf2..1f9b6ab 100644 --- a/requirements.txt +++ b/src/slack-bot/requirements.txt @@ -1,3 +1,2 @@ slack_bolt>=1.28.0,<2.0 boto3>=1.43.6 -requests>=2.33.1 diff --git a/src/weekly_post.py b/src/weekly-post/app.py similarity index 98% rename from src/weekly_post.py rename to src/weekly-post/app.py index a7cc5a3..b9abb1b 100644 --- a/src/weekly_post.py +++ b/src/weekly-post/app.py @@ -10,8 +10,8 @@ from zoneinfo import ZoneInfo import boto3 from slack_sdk import WebClient -from src.blocks import build_pay_summary_blocks, build_week_schedule -from src.schedule import FALLBACK_EXTENSION, ShiftSchedule +from shared.blocks import build_pay_summary_blocks, build_week_schedule +from shared.schedule import FALLBACK_EXTENSION, ShiftSchedule logger = logging.getLogger() logger.setLevel(logging.INFO) diff --git a/src/weekly-post/requirements.txt b/src/weekly-post/requirements.txt new file mode 100644 index 0000000..1fc4048 --- /dev/null +++ b/src/weekly-post/requirements.txt @@ -0,0 +1,2 @@ +slack_sdk>=3.33.0,<4.0 +boto3>=1.43.6 diff --git a/template.yaml b/template.yaml index 5e7d2c3..2f94e60 100644 --- a/template.yaml +++ b/template.yaml @@ -20,6 +20,20 @@ Globals: - arm64 Resources: + # --- Shared Lambda Layer --- + SharedLayer: + Type: AWS::Serverless::LayerVersion + Properties: + LayerName: afterhours-shared + ContentUri: src/shared/ + CompatibleRuntimes: + - python3.12 + CompatibleArchitectures: + - arm64 + Metadata: + BuildMethod: python3.12 + BuildArchitecture: arm64 + # --- DynamoDB --- ShiftTable: Type: AWS::DynamoDB::Table @@ -42,8 +56,10 @@ Resources: Type: AWS::Serverless::Function Properties: FunctionName: afterhours-shift-manager - Handler: src/handler.handler - CodeUri: . + Handler: handler.handler + CodeUri: src/slack-bot/ + Layers: + - !Ref SharedLayer Environment: Variables: SHIFT_TABLE: !Ref ShiftTable @@ -85,8 +101,10 @@ Resources: Type: AWS::Serverless::Function Properties: FunctionName: afterhours-weekly-post - Handler: src/weekly_post.handler - CodeUri: . + Handler: app.handler + CodeUri: src/weekly-post/ + Layers: + - !Ref SharedLayer Environment: Variables: SHIFT_TABLE: !Ref ShiftTable @@ -138,8 +156,10 @@ Resources: Type: AWS::Serverless::Function Properties: FunctionName: afterhours-roster-sync - Handler: src/roster_sync.handler - CodeUri: . + Handler: app.handler + CodeUri: src/roster-sync/ + Layers: + - !Ref SharedLayer Timeout: 60 Environment: Variables: