Skip to content

Commit

Permalink
Implement workflow to run examples
Browse files Browse the repository at this point in the history
ROCKY-20651
  • Loading branch information
Gustavo Martins committed Nov 28, 2023
1 parent a8d0c1c commit 4566a3f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions examples/run_examples.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 4566a3f

Please sign in to comment.