|
17 | 17 | import requests |
18 | 18 | from dateutil.relativedelta import relativedelta |
19 | 19 | from libmozdata import utils as lmdutils |
20 | | -from libmozdata import versions as lmdversions |
21 | 20 | from libmozdata.bugzilla import Bugzilla, BugzillaShorten |
22 | 21 | from libmozdata.fx_trains import FirefoxTrains |
23 | 22 | from libmozdata.hgmozilla import Mercurial |
@@ -501,32 +500,56 @@ def get_bugs_from_pushlog(startdate, enddate, channel="nightly"): |
501 | 500 | return bugs |
502 | 501 |
|
503 | 502 |
|
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]: |
505 | 529 | # There are different reasons to not return versions: |
506 | 530 | # i) we're merge day: the versions are changing |
507 | 531 | # 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 |
509 | 533 | if is_merge_day(): |
510 | 534 | return {} |
511 | 535 |
|
512 | | - versions = lmdversions.get(base=True) |
| 536 | + versions = get_versions_from_trains() |
513 | 537 | versions["central"] = versions["nightly"] |
514 | 538 |
|
515 | 539 | v = [versions[k] for k in ["release", "beta", "central"]] |
516 | | - versions = {k: str(v) for k, v in versions.items()} |
517 | 540 |
|
518 | | - if v[0] + 2 == v[1] + 1 == v[2]: |
| 541 | + if v[0] + 2 == v[1] + 1 == v[2]: # type: ignore[operator] |
519 | 542 | nightly_bugzilla = get_nightly_version_from_bz() |
520 | 543 | if v[2] != nightly_bugzilla: |
521 | 544 | from . import logger |
522 | 545 |
|
523 | | - logger.info("Versions mismatch between Bugzilla and product-details") |
| 546 | + logger.info("Versions mismatch between Bugzilla and the trains API") |
524 | 547 | return {} |
525 | | - return versions |
| 548 | + return {k: str(v) for k, v in versions.items()} |
526 | 549 |
|
527 | 550 | from . import logger |
528 | 551 |
|
529 | | - logger.info("Not consecutive versions in product/details") |
| 552 | + logger.info("Not consecutive versions from the trains API") |
530 | 553 | return {} |
531 | 554 |
|
532 | 555 |
|
|
0 commit comments