Skip to content

Commit 97b10d8

Browse files
authored
✨ Refactor configuration handling and add rest-bot support (#96)
* ✨ Refactor configuration handling and add rest-bot support * ♻️ Fix optional fields in BotConfig and Config models; improve module validation * ⬆️ Update CI-CD workflow to deploy only on push to dev branch
1 parent 420e554 commit 97b10d8

File tree

16 files changed

+346
-154
lines changed

16 files changed

+346
-154
lines changed

.github/workflows/CI-CD.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
uses: ./.github/workflows/docker.yaml
2727

2828
deploy:
29+
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
2930
needs: docker
3031
uses: ./.github/workflows/deploy.yaml
3132
secrets: inherit

.github/workflows/license.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/quality.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: "Lint Check"
1818
command: "pdm run ruff check ."
1919
- check: test
20-
name: "Run Tests"
20+
name: "Tests Check"
2121
command: "pdm run tests"
2222

2323
name: ${{ matrix.name }}
@@ -34,4 +34,15 @@ jobs:
3434
run: pdm install -d
3535

3636
- name: ${{ matrix.name }}
37-
run: ${{ matrix.command }}
37+
run: ${{ matrix.command }}
38+
39+
check-license-header:
40+
name: License Header Check
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
- name: Setup Copywrite
46+
uses: hashicorp/setup-copywrite@5e3e8a26d7b9f8a508848ad0a069dfd2f7aa5339
47+
- name: Check Header Compliance
48+
run: copywrite headers --plan --config .copywrite.hcl

.github/workflows/sync_template.yaml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
exclude: \.(po|pot|yml|yaml)$
2222
- repo: https://github.com/astral-sh/ruff-pre-commit
2323
# Ruff version.
24-
rev: v0.9.4
24+
rev: v0.9.10
2525
hooks:
2626
# Run the linter.
2727
- id: ruff

pdm.lock

Lines changed: 126 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ dependencies = [
1616
"schema>=0.7.7",
1717
"hypercorn>=0.17.3",
1818
"quart>=0.19.6",
19-
"pydantic>=2.9.2",
19+
"pydantic>=2.10.6",
2020
"coloredlogs>=15.0.1",
2121
"aiofile>=3.9.0",
2222
"sentry-sdk>=2.18.0",
2323
"aiocache[redis]>=0.12.3",
2424
"tortoise-orm[asyncpg]>=0.23.0",
2525
"aerich[toml]>=0.8.1",
26+
"pycord-rest-bot>=0.1.0a7",
2627
]
2728
requires-python = "==3.12.*"
2829
readme = "README.md"

src/config/bot_config.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import yaml
1010
from dotenv import load_dotenv
1111

12+
from .models import Config
13+
1214
load_dotenv()
1315

1416
SPLIT: str = "__"
@@ -59,10 +61,12 @@ def load_json_recursive(data: dict[str, Any]) -> dict[str, Any]:
5961
elif os.path.exists("config.yml"):
6062
path = "config.yml"
6163

62-
config: dict[str, dict[str, Any]]
64+
_config: Any
65+
config: Config
6366
if path:
64-
# noinspection PyArgumentEqualDefault
6567
with open(path, encoding="utf-8") as f:
66-
config = yaml.safe_load(f)
68+
_config = yaml.safe_load(f)
6769
else:
68-
config = load_from_env()
70+
_config = load_from_env()
71+
72+
config = Config(**_config) if _config else Config()

0 commit comments

Comments
 (0)