]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CI: Add in-memory cache for the latest OpenSSL/LibreSSL
authorTim Duesterhus <tim@bastelstu.be>
Thu, 29 Dec 2022 16:40:25 +0000 (17:40 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 3 Jan 2023 15:28:34 +0000 (16:28 +0100)
These functions were previously called once per compiler. Add the `lru_cache`
decorator to only perform one HTTP request each.

.github/matrix.py

index 7cd04e88a61079377a9880d26a1717feda3bb464..3df259cd8ceaad6875b31a81310dbfd4a32680a5 100755 (executable)
@@ -8,6 +8,7 @@
 # as published by the Free Software Foundation; either version
 # 2 of the License, or (at your option) any later version.
 
+import functools
 import json
 import sys
 import urllib.request
@@ -25,6 +26,7 @@ print("Generating matrix for branch '{}'.".format(ref_name))
 def clean_ssl(ssl):
     return ssl.replace("_VERSION", "").lower()
 
+@functools.lru_cache(5)
 def determine_latest_openssl(ssl):
     headers = {'Authorization': 'token ' + environ.get('GITHUB_API_TOKEN')} if environ.get('GITHUB_API_TOKEN') else {}
     request = urllib.request.Request('https://api.github.com/repos/openssl/openssl/tags', headers=headers)
@@ -38,6 +40,7 @@ def determine_latest_openssl(ssl):
                latest_tag = name
     return "OPENSSL_VERSION={}".format(latest_tag[8:])
 
+@functools.lru_cache(5)
 def determine_latest_libressl(ssl):
     libressl_download_list = urllib.request.urlopen("http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/")
     for line in libressl_download_list.readlines():