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

Open-MSS / MSS / 10653123390

01 Sep 2024 10:12AM UTC coverage: 69.967% (-0.07%) from 70.037%
10653123390

Pull #2495

github

web-flow
Merge d3a10b8f0 into 0b95679f6
Pull Request #2495: remove the conda/mamba based updater.

24 of 41 new or added lines in 5 files covered. (58.54%)

92 existing lines in 6 files now uncovered.

13843 of 19785 relevant lines covered (69.97%)

0.7 hits per line

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

46.43
/mslib/utils/release_info.py
1
# -*- coding: utf-8 -*-
2
"""
3

4
    mslib.utils.release_info
5
    ~~~~~~~~~~~~~~~~~~~~~~~~
6

7
    Shows by a github API call information about the latest release
8

9
    This file is part of MSS.
10

11
    :copyright: Copyright 2024 Reimar Bauer
12
    :copyright: Copyright 2024 by the MSS team, see AUTHORS.
13
    :license: APACHE-2.0, see LICENSE for details.
14

15
    Licensed under the Apache License, Version 2.0 (the "License");
16
    you may not use this file except in compliance with the License.
17
    You may obtain a copy of the License at
18

19
       http://www.apache.org/licenses/LICENSE-2.0
20

21
    Unless required by applicable law or agreed to in writing, software
22
    distributed under the License is distributed on an "AS IS" BASIS,
23
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
    See the License for the specific language governing permissions and
25
    limitations under the License.
26
"""
27

28
import datetime
1✔
29
import logging
1✔
30
import requests
1✔
31
from pebble import concurrent
1✔
32

33
from mslib.version import __version__ as installed_version
1✔
34

35

36
@concurrent.process(timeout=1)
1✔
37
def get_latest_release():
1✔
38
    # GitHub API URL for the MSS Release
NEW
39
    url = "https://api.github.com/repos/Open-MSS/MSS/releases/latest"
×
40

NEW
41
    try:
×
42
        # Make a GET request to the GitHub API
NEW
43
        response = requests.get(url, timeout=(1, 1))
×
NEW
44
        response.raise_for_status()  # Raise an error for non-200 status codes
×
45

46
        # Extract the JSON response
NEW
47
        release_data = response.json()
×
48

49
        # Extract the latest release tag and name
NEW
50
        latest_release = {
×
51
            'tag_name': release_data['tag_name'],
52
            'release_name': release_data['name'],
53
            'published_at': release_data['published_at'],
54
            'url': release_data['html_url']
55
        }
NEW
56
        return latest_release
×
57

NEW
58
    except requests.exceptions.RequestException as e:
×
NEW
59
        logging.debug(f"Error fetching release data: {e}")
×
NEW
60
        return None
×
61

62

63
def check_for_new_release():
1✔
64
    no_new_release_found = f"{datetime.date.today()}: No new release found."
1✔
65
    try:
1✔
66
        # we use the timeout_decorator on the function to stop requests trying to establish a connection
67
        latest_release = get_latest_release().result()
1✔
NEW
68
    except TimeoutError as e:
×
NEW
69
        logging.debug(f"Error fetching release data: {e}")
×
NEW
70
        latest_release = None
×
71

72
    if latest_release is None or latest_release['tag_name'] == installed_version:
1✔
73
        return no_new_release_found, False
1✔
74

NEW
75
    github_url = f'<a href="{latest_release["url"]}#target">{latest_release["url"]}</a>'
×
NEW
76
    return ' | '.join([
×
77
        f"New release found: {latest_release['release_name']} ({latest_release['tag_name']})",
78
        f"Published at: {latest_release['published_at']}",
79
        f"Release URL: {github_url}",
80
    ]), True
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