Skip to content

Commit 431b7fb

Browse files
authored
Merge pull request #64 from emptybutton/dev
Pull `0.5.0`v
2 parents 3cf7d98 + 3e246a9 commit 431b7fb

File tree

200 files changed

+4644
-2587
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+4644
-2587
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,24 @@ jobs:
88
steps:
99
- uses: actions/checkout@v4
1010

11-
- name: add secrets
12-
run: |
13-
echo "bot_token: ${{ secrets.BOT_TOKEN }}" > deploy/dev/ttt/secrets.yaml
14-
echo "payments_token: ${{ secrets.PAYMENTS_TOKEN }}" >> deploy/dev/ttt/secrets.yaml
15-
echo "gemini_api_key: ${{ secrets.GEMINI_API_KEY }}" >> deploy/dev/ttt/secrets.yaml
16-
echo "sentry_dsn: ${{ secrets.SENTRY_DSN }}" >> deploy/dev/ttt/secrets.yaml
11+
- name: install ruff
12+
run: curl -LsSf https://astral.sh/ruff/0.13.0/install.sh | sh
1713

1814
- name: ruff
19-
run: docker compose -f deploy/dev/docker-compose.yaml run ttt ruff check src tests
15+
run: ruff check src tests
2016

2117
mypy:
2218
runs-on: ubuntu-latest
2319
steps:
2420
- uses: actions/checkout@v4
2521

26-
- name: add secrets
22+
- name: install dependencies
2723
run: |
28-
echo "bot_token: ${{ secrets.BOT_TOKEN }}" > deploy/dev/ttt/secrets.yaml
29-
echo "payments_token: ${{ secrets.PAYMENTS_TOKEN }}" >> deploy/dev/ttt/secrets.yaml
30-
echo "gemini_api_key: ${{ secrets.GEMINI_API_KEY }}" >> deploy/dev/ttt/secrets.yaml
31-
echo "sentry_dsn: ${{ secrets.SENTRY_DSN }}" >> deploy/dev/ttt/secrets.yaml
24+
curl -LsSf https://astral.sh/uv/install.sh | sh
25+
uv sync
3226
3327
- name: mypy
34-
run: docker compose -f deploy/dev/docker-compose.yaml run ttt mypy src tests
28+
run: uv run mypy src tests
3529

3630
pytest:
3731
runs-on: ubuntu-latest
@@ -44,6 +38,7 @@ jobs:
4438
echo "payments_token: ${{ secrets.PAYMENTS_TOKEN }}" >> deploy/dev/ttt/secrets.yaml
4539
echo "gemini_api_key: ${{ secrets.GEMINI_API_KEY }}" >> deploy/dev/ttt/secrets.yaml
4640
echo "sentry_dsn: ${{ secrets.SENTRY_DSN }}" >> deploy/dev/ttt/secrets.yaml
41+
echo "sentry_dsn: ${{ secrets.ADMIN_TOKEN }}" >> deploy/dev/ttt/secrets.yaml
4742
4843
- name: pytest
4944
run: docker compose -f deploy/dev/docker-compose.yaml run ttt pytest tests --cov --cov-report=xml

deploy/dev/docker-compose.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ services:
3535
TTT_NATS_URL: nats://nats:4222
3636

3737
TTT_GEMINI_URL: https://my-openai-gemini-sigma-sandy.vercel.app
38+
39+
TTT_DIALOG_TTL: 259200 # 3 days
40+
41+
TTT_MATCHMAKING_MAX_WORKERS: 4
42+
TTT_MATCHMAKING_WORKER_MAX_USERS: 100
43+
TTT_MATCHMAKING_WORKER_CREATION_INTERVAL_SECONDS: 0.5
44+
45+
TTT_AUTO_CANCEL_INVITATIONS_TO_GAME_INTERVAL_SECONDS: 1
46+
47+
TTT_SERIALIZATION_ERROR_MAX_RETRIES: 10
3848
secrets:
3949
- secrets
4050
command: ttt-dev
@@ -84,15 +94,16 @@ services:
8494
interval: 3s
8595

8696
nats_streams:
87-
image: bitnami/natscli:0.2.3-debian-12-r4
97+
image: n255/natscli:0.3.0-bookworm-slim
8898
container_name: ttt-nats-streams
8999
depends_on:
90100
nats:
91101
condition: service_healthy
92102
volumes:
93103
- ./nats:/mnt
94-
entrypoint: [""]
95104
command: ["bash", "/mnt/add_streams.sh"]
105+
environment:
106+
NATS_URL: nats://nats:4222
96107

97108
volumes:
98109
backend-data:

deploy/dev/nats/add_streams.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

