From d1a9f81a8f33a32aa1a5a1e94556a8cc2536835b Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:17:16 +0200 Subject: [PATCH 1/7] fix: find grafana releases for latest 3 major versions --- hacking/find_grafana_versions.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/hacking/find_grafana_versions.py b/hacking/find_grafana_versions.py index b31fc530..add6ea9e 100644 --- a/hacking/find_grafana_versions.py +++ b/hacking/find_grafana_versions.py @@ -7,12 +7,12 @@ 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: @@ -20,19 +20,18 @@ def get_grafana_releases(): 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"): 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)) From d11b9a5f6c8dcbfc8e65e0554b6f051d937eec06 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:33:41 +0200 Subject: [PATCH 2/7] docs: changelog fragment --- changelogs/fragments/354-fix-find-grafana-versions.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/354-fix-find-grafana-versions.yml diff --git a/changelogs/fragments/354-fix-find-grafana-versions.yml b/changelogs/fragments/354-fix-find-grafana-versions.yml new file mode 100644 index 00000000..4ba22771 --- /dev/null +++ b/changelogs/fragments/354-fix-find-grafana-versions.yml @@ -0,0 +1,3 @@ +--- +trivial: + - fix find grafana versions python script comparation From 7ac1cd7711c5dc37ef376643f46f0482eaaa62a9 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:35:37 +0200 Subject: [PATCH 3/7] chore: remove dangling whitespace --- .../unit/modules/grafana/grafana_plugin/test_grafana_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py b/tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py index ec691a46..7cc04a99 100644 --- a/tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py +++ b/tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py @@ -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 From 355bb65a9d69c3981fc34b22de21449750f77a35 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:42:44 +0200 Subject: [PATCH 4/7] test: shebang sanity --- hacking/check_fragment.sh | 6 +++--- hacking/find_grafana_versions.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hacking/check_fragment.sh b/hacking/check_fragment.sh index bf90cae6..3173b342 100755 --- a/hacking/check_fragment.sh +++ b/hacking/check_fragment.sh @@ -1,7 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash function fail() { - cat << EOF + cat < Date: Fri, 12 Apr 2024 17:18:47 +0200 Subject: [PATCH 5/7] fix: skip pre or build release tags --- hacking/find_grafana_versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hacking/find_grafana_versions.py b/hacking/find_grafana_versions.py index 6ea344f9..780d07e6 100644 --- a/hacking/find_grafana_versions.py +++ b/hacking/find_grafana_versions.py @@ -25,7 +25,7 @@ def get_grafana_releases(): by_major = {} for release in releases: - if release.get("prerelease"): + if release.get("prerelease") or any(char in release.get("tag_name") for char in "-+"): continue 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: From 87bdf0f780474162e41393142f71b46480abdd72 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:20:55 +0200 Subject: [PATCH 6/7] chore: lint --- hacking/find_grafana_versions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hacking/find_grafana_versions.py b/hacking/find_grafana_versions.py index 780d07e6..716f877a 100644 --- a/hacking/find_grafana_versions.py +++ b/hacking/find_grafana_versions.py @@ -25,7 +25,9 @@ def get_grafana_releases(): by_major = {} for release in releases: - if release.get("prerelease") or any(char in release.get("tag_name") for char in "-+"): + if release.get("prerelease") or any( + char in release.get("tag_name") for char in "-+" + ): continue 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: From b64db9de485f46b4329169aff26f638b95c77dee Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Thu, 18 Apr 2024 08:30:51 +0200 Subject: [PATCH 7/7] ci: remove sanity ignore files --- tests/sanity/ignore-2.15.txt | 4 ---- tests/sanity/ignore-2.16.txt | 4 ---- 2 files changed, 8 deletions(-) delete mode 100644 tests/sanity/ignore-2.15.txt delete mode 100644 tests/sanity/ignore-2.16.txt diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt deleted file mode 100644 index 5c82494f..00000000 --- a/tests/sanity/ignore-2.15.txt +++ /dev/null @@ -1,4 +0,0 @@ -plugins/modules/grafana_dashboard.py validate-modules:invalid-argument-name -tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py pep8:W291 -hacking/check_fragment.sh shebang -hacking/find_grafana_versions.py shebang diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt deleted file mode 100644 index 5c82494f..00000000 --- a/tests/sanity/ignore-2.16.txt +++ /dev/null @@ -1,4 +0,0 @@ -plugins/modules/grafana_dashboard.py validate-modules:invalid-argument-name -tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py pep8:W291 -hacking/check_fragment.sh shebang -hacking/find_grafana_versions.py shebang