Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .flake8
Comment thread
Sheikah45 marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 100
extend-ignore = E231
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.13'

- name: Install dependencies with pipenv
run: |
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.13'

- name: Install dependencies
run: pip install isort
Expand All @@ -33,12 +33,12 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.13'

- uses: TrueBrain/actions-flake8@v2
with:
flake8_version: 6.0.0
plugins: flake8-quotes~=3.3
flake8_version: 7.3.0
plugins: flake8-quotes~=3.4

mypy:
runs-on: ubuntu-latest
Expand All @@ -47,13 +47,13 @@ jobs:

- name: Create requirements file
run: |
pip install pipenv==2024.4.1
pip install pipenv==2025.0.4
pipenv requirements --dev > requirements.txt

# Mypy-check runs inside its own docker image
- uses: jpetrucciani/mypy-check@master
with:
python_version: '3.10'
python_version: '3.13'
requirements: |
types-PyYAML
types-PyMySQL
Expand All @@ -75,7 +75,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.13'

- name: Install dependencies
run: pip install pipenv
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.13'

- name: Run flyway db migrations
env:
Expand Down
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
rev: 7.3.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.7
args: ["--config=.flake8"]
Comment thread
Sheikah45 marked this conversation as resolved.
Outdated
- repo: https://github.com/hhatto/autopep8
Comment thread
Sheikah45 marked this conversation as resolved.
Outdated
rev: v2.3.2
hooks:
- id: autopep8
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
rev: 6.0.1
hooks:
- id: isort
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
###############
# Build image #
###############
FROM python:3.10-slim as builder
FROM python:3.13-slim as builder

# Need git for installing aiomysql
RUN apt-get update
RUN apt-get install -y --no-install-recommends git

RUN pip install pipenv==2023.4.20
RUN pip install pipenv==2025.0.4

WORKDIR /code/

Expand All @@ -22,7 +22,7 @@ RUN PIPENV_VENV_IN_PROJECT=1 pipenv run pip install .
#################
# Runtime image #
#################
FROM python:3.10-slim
FROM python:3.13-slim

ARG GITHUB_REF
ENV VERSION=$GITHUB_REF
Expand Down
9 changes: 5 additions & 4 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ sortedcontainers = "*"
sqlalchemy = ">=2.0.0"
trueskill = "*"
uvloop = {version = "*", markers = "sys_platform != 'win32'"}
tzdata = "*"
Comment thread
Sheikah45 marked this conversation as resolved.

[dev-packages]
flaky = "*"
hypothesis = "*" # Versions between 6.47.1 and 6.56.4 added a prerelease dependency. See https://github.com/pypa/pipenv/issues/1760
pdoc3 = "*"
vulture = "*"
websockets = "*"
pytest-asyncio = "*"
Comment thread
Sheikah45 marked this conversation as resolved.
Outdated
pytest = "*"
pytest-asyncio = "~=0.21.0"
pytest-cov = "*"
pytest-mock = "*"
vulture = "*"
websockets = "*"

[requires]
python_version = "3.10"
python_version = "3.13"
1,382 changes: 699 additions & 683 deletions Pipfile.lock

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
services:
# Set up the faf db
faf-db:
image: mariadb:11
environment:
MARIADB_DATABASE: faf
MARIADB_USER: faf-api
MARIADB_PASSWORD: banana
MARIADB_ROOT_PASSWORD: banana
healthcheck:
test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ]
interval: 10s
timeout: 5s
retries: 5
ports:
- "3306:3306"

faf-db-migrations:
image: faforever/faf-db-migrations:v138
command: migrate
environment:
FLYWAY_URL: jdbc:mysql://faf-db/faf?useSSL=false
FLYWAY_USER: root
FLYWAY_PASSWORD: banana
FLYWAY_DATABASE: faf
depends_on:
faf-db:
condition: service_healthy

faf-db-testdata:
image: mariadb:11
entrypoint: sh -c "apt-get update && apt-get install -y curl && curl -s https://raw.githubusercontent.com/FAForever/db/refs/heads/develop/test-data.sql | mariadb -h faf-db -uroot -pbanana -D faf"
depends_on:
faf-db-migrations:
condition: service_completed_successfully

rabbitmq:
image: rabbitmq:3.13-management
environment:
RABBITMQ_DEFAULT_VHOST: /faf-core
RABBITMQ_DEFAULT_USER: faf-python-server
RABBITMQ_DEFAULT_PASS: banana
ports:
- "5672:5672"
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def wrapped(sig, frame):


