Skip to content

Commit 8f1a784

Browse files
committed
CI: Only check the latest GHC release per major version
Testing all releases is getting too cumbersome to deal with, and ensuring the latest release works should be good enough.
1 parent 6730b80 commit 8f1a784

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

.github/extract_from_ghc_bindist.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
import json
22
import os
33
import sys
4+
from packaging import version
45

5-
current_dir = os.path.dirname(__file__)
6-
haskell_dir = os.path.join(current_dir, "..", "haskell")
76

7+
def get_latest_versions(version_list):
8+
# Create a dictionary to store the latest version for each major.minor pair
9+
latest_versions = {}
10+
11+
for ver in version_list:
12+
# Split the version into major, minor, and patch
13+
major, minor, patch = map(int, ver.split('.'))
14+
15+
# Create a key for the major.minor pair
16+
key = f"{major}.{minor}"
17+
18+
# If the key is not in the dictionary or the current version is greater than the stored version
19+
if key not in latest_versions or version.parse(ver) > version.parse(latest_versions[key]):
20+
# Update the dictionary with the latest version
21+
latest_versions[key] = ver
822

9-
def unexpected(unexpected, l, error_message):
10-
for a in unexpected:
11-
if a in l:
12-
print(error_message, file=sys.stderr)
13-
list.remove(a)
23+
# Return the latest versions
24+
return list(latest_versions.values())
1425

1526

27+
current_dir = os.path.dirname(__file__)
28+
haskell_dir = os.path.join(current_dir, "..", "haskell")
29+
1630
with open(
1731
os.path.join(haskell_dir, "private", "ghc_bindist_generated.json"), mode="rb"
1832
) as f:
19-
version_numbers = list(json.load(f).keys())
20-
21-
unexpected(
22-
["8.10.1", "8.10.2"],
23-
version_numbers,
24-
"GHC 8.10.1 and 8.10.2 not supported. Upgrade to 8.10.3 or later.",
25-
)
33+
version_numbers = get_latest_versions(json.load(f).keys())
2634

2735
with open(os.environ["GITHUB_OUTPUT"], mode="a", encoding="utf-8") as output:
2836
output.write("ghc-matrix={}\n".format(version_numbers))

0 commit comments

Comments
 (0)