Skip to content

Commit 962ff77

Browse files
authored
Change get_checked_versions to use whattrainisitnow (#2954)
1 parent 524b421 commit 962ff77

1 file changed

Lines changed: 32 additions & 9 deletions

File tree

bugbot/utils.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import requests
1818
from dateutil.relativedelta import relativedelta
1919
from libmozdata import utils as lmdutils
20-
from libmozdata import versions as lmdversions
2120
from libmozdata.bugzilla import Bugzilla, BugzillaShorten
2221
from libmozdata.fx_trains import FirefoxTrains
2322
from libmozdata.hgmozilla import Mercurial
@@ -501,32 +500,56 @@ def get_bugs_from_pushlog(startdate, enddate, channel="nightly"):
501500
return bugs
502501

503502

504-
def get_checked_versions():
503+
def get_versions_from_trains() -> dict[str, int | None]:
504+
"""Get the current major version for each channel from whattrainisitnow.
505+
506+
We source versions from the trains API rather than product-details because
507+
product-details' beta field (`LATEST_FIREFOX_RELEASED_DEVEL_VERSION`) only
508+
updates once a beta build ships, so it lags for a day or two after merge
509+
day and makes the channel numbers look non-consecutive. The trains API
510+
reports the current-cycle version for every channel, so the numbers stay
511+
internally consistent through the merge window.
512+
513+
A channel can be null (e.g. `esr_previous` outside an ESR overlap period);
514+
we map that to None rather than failing.
515+
516+
Returns:
517+
dict: major version (int, or None) keyed by channel: release, beta,
518+
nightly, esr, esr_previous.
519+
"""
520+
data = FirefoxTrains.get_instance().get_lando_uplift_train()
521+
522+
return {
523+
channel: data[channel]["version"] if data[channel] else None
524+
for channel in ("release", "beta", "nightly", "esr", "esr_previous")
525+
}
526+
527+
528+
def get_checked_versions() -> dict[str, str]:
505529
# There are different reasons to not return versions:
506530
# i) we're merge day: the versions are changing
507531
# ii) not consecutive versions numbers
508-
# iii) bugzilla updated nightly version but p-d is not updated
532+
# iii) bugzilla updated nightly version but the trains API has not
509533
if is_merge_day():
510534
return {}
511535

512-
versions = lmdversions.get(base=True)
536+
versions = get_versions_from_trains()
513537
versions["central"] = versions["nightly"]
514538

515539
v = [versions[k] for k in ["release", "beta", "central"]]
516-
versions = {k: str(v) for k, v in versions.items()}
517540

518-
if v[0] + 2 == v[1] + 1 == v[2]:
541+
if v[0] + 2 == v[1] + 1 == v[2]: # type: ignore[operator]
519542
nightly_bugzilla = get_nightly_version_from_bz()
520543
if v[2] != nightly_bugzilla:
521544
from . import logger
522545

523-
logger.info("Versions mismatch between Bugzilla and product-details")
546+
logger.info("Versions mismatch between Bugzilla and the trains API")
524547
return {}
525-
return versions
548+
return {k: str(v) for k, v in versions.items()}
526549

527550
from . import logger
528551

529-
logger.info("Not consecutive versions in product/details")
552+
logger.info("Not consecutive versions from the trains API")
530553
return {}
531554

532555

0 commit comments

Comments
 (0)