Skip to content

Commit

Permalink
Deploy checker on GitHub Action
Browse files Browse the repository at this point in the history
- ignore single-name journals with same abbreviation as full name
- generate error summary and deploy checker on GitHub Action
  • Loading branch information
Phikho-cc committed Oct 19, 2024
1 parent 5c3f483 commit 7229041
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/quality-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Quality Check

on: [push, pull_request]

jobs:
quality-check:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Run Quality Check
run: |
python quality_checker.py
continue-on-error: true

- name: Upload Quality Check Summary
if: always()
uses: actions/upload-artifact@v2
with:
name: quality-check-summary
path: quality_check_summary.txt

- name: Add Quality Check Summary to Job
if: always()
run: |
echo "Generating GitHub Actions job summary..."
echo 'Quality Check Summary:' >> $GITHUB_STEP_SUMMARY
cat quality_check_summary.txt >> $GITHUB_STEP_SUMMARY
26 changes: 20 additions & 6 deletions scripts/check_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

# Path to the journals folder (change this path accordingly)
JOURNALS_FOLDER_PATH = "./journals/"

SUMMARY_FILE_PATH = "./check_quality_summary.txt"
errors = []
warnings = []
# Error tracking
def error(message):
errors.append(f"ERROR: {message}")

# Warning tracking
def warning(message):
print(f"WARN: {message}")
warnings.append(f"WARN: {message}")

# Check if non-UTF8 characters are present in the file
def check_non_utf8_characters(filepath):
Expand Down Expand Up @@ -58,7 +59,7 @@ def check_full_form_identical_to_abbreviation(filepath):
with open(filepath, 'r', encoding='utf-8') as f:
reader = csv.reader(f)
for line_number, row in enumerate(reader, start=1):
if len(row) == 2 and row[0].strip() == row[1].strip():
if len(row) == 2 and row[0].strip() == row[1].strip() and ' ' in row[0].strip():
warning(f"Abbreviation is the same as full form in {filepath} at line {line_number}: {row[0]}")

# Check for outdated abbreviations
Expand Down Expand Up @@ -87,10 +88,23 @@ def check_outdated_abbreviations(filepath):
check_full_form_identical_to_abbreviation(filepath)
check_outdated_abbreviations(filepath)

# Print all errors at the end
# Write the summary to a file
with open(SUMMARY_FILE_PATH, 'w') as summary_file:
if errors or warnings:
summary_file.write("Quality Check Summary:\n")
if errors:
summary_file.write("\nErrors:\n")
for err in errors:
summary_file.write(f"{err}\n")
if warnings:
summary_file.write("\nWarnings:\n")
for warn in warnings:
summary_file.write(f"{warn}\n")
else:
summary_file.write("Quality check completed with no errors or warnings.\n")

# Print summary and set exit code
if errors:
for err in errors:
print(err)
sys.exit(1)
else:
print("Quality check completed with no errors.")

0 comments on commit 7229041

Please sign in to comment.