3-
nats -s nats://nats:4222 stream add --config /mnt/streams/user.json
3+
for stream_config_file in `ls -lx /mnt/streams`; do
4+
nats stream add --config /mnt/streams/$stream_config_file
5+
done

deploy/dev/nats/streams/game.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "GAME",
3+
"subjects": ["game.>"],
4+
"retention": "limits",
5+
"max_consumers": -1,
6+
"max_msgs": -1,
7+
"max_bytes": -1,
8+
"max_age": 31536000000000000,
9+
"max_msg_size": -1,
10+
"storage": "file",
11+
"discard": "old",
12+
"num_replicas": 1,
13+
"duplicate_window": 0
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "STARS_PURCHASE",
3+
"subjects": ["stars_purchase.>"],
4+
"retention": "limits",
5+
"max_consumers": -1,
6+
"max_msgs": -1,
7+
"max_bytes": -1,
8+
"max_age": 31536000000000000,
9+
"max_msg_size": -1,
10+
"storage": "file",
11+
"discard": "old",
12+
"num_replicas": 1,
13+
"duplicate_window": 0
14+
}

deploy/prod/docker-compose.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ services:
3535
TTT_NATS_URL: nats://${NATS_TOKEN}@nats:4222
3636

3737
TTT_GEMINI_URL: ${GEMINI_URL}
38+
39+
TTT_DIALOG_TTL: 259200 # 3 days
40+
41+
TTT_MATCHMAKING_MAX_WORKERS: 4
42+
TTT_MATCHMAKING_WORKER_MAX_USERS: 100
43+
TTT_MATCHMAKING_WORKER_CREATION_INTERVAL_SECONDS: 0.5
44+
45+
TTT_AUTO_CANCEL_INVITATIONS_TO_GAME_INTERVAL_SECONDS: 1
46+
47+
TTT_SERIALIZATION_ERROR_MAX_RETRIES: 10
3848
secrets:
3949
- secrets
4050
networks:
@@ -138,7 +148,7 @@ services:
138148
interval: 3s
139149

140150
nats_streams:
141-
image: bitnami/natscli:0.2.3-debian-12-r4
151+
image: n255/natscli:0.3.0-bookworm-slim
142152
container_name: ttt-nats-streams
143153
depends_on:
144154
nats:
@@ -148,8 +158,8 @@ services:
148158
networks:
149159
- nats
150160
environment:
161+
NATS_URL: nats://nats:4222
151162
NATS_TOKEN: ${NATS_TOKEN}
152-
entrypoint: [""]
153163
command: ["bash", "/mnt/add_streams.sh"]
154164

155165
volumes:

deploy/prod/nats/add_streams.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

3-
nats -s nats://nats:4222 stream add --config /mnt/streams/user.json
3+
for stream_config_file in `ls -lx /mnt/streams`; do
4+
nats stream add --config /mnt/streams/$stream_config_file
5+
done

deploy/prod/nats/streams/game.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "GAME",
3+
"subjects": ["game.>"],
4+
"retention": "limits",
5+
"max_consumers": -1,
6+
"max_msgs": -1,
7+
"max_bytes": -1,
8+
"max_age": 31536000000000000,
9+
"max_msg_size": -1,
10+
"storage": "file",
11+
"discard": "old",
12+
"num_replicas": 1,
13+
"duplicate_window": 0
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "STARS_PURCHASE",
3+
"subjects": ["stars_purchase.>"],
4+
"retention": "limits",
5+
"max_consumers": -1,
6+
"max_msgs": -1,
7+
"max_bytes": -1,
8+
"max_age": 31536000000000000,
9+
"max_msg_size": -1,
10+
"storage": "file",
11+
"discard": "old",
12+
"num_replicas": 1,
13+
"duplicate_window": 0
14+
}

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ttt"
3-
version = "0.4.2"
3+
version = "0.5.0"
44
description = "Tic-Tac-Toe Telegram Bot"
55
authors = [
66
{name = "Alexander Smolin", email = "[email protected]"}
@@ -29,13 +29,13 @@ dependencies = [
2929

3030
[dependency-groups]
3131
dev = [
32-
"mypy[faster-cache]==1.16.0",
33-
"ruff==0.11.13",
32+
"mypy[faster-cache]==1.18.1",
33+
"ruff==0.13.0",
3434
"pytest==8.4.0",
3535
"pytest-cov==6.1.1",
3636
"pytest-asyncio==1.0.0",
3737
"dirty-equals==0.9.0",
38-
"better-exceptions==0.3.3",
38+
"rich==14.1.0",
3939
]
4040

4141
[project.urls]
@@ -111,6 +111,7 @@ ignore = [
111111
"EM101",
112112
"N807",
113113
"FURB118",
114+
"DOC402",
114115
]
115116

116117
[tool.ruff.lint.per-file-ignores]

0 commit comments

Comments
 (0)