diff --git a/.github/workflows/data-validation.yml b/.github/workflows/data-validation.yml index 29ceb67..c41d198 100644 --- a/.github/workflows/data-validation.yml +++ b/.github/workflows/data-validation.yml @@ -1,4 +1,4 @@ -name: databuilder +name: datavalidator on: workflow_dispatch: @@ -26,4 +26,6 @@ jobs: pip install -r requirements.txt - name: Run Python script + env: + WORKFLOW_RUN_NUMBER: ${{ github.run_number }} run: python src/validate_data.py diff --git a/data/EDGG/EDDF.toml b/data/EDGG/EDDF.toml index a354001..92d4a5e 100644 --- a/data/EDGG/EDDF.toml +++ b/data/EDGG/EDDF.toml @@ -24,4 +24,4 @@ url = "https://virtual-fra.com/" [[airport.links]] category = "Scenery" name = "MSFS Scenery by Aviotek" -url = "https://orbxdirect.com/product/aviotek-eddf-msfs" +url = "https://www.google.com/404" diff --git a/src/tasks/toml_data.py b/src/tasks/toml_data.py index c93fe46..7c92ed7 100644 --- a/src/tasks/toml_data.py +++ b/src/tasks/toml_data.py @@ -74,11 +74,9 @@ def check_errors(self): for error in self.errors: print(error) - sys.exit(1) - def export_data_json(self): if len(self.errors) != 0: - return + sys.exit(1) try: json_data = self.data.model_dump(mode="json") diff --git a/src/validate_data.py b/src/validate_data.py index 32e4007..8ff3157 100644 --- a/src/validate_data.py +++ b/src/validate_data.py @@ -1,6 +1,37 @@ +import os +import sys +import requests from settings import ROOT_DIRECTORY, OUTPUT_DIRECTORY from tasks.toml_data import TomlData if __name__ == "__main__": - TomlData(data_dir=ROOT_DIRECTORY, output_dir=OUTPUT_DIRECTORY, export=False) + tomldata = TomlData( + data_dir=ROOT_DIRECTORY, output_dir=OUTPUT_DIRECTORY, export=False + ) + + if len(tomldata.errors) == 0: + sys.exit(0) + + GITHUB_TOKEN = os.getenv("GITHUB_TOKEN") + REPO_OWNER = os.getenv("REPO_OWNER") + REPO_NAME = os.getenv("REPO_NAME") + workflow_run_number = os.getenv("WORKFLOW_RUN_NUMBER") + + issue_title = f"Error on workflow run {workflow_run_number}" + issue_body = "\n".join(tomldata.errors) + + url = f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/issues" + headers = { + "Authorization": f"token {GITHUB_TOKEN}", + "Accept": "application/vnd.github.v3+json", + } + data = {"title": issue_title, "body": issue_body} + + response = requests.post(url, json=data, headers=headers, timeout=5) + + if response.status_code == 201: + print("Issue created successfully.") + else: + print(f"Failed to create issue: {response.status_code}") + print(response.json())