• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / relman-auto-nag / #4196

pending completion
#4196

push

coveralls-python

suhaibmujahid
[utils] Drop dependency on release_calendar

553 of 3087 branches covered (17.91%)

2 of 2 new or added lines in 1 file covered. (100.0%)

1795 of 7995 relevant lines covered (22.45%)

0.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/auto_nag/next_release.py
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
4

5
import argparse
×
6
import re
×
7

8
import dateutil.parser
×
9
import pytz
×
10
import requests
×
11
from libmozdata import release_calendar
×
12
from libmozdata import release_owners as ro
×
13
from libmozdata import utils as lmdutils
×
14

15
from . import logger, mail, utils
×
16

17

18
def send_mail(next_date, bad_date_nrd, bad_date_ro, dryrun=False):
×
19
    mail.send_from_template(
×
20
        "next_release_email",
21
        utils.get_receivers("next-release"),
22
        "Next release date is not up-to-date",
23
        dryrun=dryrun,
24
        next_date=next_date,
25
        bad_date_nrd=bad_date_nrd,
26
        bad_date_ro=bad_date_ro,
27
    )
28

29

30
def check_dates(dryrun=False):
×
31
    next_date = utils.get_next_release_date()
×
32
    bad_date_nrd = bad_date_ro = None
×
33

34
    pat = re.compile(r"<p>(.*)</p>", re.DOTALL)
×
35
    url = "https://wiki.mozilla.org/Template:NextReleaseDate"
×
36
    template_page = str(requests.get(url).text)
×
37
    m = pat.search(template_page)
×
38
    date = dateutil.parser.parse(m.group(1).strip())
×
39
    date = pytz.utc.localize(date)
×
40

41
    if date != next_date:
×
42
        # so two possibilities:
43
        #  - Release services people just changed the release date
44
        #  - something is wrong and we must nag
45
        now = lmdutils.get_date_ymd("today")
×
46
        cal = release_calendar.get_calendar()
×
47
        must_nag = True
×
48
        for i, c in enumerate(cal):
×
49
            if (
×
50
                now < c["release date"]
51
                and i + 1 < len(cal)
52
                and cal[i + 1]["release date"] == date
53
            ):
54
                # The date is just the one after the "normal" release date
55
                # so here probably someone just changed the date because
56
                # we're close the merge day
57
                must_nag = False
×
58
                break
×
59
        if must_nag:
×
60
            bad_date_nrd = date.strftime("%Y-%m-%d")
×
61

62
    owners = ro.get_owners()
×
63
    now = lmdutils.get_date_ymd("today")
×
64
    for o in owners[::-1]:
×
65
        date = o["release date"]
×
66
        if now < date:
×
67
            if date != next_date:
×
68
                bad_date_ro = date.strftime("%Y-%m-%d")
×
69
            break
×
70

71
    if bad_date_nrd or bad_date_ro:
×
72
        next_date = next_date.strftime("%Y-%m-%d")
×
73
        send_mail(next_date, bad_date_nrd, bad_date_ro, dryrun=dryrun)
×
74

75

76
if __name__ == "__main__":
×
77
    parser = argparse.ArgumentParser(description="Check if next release date is ok")
×
78
    parser.add_argument(
×
79
        "--production",
80
        dest="dryrun",
81
        action="store_false",
82
        help="If the flag is not passed, just do the query, and print emails to console without emailing anyone",
83
    )
84
    args = parser.parse_args()
×
85
    try:
×
86
        check_dates(dryrun=args.dryrun)
×
87
    except Exception:
×
88
        logger.exception("Tool next_release")
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc