diff --git a/Dockerfile b/Dockerfile index c2a9724..d8b60d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,11 @@ -FROM python:3.7 +FROM python:3.10 -RUN pip install "PyGithub>=1.55,<2.0" "pydantic>=v1.8.2,<2.0" +COPY ./requirements.txt /code/requirements.txt -COPY ./app /app +RUN pip install -r /code/requirements.txt -CMD ["python", "/app/main.py"] +COPY ./app /code/app + +ENV PYTHONPATH=/code/app + +CMD ["python", "/code/app/main.py"] diff --git a/app/main.py b/app/main.py index 18703af..4a5ea63 100644 --- a/app/main.py +++ b/app/main.py @@ -1,4 +1,4 @@ -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone import logging from pathlib import Path from typing import Dict, List, Optional, Set @@ -7,7 +7,8 @@ from github.Issue import Issue from github.IssueComment import IssueComment from github.IssueEvent import IssueEvent -from pydantic import BaseModel, BaseSettings, SecretStr, validator +from pydantic import BaseModel, SecretStr, validator +from pydantic_settings import BaseSettings class KeywordMeta(BaseModel): @@ -92,11 +93,12 @@ def process_issue(*, issue: Issue, settings: Settings) -> None: events = list(issue.get_events()) labeled_events = get_labeled_events(events) last_comment = get_last_comment(issue) + now = datetime.now(timezone.utc) for keyword, keyword_meta in settings.input_config.items(): # Check closable delay, if enough time passed and the issue could be closed closable_delay = ( last_comment is None - or (datetime.utcnow() - keyword_meta.delay) > last_comment.created_at + or (now - keyword_meta.delay) > last_comment.created_at ) # Check label, optionally removing it if there's a comment after adding it if keyword in label_strs: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..65e67cf --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +PyGithub +pydantic>=2.5.3,<3.0.0 +pydantic-settings>=2.1.0,<3.0.0