-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added to GitHub Workflow to run examples in CI #214
base: main
Are you sure you want to change the base?
Conversation
5188766
to
4b2f797
Compare
Modified `build-test.yaml` to run this script in CI.
4b2f797
to
d8ec460
Compare
I'm not a fan of how this script works right now, because it exits when the first command fails to run. I'd rather it run every example and return an error code if any single example fails. |
Here's an alternative approach that runs every example and exits with an error code if any single example fails. #!/bin/bash
# Initialize a variable to track failures
has_error=0
# Function to run a command and log failures
run_command() {
echo "Running: $1"
$1
if [ $? -ne 0 ]; then
echo "Command failed: $1"
has_error=1
fi
}
# Run each command
run_command "cargo run --example basic-infection"
run_command "cargo run --example births-deaths"
# ... etc. ...
run_command "cargo run --example time-varying-infection ./examples/time-varying-infection/input.json"
# Exit with the appropriate code based on whether any command failed
if [ $has_error -eq 1 ]; then
echo "One or more commands failed."
exit 1
else
echo "All commands executed successfully."
exit 0
fi |
I agree that it's undesirable to have the whole job fail when a single example fails. In addition, I think we want to have individual failures visible in the GitHub interface. I think this pushes us towards each example being a separate job in GitHub actions using the GitHub actions "matrix" feature. Here's a partial example: This is unfinished. There are a few areas for improvement here:
At minimum we need to fix (1) and (2). However, I think this is a more promising angle than a script. |
This is what it looks like: https://github.com/CDCgov/ixa/actions/runs/13291542297 |
Thanks for this work! I'll add "WIP" to this PR and keep working on this. I've been getting a list of examples with this bash one-liner: EXAMPLES=$(cargo run --example 2>&1 | tail -n +3) But you're right, this only works for examples without arguments. |
examples/run_examples.sh
, which runs all examples.examples/run_examples.sh
, which runs all examples.
cb62f57
to
db07707
Compare
f981772
to
2bbc74b
Compare
2bbc74b
to
8242e2d
Compare
examples/run_examples.sh
, which runs all examples.examples.yaml
to run examples in CI
…f the dependencies and dependency build artifacts.
cf567c5
to
fa413b6
Compare
examples.yaml
to run examples in CIexamples.yaml
to run examples in CI
examples.yaml
to run examples in CIOnly `target/debug/deps` build artifacts are cached.
…nt recompilation.
Remove unused step ids.
…y because of a cache miss.
Cached artifacts appear to be saved and restored correctly, but I cannot observe any difference in compile times.
|
Manually bumped version to invalidate the cache.
Examples are running. Caching of dependencies and their build artifacts has been bumped to the backlog as a separate task for now. |
Modified
build-test.yaml
to run this script in CI.