Skip to content

Commit

Permalink
Merge pull request #4 from Alexander-Wilms/main
Browse files Browse the repository at this point in the history
Validate templates during CI
  • Loading branch information
sunderme authored Feb 12, 2024
2 parents 3d936b0 + 43457bc commit 8679b75
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
on:
- push

jobs:
validate:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Validate templates
run: python3 validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Date": "2023-04-10",
"Description": "Template for Master degree thesis in Mathematics. University on Ioannina Greece",
"License": "",
"Name": "MSc Thesis Mathematics UOI",
"Name": "MSc Thesis Mathematics UOI GR",
"Version": "1.0",
"FilesToOpen" : "./thesisMSc.tex"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Date": "2023-04-10",
"Description": "Template for Phd thesis in Mathematics. University on Ioannina - Greece",
"License": "",
"Name": "Phd Thesis Mathematics UOI",
"Name": "Phd Thesis Mathematics UOI GR",
"Version": "1.0",
"FilesToOpen" : "./thesis.tex"
}
31 changes: 31 additions & 0 deletions validate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import json
from pathlib import Path

for json_path in Path(".").glob("**/*.json"):
json_path_str = str(json_path)
if json_path_str.startswith("."):
continue
print(f"Validating {json_path_str}")
with open(json_path_str) as f:
template_data = json.load(f)

template_name = template_data["Name"]
print(f"\tName field in JSON: {template_name}")
expected_path = json_path.parent / f"template_{template_name}.json"
print(f"\tExpected .json path: {expected_path}")
print(f"\tActual .json path: {json_path_str}")
print("\tChecking whether .json path matches name")
assert json_path == expected_path

png_path = expected_path.with_suffix(".png")
print(f"\tChecking whether .png exists: {png_path}")
assert png_path.is_file()

tex_path = expected_path.with_suffix(".tex")
zip_path = expected_path.with_suffix(".zip")
print(f"\tChecking whether .tex ({tex_path}) or .zip ({zip_path}) exists")
assert (
expected_path.with_suffix(".tex").is_file()
or expected_path.with_suffix(".zip").is_file()
)
print()

0 comments on commit 8679b75

Please sign in to comment.