Skip to content

Commit

Permalink
Annotate errors in github actions (#34)
Browse files Browse the repository at this point in the history
* improv: add annotations to file on check errors

* test: intentionally invalid csv

* ci: run push hook on main only

* Revert "test: intentionally invalid csv"

This reverts commit 7e650c4.

* improv: quote entries in errors
  • Loading branch information
imLinguin authored Aug 5, 2024
1 parent 3d07226 commit aa2c891
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/validity-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
push:
paths:
- '**.csv'
branches:
- main
pull_request:
paths:
- '**.csv'
Expand Down
32 changes: 23 additions & 9 deletions tools/preflight-check.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,30 +20,41 @@ 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]
codename = row[2]
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()

0 comments on commit aa2c891

Please sign in to comment.