diff --git a/.github/workflows/validity-check.yml b/.github/workflows/validity-check.yml index 7033be4..b6c9ca6 100644 --- a/.github/workflows/validity-check.yml +++ b/.github/workflows/validity-check.yml @@ -3,6 +3,8 @@ on: push: paths: - '**.csv' + branches: + - main pull_request: paths: - '**.csv' diff --git a/tools/preflight-check.py b/tools/preflight-check.py index 2975f69..8a8f728 100755 --- a/tools/preflight-check.py +++ b/tools/preflight-check.py @@ -1,12 +1,15 @@ #!/usr/bin/env python3 import sys +import os import csv SUPPORTED_STORES = ["amazon", "battlenet", "none", "egs", "ubisoft", "ea", "humble", "itchio", "steam", "gog", "zoomplatform"] def main(): file = sys.argv[1] + filename = os.path.basename(file) + has_error = False with open(file, 'r') as csvfile: rows = csv.reader(csvfile) header = True @@ -17,8 +20,14 @@ def main(): continue if not row: - print("Empty row found:", i) - exit(1) + print(f"::error file={filename},line={i}::empty row found") + has_error = True + continue + + if len(row) != 6: + print(f"::error file={filename},line={i}::incorrect number of columns") + has_error = True + continue title = row[0] store = row[1] @@ -26,21 +35,26 @@ def main(): umu_id = row[3] if not (title and store and codename and umu_id): - print("At least one of the required fields is missing, in row:", i) - exit(1) + print(f"::error file={filename},line={i}::At least one of the required fields is missing") + has_error = True + continue if store not in SUPPORTED_STORES: - print("Invalid store provided", store, "in row", i) - exit(1) + print(f"::error file={filename},line={i}::Invalid store provided '{store}'") + has_error = True + continue if store == "none" and codename == "none": continue release_id = f"{store}_{codename}" if release_id in release_ids: - print("Duplicate entry found", title, store, codename, "in row", i) - exit(1) + print(f"::error file={filename},line={i}::Duplicate entry found '{title}, {store}, {codename}'") + has_error = True + continue release_ids.append(release_id) - + + if has_error: + exit(1) if __name__ == "__main__": main()