Skip to content

Commit 48bef94

Browse files
committed
Slackbot missing def, ci
1 parent 6676428 commit 48bef94

2 files changed

Lines changed: 91 additions & 1 deletion

File tree

.github/workflows/slackbot-ci.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Slackbot CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'server/installer/slackbot/**'
7+
- '.github/workflows/slackbot-ci.yml'
8+
pull_request:
9+
paths:
10+
- 'server/installer/slackbot/**'
11+
- '.github/workflows/slackbot-ci.yml'
12+
workflow_dispatch:
13+
14+
jobs:
15+
lint-and-import:
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: server/installer/slackbot
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.12'
27+
cache: pip
28+
cache-dependency-path: server/installer/slackbot/requirements.txt
29+
30+
- name: Install dependencies
31+
run: pip install -r requirements.txt ruff
32+
33+
- name: Lint
34+
run: ruff check slack_bot.py
35+
36+
- name: Import smoke-test (catches missing def, bad module-level code)
37+
env:
38+
SLACK_APP_TOKEN: xapp-test-000000000000
39+
SLACK_BOT_TOKEN: xoxb-test-000000000000
40+
run: |
41+
python - <<'EOF'
42+
import importlib, sys, types
43+
44+
# Stub out slack_sdk and requests so the import doesn't need real network/tokens
45+
for mod in ["slack_sdk", "slack_sdk.web", "slack_sdk.socket_mode",
46+
"slack_sdk.socket_mode.request", "slack_sdk.socket_mode.response"]:
47+
sys.modules.setdefault(mod, types.ModuleType(mod))
48+
49+
# Minimal stubs the module actually uses at import time
50+
web_mod = sys.modules["slack_sdk.web"]
51+
web_mod.WebClient = lambda **_: None # type: ignore[attr-defined]
52+
53+
sm_mod = sys.modules["slack_sdk.socket_mode"]
54+
class _FakeSMC:
55+
def __init__(self, **_): pass
56+
socket_mode_request_listeners = []
57+
sm_mod.SocketModeClient = _FakeSMC # type: ignore[attr-defined]
58+
59+
import requests as _req
60+
_orig_get = _req.get
61+
def _no_net(*a, **kw): raise RuntimeError("network disabled in CI")
62+
_req.get = _no_net # type: ignore[attr-defined]
63+
64+
bot = importlib.import_module("slack_bot")
65+
66+
# Verify all command handlers are callable
67+
required = ["handle_help", "handle_wx", "handle_agent", "handle_approve",
68+
"handle_aistats", "handle_testimage", "process_events"]
69+
missing = [fn for fn in required if not callable(getattr(bot, fn, None))]
70+
if missing:
71+
print(f"FAIL: missing callables: {missing}")
72+
sys.exit(1)
73+
print("OK: all command handlers are defined and callable")
74+
EOF
75+
76+
docker-build:
77+
runs-on: ubuntu-latest
78+
steps:
79+
- uses: actions/checkout@v4
80+
81+
- uses: docker/setup-buildx-action@v3
82+
83+
- name: Build Docker image
84+
uses: docker/build-push-action@v5
85+
with:
86+
context: server/installer/slackbot
87+
push: false
88+
tags: lappy-slackbot:ci
89+
cache-from: type=gha
90+
cache-to: type=gha,mode=max

server/installer/slackbot/slack_bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def pct(v): return f"{v * 100:.1f}%"
518518
)
519519

520520

521-
521+
def handle_help(user, thread_ts=None, channel=None):
522522
channel = channel or DEFAULT_CHANNEL
523523
help_text = (
524524
f"📘 <@{user}> Available Commands:\n"

0 commit comments

Comments
 (0)