Restructure src/ to per-function layout with shared Layer

Move from flat src/ to per-function directories:
- src/slack-bot/ — Slack Bolt Lambda handler
- src/weekly-post/ — Monday schedule + pay post
- src/roster-sync/ — Daily 3CX roster sync
- src/shared/ — Lambda Layer with schedule, blocks, three_cx_client

Each function has its own requirements.txt and CodeUri. Shared
modules are deployed as a SAM Layer (afterhours-shared) importable
as `from shared.X import Y`.
This commit is contained in:
Adam Moussa 2026-05-12 15:39:28 -04:00
parent 3de9243f6b
commit 0fed60248a
14 changed files with 40 additions and 15 deletions

View file

@ -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"

View file

@ -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)

View file

@ -0,0 +1,2 @@
boto3>=1.43.6
requests>=2.33.1

View file

@ -0,0 +1,2 @@
boto3>=1.43.6
requests>=2.33.1

View file

@ -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")

View file

@ -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)

View file

@ -1,3 +1,2 @@
slack_bolt>=1.28.0,<2.0
boto3>=1.43.6
requests>=2.33.1

View file

@ -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)

View file

@ -0,0 +1,2 @@
slack_sdk>=3.33.0,<4.0
boto3>=1.43.6

View file

@ -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: