Skip to content

Commit 531993d

Browse files
authored
Merge pull request #110 from JTJag/chore/add-precommit-config
chore: add pre-commit hooks and document contribution workflow
2 parents 4bc4d2d + b0469eb commit 531993d

11 files changed

Lines changed: 234 additions & 11 deletions

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ jobs:
4343
run: docker compose config
4444

4545
- name: Build Compose services
46-
run: docker compose build
46+
run: docker compose build

.github/workflows/python-lint-format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
3535
- name: Check formatting with Black
3636
run: |
37-
black --check .
37+
black --check .

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@ test_issues_report.md
198198
test_upload.txt
199199
test_voice.ogg
200200
sticker.webp
201-
two.png
201+
two.png

.pre-commit-config.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 25.9.0
4+
hooks:
5+
- id: black
6+
language_version: python3
7+
8+
- repo: https://github.com/pycqa/flake8
9+
rev: 7.3.0
10+
hooks:
11+
- id: flake8
12+
args: ["--count", "--select=E9,F63,F7,F82", "--show-source", "--statistics"]
13+
14+
- repo: https://github.com/pre-commit/pre-commit-hooks
15+
rev: v5.0.0
16+
hooks:
17+
- id: end-of-file-fixer
18+
- id: trailing-whitespace
19+
- id: check-merge-conflict
20+
21+
- repo: https://github.com/hadolint/hadolint
22+
rev: v2.12.0
23+
hooks:
24+
- id: hadolint-docker
25+
args: ["--failure-threshold", "error", "Dockerfile"]
26+
27+
- repo: local
28+
hooks:
29+
- id: docker-compose-config
30+
name: docker compose config
31+
entry: docker compose --env-file .env.example config
32+
language: system
33+
pass_filenames: false
34+
stages: [pre-commit]
35+
- id: docker-build-ci
36+
name: docker build (ci parity)
37+
entry: docker build --file Dockerfile --tag telegram-mcp:ci .
38+
language: system
39+
pass_filenames: false
40+
stages: [pre-push]

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ ENV TELEGRAM_SESSION_STRING=""
4444
# EXPOSE 8000
4545

4646
# Define the command to run the application
47-
CMD ["python", "main.py"]
47+
CMD ["python", "main.py"]

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,15 @@ Telegram messages, display names, chat titles, and button labels are untrusted c
289289
## Contributing
290290

291291
1. Fork and clone the repository.
292-
2. Create a focused branch.
293-
3. Add or update tests when behavior changes.
294-
4. Run formatting, tests, and coverage locally.
295-
5. Open a pull request with a concise description.
292+
2. Install dependencies and git hooks:
293+
- `uv sync`
294+
- `uv run pre-commit install --hook-type pre-commit --hook-type pre-push`
295+
3. Create a focused branch.
296+
4. Add or update tests when behavior changes.
297+
5. Run checks locally:
298+
- `uv run pre-commit run --all-files`
299+
- `uv run pre-commit run --hook-stage pre-push --all-files`
300+
6. Open a pull request with a concise description.
296301

297302
## License
298303

claude_desktop_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
]
1111
}
1212
}
13-
}
13+
}

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ services:
1717
# Replace './telegram_sessions' with your desired host path.
1818
# volumes:
1919
# - ./telegram_sessions:/app
20-
restart: unless-stopped
20+
restart: unless-stopped

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ exclude = [
6666
dev = [
6767
"black>=25.9.0",
6868
"flake8>=7.3.0",
69+
"pre-commit>=4.6.0",
6970
"pytest>=9.0.2",
7071
"pytest-asyncio>=1.3.0",
7172
"pytest-cov>=6.0.0",

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ nest-asyncio>=1.6.0
55
python-dotenv>=1.1.0
66
python-json-logger>=3.3.0
77
qrcode>=8.2
8-
telethon>=1.42.0
8+
telethon>=1.42.0

0 commit comments

Comments
 (0)