diff options
Diffstat (limited to 'ansible_collections/community/grafana/hacking')
4 files changed, 61 insertions, 0 deletions
diff --git a/ansible_collections/community/grafana/hacking/NEED_FRAGMENT b/ansible_collections/community/grafana/hacking/NEED_FRAGMENT new file mode 100644 index 000000000..a7381318f --- /dev/null +++ b/ansible_collections/community/grafana/hacking/NEED_FRAGMENT @@ -0,0 +1,7 @@ +Dear contributor, + +Thank you for you Pull Request ! +To ease the work of maintainers you need to add a [changelog fragment](https://docs.ansible.com/ansible/latest/community/development_process.html#creating-a-changelog-fragment) in you PR. + +It will help your change be released faster ! +Thank you ! diff --git a/ansible_collections/community/grafana/hacking/check_fragment.sh b/ansible_collections/community/grafana/hacking/check_fragment.sh new file mode 100755 index 000000000..bf90cae65 --- /dev/null +++ b/ansible_collections/community/grafana/hacking/check_fragment.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +function fail() { + cat << EOF + Dear contributor, + + Thank you for you Pull Request ! + To ease the work of maintainers you need to add a [changelog fragment](https://docs.ansible.com/ansible/latest/community/development_process.html#creating-a-changelog-fragment) in you PR. + + It will help your change be released faster ! + Thank you ! +EOF + exit 1 +} + +FRAGMENTS=$(git fetch && git diff --name-only --diff-filter=ACMRT origin/main..HEAD | grep "changelogs") +[ -z "$FRAGMENTS" ] && fail +exit 0 diff --git a/ansible_collections/community/grafana/hacking/find_grafana_versions.py b/ansible_collections/community/grafana/hacking/find_grafana_versions.py new file mode 100644 index 000000000..06625a2d5 --- /dev/null +++ b/ansible_collections/community/grafana/hacking/find_grafana_versions.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import json +import requests + + +def get_by_major(version): + if version.startswith("v"): + version = version[1:] + return (version[0], version, int(version.replace('.', ''))) + + +def get_grafana_releases(): + r = requests.get('https://api.github.com/repos/grafana/grafana/releases?per_page=50', 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"): + 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"]) + print(json.dumps(latest_releases)) diff --git a/ansible_collections/community/grafana/hacking/requirements.txt b/ansible_collections/community/grafana/hacking/requirements.txt new file mode 100644 index 000000000..ced51d094 --- /dev/null +++ b/ansible_collections/community/grafana/hacking/requirements.txt @@ -0,0 +1 @@ +requests==2.28.0 |