Skip to content

Commit

Permalink
Merge branch 'main' into auto-bump-grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemental authored Apr 18, 2024
2 parents 409c142 + b64db9d commit ef6b075
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 27 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/354-fix-find-grafana-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- fix find grafana versions python script comparation
6 changes: 3 additions & 3 deletions hacking/check_fragment.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash

function fail() {
cat << EOF
cat <<EOF
Dear contributor,
Thank you for you Pull Request !
Expand All @@ -10,7 +10,7 @@ function fail() {
It will help your change be released faster !
Thank you !
EOF
exit 1
exit 1
}

FRAGMENTS=$(git fetch && git diff --name-only --diff-filter=ACMRT origin/main..HEAD | grep "changelogs")
Expand Down
31 changes: 16 additions & 15 deletions hacking/find_grafana_versions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

import json
import requests
Expand All @@ -7,32 +7,33 @@
def get_by_major(version):
if version.startswith("v"):
version = version[1:]
return (version[0], version, int(version.replace(".", "")))
return int(version.split(".")[0]), version, tuple(map(int, version.split(".")))


def get_grafana_releases():
r = requests.get(
"https://api.github.com/repos/grafana/grafana/releases?per_page=50",
"https://api.github.com/repos/grafana/grafana/releases?per_page=100",
headers={"Accept": "application/vnd.github.v3+json"},
)
if r.status_code != 200:
raise Exception("Failed to get releases from GitHub")
return r.json()


by_major = {}

if __name__ == "__main__":
releases = get_grafana_releases()
for item in releases:
if item.get("prerelease"):
by_major = {}

for release in releases:
if release.get("prerelease") or any(
char in release.get("tag_name") for char in "-+"
):
continue
major, version, as_int = get_by_major(item.get("tag_name"))
if major not in by_major.keys() or by_major[major]["as_int"] < as_int:
by_major[major] = {"version": version, "as_int": as_int}
latest_3_majors = sorted(list(by_major.keys()), reverse=True)[:3]

latest_releases = []
for idx in latest_3_majors:
latest_releases.append(by_major[idx]["version"])
major, version, as_tuple = get_by_major(release.get("tag_name"))
if major not in by_major.keys() or by_major[major]["as_tuple"] < as_tuple:
by_major[major] = {"version": version, "as_tuple": as_tuple}

latest_3_majors = sorted(list(by_major.keys()))[:3]
latest_releases = [by_major[idx]["version"] for idx in latest_3_majors]

print(json.dumps(latest_releases))
4 changes: 0 additions & 4 deletions tests/sanity/ignore-2.15.txt

This file was deleted.

4 changes: 0 additions & 4 deletions tests/sanity/ignore-2.16.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def run_command_ls():
def run_command_install_zip():
STDERR = ""
STDOUT = """
installing alexanderzobnin-grafana-zabbix @
installing alexanderzobnin-grafana-zabbix @
from: /home/grafana//alexanderzobnin-grafana-zabbix-v3.10.5-1-g2219691.zip
into: /var/lib/grafana/plugins
Expand Down

0 comments on commit ef6b075

Please sign in to comment.