Skip to content

Commit

Permalink
Wokflow para validar materials
Browse files Browse the repository at this point in the history
Também renomeando workflow de deploy
  • Loading branch information
camilamaia committed Nov 6, 2024
1 parent 4b5cf40 commit ed8d2f6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
File renamed without changes.
27 changes: 27 additions & 0 deletions .github/workflows/validate_materials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Validate Materials

on:
push:

jobs:
validate:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run validation script
run: |
export PYTHONPATH=$(pwd) # Adiciona o diretório raiz ao PYTHONPATH
python curadoria_coletiva/validate_materials.py
1 change: 0 additions & 1 deletion curadoria_coletiva/materials/example.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
- titulo: Introdução ao Python
autor: Jane Doe
url: https://example.com/python-course
assuntos:
- python
Expand Down
13 changes: 9 additions & 4 deletions curadoria_coletiva/validate_materials.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import yaml
from pydantic import ValidationError
from typing import Set, List, Dict, Any
Expand All @@ -19,9 +20,13 @@ def validate_materials_from_yaml(yaml_file: str) -> List[Dict[str, Any]]:
validated_materials.append(material_data)
print(f"Valid material found: {material_data.get('titulo')}")
except ValidationError as e:
print(f"Validation error in material {material_data.get('titulo')}: {e}")
msg = "Validation error in material {material_data.get('titulo')}: {e}"
print(msg)
sys.exit(1, msg)
except ValueError as e:
print(f"Value error in material {material_data.get('titulo')}: {e}")
msg = f"Value error in material {material_data.get('titulo')}: {e}"
print(msg)
sys.exit(1, msg)

return validated_materials

Expand Down Expand Up @@ -69,6 +74,6 @@ def _validate_material(material_data: Dict[str, Any], unique_titles: Set[str]) -


if __name__ == "__main__":
input_yaml_file = "all_materials.yml"
collect_materials("materials", input_yaml_file)
input_yaml_file = "curadoria_coletiva/all_materials.yml"
collect_materials("curadoria_coletiva/materials", input_yaml_file)
validate_materials_from_yaml(input_yaml_file)

0 comments on commit ed8d2f6

Please sign in to comment.