From d581859a63f394162d32747099f172d73c3a0a62 Mon Sep 17 00:00:00 2001 From: Alexey Snigir Date: Fri, 19 Jul 2024 12:15:53 +0200 Subject: [PATCH] workflows check --- .github/workflows/checks-vizro-core.yml | 2 +- .github/workflows/checks-workflows.yml | 34 +++++++++++++++++++++++++ tools/yaml_check.py | 27 ++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/checks-workflows.yml create mode 100644 tools/yaml_check.py diff --git a/.github/workflows/checks-vizro-core.yml b/.github/workflows/checks-vizro-core.yml index f62835f40..6c54515cb 100644 --- a/.github/workflows/checks-vizro-core.yml +++ b/.github/workflows/checks-vizro-core.yml @@ -9,7 +9,7 @@ on: branches: [main] paths: - "vizro-core/**" - pull_request: + pull_request_target: branches: - "main" paths: diff --git a/.github/workflows/checks-workflows.yml b/.github/workflows/checks-workflows.yml new file mode 100644 index 000000000..778349a4d --- /dev/null +++ b/.github/workflows/checks-workflows.yml @@ -0,0 +1,34 @@ +name: Worflows check + +defaults: + run: + working-directory: vizro + +on: + push: + branches: [main] + pull_request: + branches: + - main + +env: + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 + PYTHON_VERSION: "3.11" + +jobs: + lint-vizro-all: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Workflows check + run: | + cd .github/workflows + python ../../tools/yaml_check.py diff --git a/tools/yaml_check.py b/tools/yaml_check.py new file mode 100644 index 000000000..f73658d92 --- /dev/null +++ b/tools/yaml_check.py @@ -0,0 +1,27 @@ +import yaml +import os +import json + + +def yaml_reader(filepath): + for file in filepath: + with open(file, "rb") as f: + data = yaml.safe_load(f) + data_str = json.dumps(data) + if "pull_request_target" in data_str: + print(f"{file} contains pull_request_target") + failed_list.append(file) + + +def failed_list_check(failed_list): + if failed_list: + return exit(1) + else: + pass + + +if __name__ == "__main__": + filepath = os.listdir() + failed_list = [] + yaml_reader(filepath) + failed_list_check(failed_list)