Skip to content

Commit 44b17f3

Browse files
author
beefbrisket911
authored
send alerts to slack (#127)
Send alerts to Slack if a bot token is defined. - bump to python 3.13 - add github dependabot
1 parent ba49d1b commit 44b17f3

File tree

7 files changed

+24
-13
lines changed

7 files changed

+24
-13
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"

.github/workflows/deploy.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,3 @@ jobs:
3636
push: true
3737
tags: ${{ steps.meta.outputs.tags }}
3838
labels: ${{ steps.meta.outputs.labels }}
39-
40-
- uses: cowprotocol/autodeploy-action@v1
41-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
42-
with:
43-
pods: "ebbo"
44-
tag: ${{ secrets.AUTODEPLOY_TAG }}
45-
url: ${{ secrets.AUTODEPLOY_URL }}
46-
token: ${{ secrets.AUTODEPLOY_TOKEN }}

.github/workflows/pull_request.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v3
11-
- name: Setup Python 3.12
11+
- name: Setup Python 3.13
1212
uses: actions/setup-python@v3
1313
with:
14-
python-version: '3.12'
14+
python-version: '3.13'
1515
- name: Install Requirements
1616
run:
1717
pip install -r requirements.txt

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
FROM python:3.12
1+
FROM python:3.13-slim
22
COPY requirements.txt .
33
RUN python -m pip install -r requirements.txt
44
COPY . .
5-
CMD python -m src.daemon
5+
6+
ENTRYPOINT [ "python", "-m", "src.daemon" ]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ python-dotenv
88
requests
99
types-requests
1010
web3
11+
slack_sdk==3.34.0

src/daemon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" A daemon to run tests on settlements.
1+
"""A daemon to run tests on settlements.
22
An infinite loop is started which listens to CoW Protocol trade events. If such an event happens,
33
the correstonding transaction hash is added to the queue of the individual tests.
44

src/monitoring_tests/base_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
# pylint: disable=logging-fstring-interpolation
77

8+
import os
89
from abc import ABC, abstractmethod
10+
from slack_sdk import WebClient
911
from src.helper_functions import get_logger
1012

1113

@@ -20,6 +22,9 @@ def __init__(self) -> None:
2022
self.tx_hashes: list[str] = []
2123
self.logger = get_logger()
2224

25+
if "SLACK_BOT_TOKEN" in os.environ:
26+
self.slack_client = WebClient(token=os.environ["SLACK_BOT_TOKEN"])
27+
2328
@abstractmethod
2429
def run(self, tx_hash: str) -> bool:
2530
"""
@@ -58,3 +63,8 @@ def alert(self, msg: str) -> None:
5863
It must be implemented by all subclasses.
5964
"""
6065
self.logger.error(msg)
66+
67+
if self.slack_client:
68+
self.slack_client.chat_postMessage(
69+
channel=os.environ.get("SLACK_CHANNEL", "#alerts-ebbo"), text=msg
70+
)

0 commit comments

Comments
 (0)