mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-10-03 13:53:21 +00:00
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:
parent
3de9243f6b
commit
0fed60248a
14 changed files with 40 additions and 15 deletions
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
|
|
@ -7,4 +7,4 @@ jobs:
|
||||||
ci:
|
ci:
|
||||||
uses: Sea-Haven-Industries/.github/.github/workflows/ci-python-sam.yaml@main
|
uses: Sea-Haven-Industries/.github/.github/workflows/ci-python-sam.yaml@main
|
||||||
with:
|
with:
|
||||||
source-dirs: "src"
|
source-dirs: "src/slack-bot src/weekly-post src/roster-sync src/shared/python/shared"
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
|
|
||||||
from src.three_cx_client import ThreeCXClient
|
from shared.three_cx_client import ThreeCXClient
|
||||||
from src.schedule import ShiftSchedule
|
from shared.schedule import ShiftSchedule
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
2
src/roster-sync/requirements.txt
Normal file
2
src/roster-sync/requirements.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
boto3>=1.43.6
|
||||||
|
requests>=2.33.1
|
||||||
2
src/shared/requirements.txt
Normal file
2
src/shared/requirements.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
boto3>=1.43.6
|
||||||
|
requests>=2.33.1
|
||||||
|
|
@ -10,14 +10,14 @@ from zoneinfo import ZoneInfo
|
||||||
import boto3
|
import boto3
|
||||||
from slack_bolt import App
|
from slack_bolt import App
|
||||||
|
|
||||||
from src.blocks import (
|
from shared.blocks import (
|
||||||
build_help_blocks,
|
build_help_blocks,
|
||||||
build_pay_summary_blocks,
|
build_pay_summary_blocks,
|
||||||
build_roster_blocks,
|
build_roster_blocks,
|
||||||
build_shift_change_message,
|
build_shift_change_message,
|
||||||
build_week_schedule,
|
build_week_schedule,
|
||||||
)
|
)
|
||||||
from src.schedule import FALLBACK_EXTENSION, ShiftSchedule
|
from shared.schedule import FALLBACK_EXTENSION, ShiftSchedule
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
EASTERN = ZoneInfo("America/New_York")
|
EASTERN = ZoneInfo("America/New_York")
|
||||||
|
|
@ -6,7 +6,7 @@ import os
|
||||||
import boto3
|
import boto3
|
||||||
from slack_bolt.adapter.aws_lambda import SlackRequestHandler
|
from slack_bolt.adapter.aws_lambda import SlackRequestHandler
|
||||||
|
|
||||||
from src.app import create_app
|
from app import create_app
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
slack_bolt>=1.28.0,<2.0
|
slack_bolt>=1.28.0,<2.0
|
||||||
boto3>=1.43.6
|
boto3>=1.43.6
|
||||||
requests>=2.33.1
|
|
||||||
|
|
@ -10,8 +10,8 @@ from zoneinfo import ZoneInfo
|
||||||
import boto3
|
import boto3
|
||||||
from slack_sdk import WebClient
|
from slack_sdk import WebClient
|
||||||
|
|
||||||
from src.blocks import build_pay_summary_blocks, build_week_schedule
|
from shared.blocks import build_pay_summary_blocks, build_week_schedule
|
||||||
from src.schedule import FALLBACK_EXTENSION, ShiftSchedule
|
from shared.schedule import FALLBACK_EXTENSION, ShiftSchedule
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
2
src/weekly-post/requirements.txt
Normal file
2
src/weekly-post/requirements.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
slack_sdk>=3.33.0,<4.0
|
||||||
|
boto3>=1.43.6
|
||||||
|
|
@ -20,6 +20,20 @@ Globals:
|
||||||
- arm64
|
- arm64
|
||||||
|
|
||||||
Resources:
|
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 ---
|
# --- DynamoDB ---
|
||||||
ShiftTable:
|
ShiftTable:
|
||||||
Type: AWS::DynamoDB::Table
|
Type: AWS::DynamoDB::Table
|
||||||
|
|
@ -42,8 +56,10 @@ Resources:
|
||||||
Type: AWS::Serverless::Function
|
Type: AWS::Serverless::Function
|
||||||
Properties:
|
Properties:
|
||||||
FunctionName: afterhours-shift-manager
|
FunctionName: afterhours-shift-manager
|
||||||
Handler: src/handler.handler
|
Handler: handler.handler
|
||||||
CodeUri: .
|
CodeUri: src/slack-bot/
|
||||||
|
Layers:
|
||||||
|
- !Ref SharedLayer
|
||||||
Environment:
|
Environment:
|
||||||
Variables:
|
Variables:
|
||||||
SHIFT_TABLE: !Ref ShiftTable
|
SHIFT_TABLE: !Ref ShiftTable
|
||||||
|
|
@ -85,8 +101,10 @@ Resources:
|
||||||
Type: AWS::Serverless::Function
|
Type: AWS::Serverless::Function
|
||||||
Properties:
|
Properties:
|
||||||
FunctionName: afterhours-weekly-post
|
FunctionName: afterhours-weekly-post
|
||||||
Handler: src/weekly_post.handler
|
Handler: app.handler
|
||||||
CodeUri: .
|
CodeUri: src/weekly-post/
|
||||||
|
Layers:
|
||||||
|
- !Ref SharedLayer
|
||||||
Environment:
|
Environment:
|
||||||
Variables:
|
Variables:
|
||||||
SHIFT_TABLE: !Ref ShiftTable
|
SHIFT_TABLE: !Ref ShiftTable
|
||||||
|
|
@ -138,8 +156,10 @@ Resources:
|
||||||
Type: AWS::Serverless::Function
|
Type: AWS::Serverless::Function
|
||||||
Properties:
|
Properties:
|
||||||
FunctionName: afterhours-roster-sync
|
FunctionName: afterhours-roster-sync
|
||||||
Handler: src/roster_sync.handler
|
Handler: app.handler
|
||||||
CodeUri: .
|
CodeUri: src/roster-sync/
|
||||||
|
Layers:
|
||||||
|
- !Ref SharedLayer
|
||||||
Timeout: 60
|
Timeout: 60
|
||||||
Environment:
|
Environment:
|
||||||
Variables:
|
Variables:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue