Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] make APPROVALS_REQUIRED configurable #107

Merged
merged 3 commits into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions environment.sample
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ ODOO_PASSWORD=

#SENTRY_DSN=

# Number of approvals to have the proposal marked as "Approved"
#APPROVALS_REQUIRED=2
# Number of days before the proposal can be marked as "Approved"
#MIN_PR_AGE=5

# Coma separated list of task to run
# By default all configured tasks are run.
# Available tasks:
Expand Down
1 change: 1 addition & 0 deletions newsfragments/107.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``APPROVALS_REQUIRED`` and ``MIN_PR_AGE`` configuration options to control the conditions to set the ``Approved`` label.
3 changes: 3 additions & 0 deletions src/oca_github_bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,7 @@ def func_wrapper(*args, **kwargs):
"What a great day to merge this nice PR. Let's do it!",
]

APPROVALS_REQUIRED = int(os.environ.get("APPROVALS_REQUIRED", "2"))
MIN_PR_AGE = int(os.environ.get("MIN_PR_AGE", "5"))

SIMPLE_INDEX_ROOT = os.environ.get("SIMPLE_INDEX_ROOT")
3 changes: 1 addition & 2 deletions src/oca_github_bot/tasks/tag_approved.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
from collections import defaultdict

from .. import github
from ..config import switchable
from ..config import APPROVALS_REQUIRED, switchable
from ..github import gh_call
from ..queue import getLogger, task
from .tag_ready_to_merge import LABEL_READY_TO_MERGE, tag_ready_to_merge

_logger = getLogger(__name__)

APPROVALS_REQUIRED = 2
LABEL_APPROVED = "approved"


Expand Down
5 changes: 2 additions & 3 deletions src/oca_github_bot/tasks/tag_ready_to_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
from datetime import datetime, timedelta

from .. import github
from ..config import switchable
from ..config import MIN_PR_AGE, switchable
from ..github import gh_call, gh_datetime
from ..queue import getLogger, task

_logger = getLogger(__name__)


MIN_PR_AGE = timedelta(days=5)
LABEL_READY_TO_MERGE = "ready to merge"
READY_TO_MERGE_COMMENT = (
"This PR has the `approved` label and "
Expand All @@ -27,7 +26,7 @@
def tag_ready_to_merge(org, repo=None, dry_run=False):
"""Add the ``ready to merge`` tag to all PRs where conditions are met."""
with github.login() as gh:
max_created = datetime.utcnow() - MIN_PR_AGE
max_created = datetime.utcnow() - timedelta(days=MIN_PR_AGE)
query = [
"type:pr",
"state:open",
Expand Down