diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index caa0c35a..abcbe745 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -43,6 +43,12 @@ jobs: pytest tests --junitxml=build/pytest.xml + - name: "Test Examples" + run: | + .venv/Scripts/activate.bat + + python examples/run_examples.py + - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() # run this step even if previous step failed diff --git a/examples/run_examples.py b/examples/run_examples.py new file mode 100644 index 00000000..5df23c8e --- /dev/null +++ b/examples/run_examples.py @@ -0,0 +1,26 @@ +import os.path +from pathlib import Path +import subprocess +import sys + + +def run_examples() -> None: + path = Path(os.path.realpath(__file__)) + examples_path = path.parent + example_files = list(examples_path.rglob("*.py")) + example_files.remove(path) + + example_failed = False + for f in example_files: + try: + subprocess.run(["python", f], check=True) + except subprocess.CalledProcessError: + print(f"Example has failed: {f.name}") + example_failed = True + + if example_failed: + sys.exit(1) + + +if __name__ == "__main__": + run_examples()