Skip to content

Commit 2e6de3c

Browse files
committed
Refactor JSON review processing script and GitHub Actions workflow
Updated the workflow to remove the exit code on script failure, allowing for continued execution. Enhanced the script to provide clearer feedback on failed files, indicating their movement to a dedicated 'failed' directory and improving overall error handling and user feedback.
1 parent 313c501 commit 2e6de3c

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

.github/workflows/process_json_reviews.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
env:
3636
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3737
run: |
38-
python scripts/process_json_reviews.py || exit 1
38+
python scripts/process_json_reviews.py
3939
4040
- name: Commit and push processed files
4141
if: success() || failure() # Run even if previous step failed

Scripts/process_json_reviews.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,25 @@ def main() -> None:
332332
print(f" Total files: {len(json_files)}")
333333

334334
if failed_files:
335-
print(f"\nFailed files:")
335+
print(f"\nFailed files (moved to {FAILED_DIR}/):")
336336
for filename, error in failed_files:
337337
print(f" - {filename}: {error}")
338+
print(f"\n⚠ Note: Failed files have been moved to {FAILED_DIR}/ and will not be retried.")
338339

339-
if failed_count > 0:
340-
print(f"\n✗ Exiting with error code 1 due to {failed_count} failed file(s)")
341-
sys.exit(1)
342-
else:
343-
print(f"\n✓ All files processed successfully")
340+
# Exit successfully if we handled all files (either processed or moved to failed/)
341+
# We only exit with error if we couldn't handle the files at all
342+
if processed_count > 0 or (failed_count > 0 and processed_count + failed_count == len(json_files)):
343+
# All files were handled (either processed or moved to failed directory)
344+
if failed_count > 0:
345+
print(f"\n✓ Handled {processed_count + failed_count} file(s) ({processed_count} processed, {failed_count} moved to failed/)")
346+
print(f" Failed files are in {FAILED_DIR}/ and can be reviewed manually.")
347+
else:
348+
print(f"\n✓ All {processed_count} file(s) processed successfully")
344349
sys.exit(0)
350+
else:
351+
# This shouldn't happen, but if it does, something went wrong
352+
print(f"\n✗ Error: Could not handle all files properly")
353+
sys.exit(1)
345354

346355

347356
if __name__ == "__main__":

0 commit comments

Comments
 (0)