Run the examples as tests
All checks were successful
/ build (pull_request) Successful in 1m17s
/ test (pull_request) Successful in 1m8s

This commit is contained in:
Aaron Fenyes 2025-03-28 00:36:38 -07:00
parent 7f45e98b46
commit 0a9d234557
2 changed files with 23 additions and 22 deletions

View file

@ -17,7 +17,8 @@ jobs:
- run: RUSTFLAGS='-D warnings' trunk build
# run the automated tests, reporting success if the tests pass and were built
# without warnings
# without warnings. the examples are run as tests, because we've configured
# each example target with `test = true` and `harness = false` in Cargo.toml
test:
runs-on: docker
container:
@ -27,24 +28,4 @@ jobs:
working-directory: app-proto
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- run: RUSTFLAGS='-D warnings' cargo test
# run the Cargo examples, as described here:
#
# Karol Kuczmarski. "Add examples to your Rust libraries"
# http://xion.io/post/code/rust-examples.html
#
# report success if the examples build and run without errors or warnings
run-examples:
runs-on: docker
container:
image: cimg/rust:1.85-node
defaults:
run:
working-directory: app-proto
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- run: RUSTFLAGS='-D warnings' cargo run --example irisawa-hexlet
- run: RUSTFLAGS='-D warnings' cargo run --example three-spheres
- run: RUSTFLAGS='-D warnings' cargo run --example point-on-sphere
- run: RUSTFLAGS='-D warnings' cargo run --example kaleidocycle
- run: RUSTFLAGS='-D warnings' cargo test

View file

@ -50,3 +50,23 @@ wasm-bindgen-test = "0.3.34"
[profile.release]
opt-level = "s" # optimize for small code size
debug = true # include debug symbols
[[example]]
name = "irisawa-hexlet"
test = true
harness = false
[[example]]
name = "kaleidocycle"
test = true
harness = false
[[example]]
name = "point-on-sphere"
test = true
harness = false
[[example]]
name = "three-spheres"
test = true
harness = false