summaryrefslogtreecommitdiffstats
path: root/.github/scripts
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <austin@netdata.cloud>2023-02-24 10:00:36 -0500
committerGitHub <noreply@github.com>2023-02-24 17:00:36 +0200
commita20b8c4ab47c84f8e9f1473e78472ff4bedd57f1 (patch)
tree4c3b33abeda5ffcc8d3091470d3873d6936411a9 /.github/scripts
parent13b34502c10d62c2210c1f624b37c96d3278b8a9 (diff)
Add a scheduled CI job to flag supported platforms going EOL upstream. (#14581)
* Add a scheduled CI job to flag supported platforms going EOL upstream. By default, it runs at 03:00 UTC every Monday and checks the upstream EOL date for each platform we support that needs such checking. If the platform will be EOL upstream within the next 30 days, an issue is opened flagging the platform for removal from CI and our support document and auto-assigned to the agent SRE team members. The workflow can also be manually triggered (mostly intended for testing). Data about upstream EOL dates is retrieved from https://endoflife.date via their new public API. Happily, our own definition of what constitutes EOL for our purposes matches up 1:1 with how they categorize platforms as EOL. * Fix logic issue in issue creation. * Explicitly enable error handling for issue checks.
Diffstat (limited to '.github/scripts')
-rwxr-xr-x.github/scripts/gen-matrix-eol-check.py23
-rwxr-xr-x.github/scripts/platform-impending-eol.py41
2 files changed, 64 insertions, 0 deletions
diff --git a/.github/scripts/gen-matrix-eol-check.py b/.github/scripts/gen-matrix-eol-check.py
new file mode 100755
index 0000000000..9164052a00
--- /dev/null
+++ b/.github/scripts/gen-matrix-eol-check.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+'''Generate the build matrix for the EOL check jobs.'''
+
+import json
+
+from ruamel.yaml import YAML
+
+yaml = YAML(typ='safe')
+entries = list()
+
+with open('.github/data/distros.yml') as f:
+ data = yaml.load(f)
+
+for item in data['include']:
+ if 'eol_check' in item and item['eol_check']:
+ entries.append({
+ 'distro': item['distro'],
+ 'release': item['version'],
+ })
+
+entries.sort(key=lambda k: (k['distro'], k['release']))
+matrix = json.dumps({'include': entries}, sort_keys=True)
+print(matrix)
diff --git a/.github/scripts/platform-impending-eol.py b/.github/scripts/platform-impending-eol.py
new file mode 100755
index 0000000000..eec9b1abee
--- /dev/null
+++ b/.github/scripts/platform-impending-eol.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+'''Check if a given distro is going to be EOL soon.
+
+ This queries the public API of https://endoflife.date to fetch EOL dates.
+
+ ‘soon’ is defined by LEAD_DAYS, currently 30 days.'''
+
+import datetime
+import json
+import sys
+import urllib.request
+
+URL_BASE = 'https://endoflife.date/api'
+NOW = datetime.date.today()
+LEAD_DAYS = datetime.timedelta(days=30)
+
+DISTRO = sys.argv[1]
+RELEASE = sys.argv[2]
+
+
+with urllib.request.urlopen(f'{ URL_BASE }/{ DISTRO }/{ RELEASE }.json') as response:
+ match response.status:
+ case 200:
+ data = json.load(response)
+ case 404:
+ sys.exit(f'No data available for { DISTRO } { RELEASE }.')
+ case _:
+ sys.exit(
+ f'Failed to retrieve data for { DISTRO } { RELEASE } ' +
+ f'(status: { response.status }).'
+ )
+
+eol = datetime.date.fromisoformat(data['eol'])
+
+offset = abs(eol - NOW)
+
+if offset <= LEAD_DAYS:
+ print(data['eol'])
+ sys.exit(2)
+else:
+ sys.exit(0)