Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts: Fix the validation script #467

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/scripts/validate_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def log_error(file_path, line_number, message, line, shouldCleanLine = False):
print(f'Error in {file_path} (line {line_number}): {message}\n\t"{line}"')

def is_file_valid(file_path):
with open(file_path, 'r') as file:
with open(file_path, 'r', encoding='utf-8') as file:
for line_number, line in enumerate(file, 1):
cleaned_line = clean_line(line)
if cleaned_line == "":
continue
elif cleaned_line.startswith("["):
if not cleaned_line.endswith("]"):
print(f'Error in {file_path} group format (line {line_number}): Unclosed brackets for group.\n\T"{line}"')
print(f'Error in {file_path} group format (line {line_number}): Unclosed brackets for group.\n\t"{line}"')
return False
continue
elif re.match(r'^(\s*(gametitle|comment|gsaspectratio|gsinterlacemode|author|description)\s*=)', line, re.IGNORECASE):
Expand All @@ -41,7 +41,7 @@ def is_file_valid(file_path):
if not re.match(r'^patch=(0|1|2),(EE|IOP),[0-9A-Fa-f]{1,8},(byte|short|word|double|extended|beshort|beword|bedouble|bytes),[0-9A-Fa-f]{1,8}', line):
log_error(file_path, line_number, "Invalid patch format.", line, True)
return False
if re.match(",\d{8}(\n|\s*(//.*)*)+(?!.)", line):
if re.match(r",\d{8}(\n|\s*(//.*)*)+(?!.)", line):
log_error(file_path, line_number, "Invalid comment syntax at end of patch line.", line, False)
return False
elif cleaned_line.startswith("dpatch"):
Expand Down Expand Up @@ -71,7 +71,7 @@ def is_file_valid(file_path):

def main():
error_found = False
print('Started validating patches files')
print('Started validating patch files')

files = glob.glob(patches_glob_path)
file_count = len(files)
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pack_patches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Create archives
run: |
7z a -r patches.zip ./patches/*

- name: Upload archives
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: cheats
path: ./patches.zip
Expand All @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4

- name: Create a new release
uses: marvinpinto/action-automatic-releases@latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate_patches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
timeout-minutes: 1
steps:
- name: Checkout Repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Validate all patches
run: |
Expand Down
Loading