feat(dependencies): switch to Poetry | chore(sentry): remove Sentry #418
@ -1,4 +1,2 @@
|
|||||||
APP_LIFECYCLE="dev"
|
APP_LIFECYCLE="dev"
|
||||||
SENTRY_ENABLED="False"
|
|
||||||
SENTRY_DSN=""
|
|
||||||
WEBEX_API_KEY=""
|
WEBEX_API_KEY=""
|
||||||
|
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -12,7 +12,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
uses: luketainton/gha-workflows/.github/workflows/ci-python-with-docker.yml@main
|
uses: luketainton/gha-workflows/.github/workflows/ci-python-poetry-with-docker.yml@main
|
||||||
secrets:
|
secrets:
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
||||||
|
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@ -5,6 +5,12 @@ on:
|
|||||||
- cron: "0 9 * * 0"
|
- cron: "0 9 * * 0"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
test:
|
||||||
|
uses: luketainton/gha-workflows/.github/workflows/ci-python-poetry-with-docker.yml@main
|
||||||
|
secrets:
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
||||||
|
|
||||||
create_release:
|
create_release:
|
||||||
name: Create Release
|
name: Create Release
|
||||||
uses: luketainton/gha-workflows/.github/workflows/create-release.yml@main
|
uses: luketainton/gha-workflows/.github/workflows/create-release.yml@main
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -133,3 +133,6 @@ dmypy.json
|
|||||||
# IDE
|
# IDE
|
||||||
.vscode
|
.vscode
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
# Ruff
|
||||||
|
.ruff_cache/
|
||||||
|
@ -8,10 +8,13 @@ WORKDIR /run
|
|||||||
|
|
||||||
RUN mkdir -p /.local && \
|
RUN mkdir -p /.local && \
|
||||||
chmod -R 777 /.local && \
|
chmod -R 777 /.local && \
|
||||||
pip install -U pip
|
pip install -U pip poetry
|
||||||
|
|
||||||
COPY requirements.txt /run/requirements.txt
|
COPY pyproject.toml /run/pyproject.toml
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
COPY poetry.lock /run/poetry.lock
|
||||||
|
|
||||||
|
RUN poetry config virtualenvs.create false && \
|
||||||
|
poetry install --without dev
|
||||||
|
|
||||||
ENTRYPOINT ["python3", "-B", "-m", "app.main"]
|
ENTRYPOINT ["python3", "-B", "-m", "app.main"]
|
||||||
|
|
||||||
|
@ -11,11 +11,6 @@ class Config:
|
|||||||
self.__environment: str = os.environ.get("APP_LIFECYCLE", "DEV").upper()
|
self.__environment: str = os.environ.get("APP_LIFECYCLE", "DEV").upper()
|
||||||
self.__version: str = os.environ["APP_VERSION"]
|
self.__version: str = os.environ["APP_VERSION"]
|
||||||
self.__webex_token: str = os.environ["WEBEX_API_KEY"]
|
self.__webex_token: str = os.environ["WEBEX_API_KEY"]
|
||||||
self.__sentry_dsn: str = os.environ.get("SENTRY_DSN", "")
|
|
||||||
self.__sentry_enabled: bool = bool(
|
|
||||||
os.environ.get("SENTRY_ENABLED", "False").upper() == "TRUE"
|
|
||||||
and self.__sentry_dsn != ""
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def environment(self) -> str:
|
def environment(self) -> str:
|
||||||
@ -27,19 +22,6 @@ class Config:
|
|||||||
"""Returns the current app version."""
|
"""Returns the current app version."""
|
||||||
return self.__version
|
return self.__version
|
||||||
|
|
||||||
@property
|
|
||||||
def sentry_enabled(self) -> bool:
|
|
||||||
"""Returns True if Sentry SDK is enabled, else False."""
|
|
||||||
return self.__sentry_enabled
|
|
||||||
|
|
||||||
@property
|
|
||||||
def sentry_dsn(self) -> str:
|
|
||||||
"""Returns the Sentry DSN value if Sentry SDK is enabled AND
|
|
||||||
Sentry DSN is set, else blank string."""
|
|
||||||
if not self.__sentry_enabled:
|
|
||||||
return ""
|
|
||||||
return self.__sentry_dsn
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def webex_token(self) -> str:
|
def webex_token(self) -> str:
|
||||||
"""Returns the Webex API key."""
|
"""Returns the Webex API key."""
|
||||||
|
@ -18,7 +18,7 @@ CHAR_REPLACEMENTS: list = [
|
|||||||
|
|
||||||
def get_templates() -> list[dict]:
|
def get_templates() -> list[dict]:
|
||||||
url: str = "https://api.memegen.link/templates"
|
url: str = "https://api.memegen.link/templates"
|
||||||
req: requests.Response = requests.get(url=url, timeout=5)
|
req: requests.Response = requests.get(url=url, timeout=10)
|
||||||
req.raise_for_status()
|
req.raise_for_status()
|
||||||
data: dict = req.json()
|
data: dict = req.json()
|
||||||
templates: list = []
|
templates: list = []
|
||||||
|
12
app/main.py
12
app/main.py
@ -1,22 +1,10 @@
|
|||||||
#!/usr/local/bin/python3
|
#!/usr/local/bin/python3
|
||||||
|
|
||||||
import sentry_sdk
|
|
||||||
from sentry_sdk.integrations.stdlib import StdlibIntegration
|
|
||||||
from webex_bot.webex_bot import WebexBot
|
from webex_bot.webex_bot import WebexBot
|
||||||
|
|
||||||
from app import close, meme
|
from app import close, meme
|
||||||
from app.config import config
|
from app.config import config
|
||||||
|
|
||||||
if config.sentry_enabled:
|
|
||||||
apm = sentry_sdk.init(
|
|
||||||
dsn=config.sentry_dsn,
|
|
||||||
enable_tracing=True,
|
|
||||||
environment=config.environment,
|
|
||||||
release=config.version,
|
|
||||||
integrations=[StdlibIntegration()],
|
|
||||||
spotlight=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def create_bot() -> WebexBot:
|
def create_bot() -> WebexBot:
|
||||||
"""Create a Bot object."""
|
"""Create a Bot object."""
|
||||||
|
69
poetry.lock
generated
69
poetry.lock
generated
@ -1,4 +1,4 @@
|
|||||||
# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
|
# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand.
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "astroid"
|
name = "astroid"
|
||||||
@ -390,20 +390,17 @@ files = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "isort"
|
name = "isort"
|
||||||
version = "5.12.0"
|
version = "5.13.2"
|
||||||
description = "A Python utility / library to sort Python imports."
|
description = "A Python utility / library to sort Python imports."
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8.0"
|
python-versions = ">=3.8.0"
|
||||||
files = [
|
files = [
|
||||||
{file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"},
|
{file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"},
|
||||||
{file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"},
|
{file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
colors = ["colorama (>=0.4.3)"]
|
colors = ["colorama (>=0.4.6)"]
|
||||||
pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"]
|
|
||||||
plugins = ["setuptools"]
|
|
||||||
requirements-deprecated-finder = ["pip-api", "pipreqs"]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mccabe"
|
name = "mccabe"
|
||||||
@ -784,60 +781,6 @@ files = [
|
|||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
requests = ">=2.0.1,<3.0.0"
|
requests = ">=2.0.1,<3.0.0"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sentry-sdk"
|
|
||||||
version = "2.19.0"
|
|
||||||
description = "Python client for Sentry (https://sentry.io)"
|
|
||||||
optional = false
|
|
||||||
python-versions = ">=3.6"
|
|
||||||
files = [
|
|
||||||
{file = "sentry_sdk-2.19.0-py2.py3-none-any.whl", hash = "sha256:7b0b3b709dee051337244a09a30dbf6e95afe0d34a1f8b430d45e0982a7c125b"},
|
|
||||||
{file = "sentry_sdk-2.19.0.tar.gz", hash = "sha256:ee4a4d2ae8bfe3cac012dcf3e4607975904c137e1738116549fc3dbbb6ff0e36"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[package.dependencies]
|
|
||||||
certifi = "*"
|
|
||||||
urllib3 = ">=1.26.11"
|
|
||||||
|
|
||||||
[package.extras]
|
|
||||||
aiohttp = ["aiohttp (>=3.5)"]
|
|
||||||
anthropic = ["anthropic (>=0.16)"]
|
|
||||||
arq = ["arq (>=0.23)"]
|
|
||||||
asyncpg = ["asyncpg (>=0.23)"]
|
|
||||||
beam = ["apache-beam (>=2.12)"]
|
|
||||||
bottle = ["bottle (>=0.12.13)"]
|
|
||||||
celery = ["celery (>=3)"]
|
|
||||||
celery-redbeat = ["celery-redbeat (>=2)"]
|
|
||||||
chalice = ["chalice (>=1.16.0)"]
|
|
||||||
clickhouse-driver = ["clickhouse-driver (>=0.2.0)"]
|
|
||||||
django = ["django (>=1.8)"]
|
|
||||||
falcon = ["falcon (>=1.4)"]
|
|
||||||
fastapi = ["fastapi (>=0.79.0)"]
|
|
||||||
flask = ["blinker (>=1.1)", "flask (>=0.11)", "markupsafe"]
|
|
||||||
grpcio = ["grpcio (>=1.21.1)", "protobuf (>=3.8.0)"]
|
|
||||||
http2 = ["httpcore[http2] (==1.*)"]
|
|
||||||
httpx = ["httpx (>=0.16.0)"]
|
|
||||||
huey = ["huey (>=2)"]
|
|
||||||
huggingface-hub = ["huggingface_hub (>=0.22)"]
|
|
||||||
langchain = ["langchain (>=0.0.210)"]
|
|
||||||
launchdarkly = ["launchdarkly-server-sdk (>=9.8.0)"]
|
|
||||||
litestar = ["litestar (>=2.0.0)"]
|
|
||||||
loguru = ["loguru (>=0.5)"]
|
|
||||||
openai = ["openai (>=1.0.0)", "tiktoken (>=0.3.0)"]
|
|
||||||
openfeature = ["openfeature-sdk (>=0.7.1)"]
|
|
||||||
opentelemetry = ["opentelemetry-distro (>=0.35b0)"]
|
|
||||||
opentelemetry-experimental = ["opentelemetry-distro"]
|
|
||||||
pure-eval = ["asttokens", "executing", "pure_eval"]
|
|
||||||
pymongo = ["pymongo (>=3.1)"]
|
|
||||||
pyspark = ["pyspark (>=2.4.4)"]
|
|
||||||
quart = ["blinker (>=1.1)", "quart (>=0.16.1)"]
|
|
||||||
rq = ["rq (>=0.6)"]
|
|
||||||
sanic = ["sanic (>=0.8)"]
|
|
||||||
sqlalchemy = ["sqlalchemy (>=1.2)"]
|
|
||||||
starlette = ["starlette (>=0.19.1)"]
|
|
||||||
starlite = ["starlite (>=1.48)"]
|
|
||||||
tornado = ["tornado (>=6)"]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "setuptools"
|
name = "setuptools"
|
||||||
version = "68.0.0"
|
version = "68.0.0"
|
||||||
@ -1021,4 +964,4 @@ files = [
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.11.2"
|
python-versions = "^3.11.2"
|
||||||
content-hash = "f7823bb3d889bedb7b2edccc56ba8169403af44b0e5d17925cee1e42445ccb5c"
|
content-hash = "3bf64765123ffdd88b19d2ddaa5cd4a40370e4e635cd22164065e4cc583aae20"
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "webexmemebot"
|
name = "webexmemebot"
|
||||||
version = "0.1.0"
|
version = "0.0.0" # Version is tracked by GitHub Releases
|
||||||
description = "Webex-based meme generation bot using memegen.link."
|
description = "Webex-based meme generation bot using memegen.link."
|
||||||
authors = ["luketainton"]
|
authors = ["luketainton"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
package-mode = false
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.11.2"
|
python = "^3.11.2"
|
||||||
webex-bot = "^0.5.2"
|
webex-bot = "^0.5.2"
|
||||||
pillow = "^11.0.0"
|
pillow = "^11.0.0"
|
||||||
sentry-sdk = "^2.19.0"
|
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
black = "^24.10.0"
|
black = "^24.10.0"
|
||||||
coverage = "^7.6.8"
|
coverage = "^7.6.8"
|
||||||
|
isort = "^5.13.2"
|
||||||
pylint = "^3.2.6"
|
pylint = "^3.2.6"
|
||||||
pylint-exit = "^1.2.0"
|
pylint-exit = "^1.2.0"
|
||||||
pytest = "^8.3.3"
|
pytest = "^8.3.3"
|
||||||
|
@ -5,8 +5,6 @@ import os
|
|||||||
vars: dict = {
|
vars: dict = {
|
||||||
"APP_VERSION": "dev",
|
"APP_VERSION": "dev",
|
||||||
"WEBEX_API_KEY": "testing",
|
"WEBEX_API_KEY": "testing",
|
||||||
"SENTRY_ENABLED": "false",
|
|
||||||
"SENTRY_DSN": "http://localhost",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -20,4 +18,3 @@ from app.config import config # pragma: no cover # noqa: E402
|
|||||||
def test_config() -> None:
|
def test_config() -> None:
|
||||||
assert config.webex_token == vars["WEBEX_API_KEY"]
|
assert config.webex_token == vars["WEBEX_API_KEY"]
|
||||||
assert config.version == vars["APP_VERSION"]
|
assert config.version == vars["APP_VERSION"]
|
||||||
assert config.sentry_enabled == bool(vars["SENTRY_ENABLED"].lower() == "true")
|
|
||||||
|
Loading…
Reference in New Issue
Block a user