Skip to content

Commit 40d9243

Browse files
fixup gitlab actions
1 parent 9c14143 commit 40d9243

File tree

1 file changed

+35
-10
lines changed

1 file changed

+35
-10
lines changed

tools/preflight-check.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,27 @@
44
import os
55
import csv
66

7-
SUPPORTED_STORES = ["amazon", "battlenet", "none", "egs", "ubisoft", "ea", "humble", "itchio", "gog", "zoomplatform"]
7+
SUPPORTED_STORES = [
8+
"amazon", "battlenet", "none", "egs", "ubisoft", "ea",
9+
"humble", "itchio", "gog", "zoomplatform"
10+
]
11+
12+
EXPECTED_COLS = 7 # TITLE, STORE, CODENAME, UMU_ID, ACRONYM(opt), EXE_STRING(opt), NOTE(opt)
813

914
def main():
15+
if len(sys.argv) < 2:
16+
print("Usage: validate_csv.py <path-to-csv>")
17+
exit(2)
18+
1019
file = sys.argv[1]
1120
filename = os.path.basename(file)
1221
has_error = False
13-
with open(file, 'r') as csvfile:
22+
23+
with open(file, "r", newline="") as csvfile:
1424
rows = csv.reader(csvfile)
1525
header = True
16-
release_ids = list()
26+
release_keys = set()
27+
1728
for i, row in enumerate(rows, 1):
1829
if header:
1930
header = False
@@ -24,8 +35,11 @@ def main():
2435
has_error = True
2536
continue
2637

27-
if len(row) != 6:
28-
print(f"::error file={filename},line={i}::incorrect number of columns")
38+
if len(row) != EXPECTED_COLS:
39+
print(
40+
f"::error file={filename},line={i}::incorrect number of columns "
41+
f"(expected {EXPECTED_COLS}, got {len(row)})"
42+
)
2943
has_error = True
3044
continue
3145

@@ -34,6 +48,11 @@ def main():
3448
codename = row[2]
3549
umu_id = row[3]
3650

51+
# Optional columns (present but not required)
52+
acronym = row[4]
53+
exe_string = row[5]
54+
notes = row[6]
55+
3756
if not (title and store and codename and umu_id):
3857
print(f"::error file={filename},line={i}::At least one of the required fields is missing")
3958
has_error = True
@@ -44,15 +63,21 @@ def main():
4463
has_error = True
4564
continue
4665

66+
# Preserve existing behavior: skip "none/none" releases
4767
if store == "none" and codename == "none":
4868
continue
49-
release_id = f"{store}_{codename}"
50-
if release_id in release_ids:
51-
print(f"::error file={filename},line={i}::Duplicate entry found '{title}, {store}, {codename}'")
69+
70+
# Duplicates should be per game+store+codename
71+
release_key = (umu_id, store, codename)
72+
if release_key in release_keys:
73+
print(
74+
f"::error file={filename},line={i}::Duplicate entry found "
75+
f"'{title}, {store}, {codename}, {umu_id}'"
76+
)
5277
has_error = True
5378
continue
54-
release_ids.append(release_id)
55-
79+
release_keys.add(release_key)
80+
5681
if has_error:
5782
exit(1)
5883

0 commit comments

Comments
 (0)