async def main():
global startup_time, shutdown_time
global shutdown_time

logger.info(
"Lobby %s (Python %s) on %s named %s",
Expand Down
44 changes: 22 additions & 22 deletions server/gameconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,26 +637,26 @@ def __str__(self):


COMMAND_HANDLERS = {
"AIOption": GameConnection.handle_ai_option,
"Bottleneck": GameConnection.handle_bottleneck,
"BottleneckCleared": GameConnection.handle_bottleneck_cleared,
"Chat": GameConnection.handle_chat,
"ClearSlot": GameConnection.handle_clear_slot,
"Desync": GameConnection.handle_desync,
"Disconnected": GameConnection.handle_disconnected,
"EnforceRating": GameConnection.handle_enforce_rating,
"GameEnded": GameConnection.handle_game_ended,
"GameFull": GameConnection.handle_game_full,
"GameMods": GameConnection.handle_game_mods,
"GameOption": GameConnection.handle_game_option,
"GameResult": GameConnection.handle_game_result,
"GameState": GameConnection.handle_game_state,
"IceMsg": GameConnection.handle_ice_message,
"JsonStats": GameConnection.handle_json_stats,
"LaunchStatus": GameConnection.handle_launch_status,
"OperationComplete": GameConnection.handle_operation_complete,
"PlayerOption": GameConnection.handle_player_option,
"Rehost": GameConnection.handle_rehost,
"TeamkillHappened": GameConnection.handle_teamkill_happened,
"TeamkillReport": GameConnection.handle_teamkill_report,
"AIOption": GameConnection.handle_ai_option,
Comment thread
Sheikah45 marked this conversation as resolved.
Outdated
"Bottleneck": GameConnection.handle_bottleneck,
"BottleneckCleared": GameConnection.handle_bottleneck_cleared,
"Chat": GameConnection.handle_chat,
"ClearSlot": GameConnection.handle_clear_slot,
"Desync": GameConnection.handle_desync,
"Disconnected": GameConnection.handle_disconnected,
"EnforceRating": GameConnection.handle_enforce_rating,
"GameEnded": GameConnection.handle_game_ended,
"GameFull": GameConnection.handle_game_full,
"GameMods": GameConnection.handle_game_mods,
"GameOption": GameConnection.handle_game_option,
"GameResult": GameConnection.handle_game_result,
"GameState": GameConnection.handle_game_state,
"IceMsg": GameConnection.handle_ice_message,
"JsonStats": GameConnection.handle_json_stats,
"LaunchStatus": GameConnection.handle_launch_status,
"OperationComplete": GameConnection.handle_operation_complete,
"PlayerOption": GameConnection.handle_player_option,
"Rehost": GameConnection.handle_rehost,
"TeamkillHappened": GameConnection.handle_teamkill_happened,
"TeamkillReport": GameConnection.handle_teamkill_report,
}
5 changes: 4 additions & 1 deletion server/lobbyconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,10 @@ async def command_modvault(self, message):
ui=ui)
await self.send(out)
except Exception:
self._logger.error(f"Error handling table_mod row (uid: {uid})", exc_info=True)
self._logger.error(
f"Error handling table_mod row (uid: {uid})",
exc_info=True
)

elif type == "like":
canLike = True
Expand Down
1 change: 1 addition & 0 deletions server/protocol/gpgnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class GpgNetServerProtocol(metaclass=ABCMeta):
"""
Defines an interface for the server side GPGNet protocol
"""

Comment thread
Sheikah45 marked this conversation as resolved.
Outdated
async def send_ConnectToPeer(self, player_name: str, player_uid: int, offer: bool):
"""
Tells a client that has a listening LobbyComm instance to connect to the
Expand Down
4 changes: 0 additions & 4 deletions tests/unit_tests/test_game_rating.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,12 @@ async def rating_service(database, player_service):
mock_ratings = defaultdict(dict)

def set_mock_rating(player_id, rating_type, rating):
nonlocal mock_ratings
nonlocal mock_service
mock_service._logger.debug(
f"Set mock {rating_type} rating for player {player_id}: {rating}"
)
mock_ratings[player_id][rating_type] = rating

def get_mock_ratings(conn, player_ids, **kwargs):
nonlocal mock_ratings
nonlocal mock_service
player_ratings = {
player_id: PlayerRatings(mock_service.leaderboards, init=False)
for player_id in player_ids
Expand Down
Loading