Skip to content

Test examples in CI#29

Merged
toruseo merged 1 commit intotoruseo:mainfrom
EwoutH:run_examples_in_ci
Mar 5, 2024
Merged

Test examples in CI#29
toruseo merged 1 commit intotoruseo:mainfrom
EwoutH:run_examples_in_ci

Conversation

@EwoutH
Copy link
Copy Markdown
Contributor

@EwoutH EwoutH commented Mar 5, 2024

This pull request integrates pytest within our GitHub Actions CI pipeline to automatically execute all example scripts located in the demos_and_examples directory. This ensures that every commit or pull request can be verified that all existing examples keep working when changes are made.

Changes

  • Added test_examples.py: A pytest wrapper script that dynamically discovers and runs each .py file in demos_and_examples as a separate test case.
  • Updated .github/workflows/python-app.yml: Configured the CI pipeline to set up pytest and run the wrapper script as part of the testing jobs.
  • Added pytest to the project dependencies to enable automated test discovery and execution.

How It Works

The test_examples.py script utilizes pytest's pytest_generate_tests hook to collect all the Python scripts in the demos_and_examples directory and parameterizes them as individual test cases. For each script, it uses Python's subprocess module to run the script as a separate process. The test is considered successful if the script runs to completion without errors (exit code 0).


It already detected the first issue with the examples, which I reported in #28. If that is fixed everything should turn green. This PR can already be merged however.

Currently the tests take about 12 minutes, mainly due to the deep learning examples. Maybe we can speedup or exclude those in the future.

Create a CI configuration with GitHub Actions that runs all the examples in CI, to see if all existing examples keep working when changes are made.
@toruseo toruseo merged commit 0e0668f into toruseo:main Mar 5, 2024
@toruseo
Copy link
Copy Markdown
Owner

toruseo commented Mar 5, 2024

Thanks for this too. I was also thinking this kind of test is necessary. Really appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants