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

pw_poller: make list module configurable #46

Merged
merged 1 commit into from
Feb 26, 2025
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
3 changes: 3 additions & 0 deletions netdev/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
series_tree_name_should_be_local, \
series_is_a_fix_for, \
series_needs_async

current_tree = 'net'
next_tree = 'net-next'
28 changes: 16 additions & 12 deletions pw_poller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import time
import queue
from typing import Dict
from importlib import import_module

from core import NIPA_DIR
from core import NipaLifetime
Expand All @@ -21,7 +22,6 @@
from pw import Patchwork
from pw import PwSeries
import core
import netdev


class IncompleteSeries(Exception):
Expand Down Expand Up @@ -80,6 +80,9 @@ def __init__(self, config) -> None:
self._recheck_period = config.getint('poller', 'recheck_period', fallback=3)
self._recheck_lookback = config.getint('poller', 'recheck_lookback', fallback=9)

listmodname = config.get('list', 'module', fallback='netdev')
self.list_module = import_module(listmodname)

def init_state_from_disk(self) -> None:
try:
with open('poller.state', 'r') as f:
Expand All @@ -91,28 +94,28 @@ def init_state_from_disk(self) -> None:
pass

def _series_determine_tree(self, s: PwSeries) -> str:
s.tree_name = netdev.series_tree_name_direct(s)
s.tree_name = self.list_module.series_tree_name_direct(s)
s.tree_mark_expected = True
s.tree_marked = bool(s.tree_name)

if s.is_pure_pull():
if s.title.find('-next') >= 0:
s.tree_name = 'net-next'
s.tree_name = self.list_module.next_tree
else:
s.tree_name = 'net'
s.tree_name = self.list_module.current_tree
s.tree_mark_expected = None
return f"Pull request for {s.tree_name}"

if s.tree_name:
log(f'Series is clearly designated for: {s.tree_name}', "")
return f"Clearly marked for {s.tree_name}"

s.tree_mark_expected, should_test = netdev.series_tree_name_should_be_local(s)
s.tree_mark_expected, should_test = self.list_module.series_tree_name_should_be_local(s)
if not should_test:
log("No tree designation found or guessed", "")
return "Not a local patch"

if netdev.series_ignore_missing_tree_name(s):
if self.list_module.series_ignore_missing_tree_name(s):
s.tree_mark_expected = None
log('Okay to ignore lack of tree in subject, ignoring series', "")
return "Series ignored based on subject"
Expand All @@ -122,11 +125,12 @@ def _series_determine_tree(self, s: PwSeries) -> str:
else:
log_open_sec('Series okay without a tree designation')

# TODO: make this configurable
if "net" in self._trees and netdev.series_is_a_fix_for(s, self._trees["net"]):
s.tree_name = "net"
elif "net-next" in self._trees and self._trees["net-next"].check_applies(s):
s.tree_name = "net-next"
if self.list_module.current_tree in self._trees and \
self.list_module.series_is_a_fix_for(s, self._trees[self.list_module.current_tree]):
s.tree_name = self.list_module.current_tree
elif self.list_module.next_tree in self._trees and \
self._trees[self.list_module.next_tree].check_applies(s):
s.tree_name = self.list_module.next_tree

if s.tree_name:
log(f"Target tree - {s.tree_name}", "")
Expand Down Expand Up @@ -166,7 +170,7 @@ def _process_series(self, pw_series) -> None:
raise IncompleteSeries

comment = self.series_determine_tree(s)
s.need_async = netdev.series_needs_async(s)
s.need_async = self.list_module.series_needs_async(s)
if s.need_async:
comment += ', async'

Expand Down