Skip to content

Some cargo build/test tasks are not running in CI #458

Open
@RobertJacobsonCDC

Description

@RobertJacobsonCDC

A few subtle Cargo behaviors mean that we don't run what we think we run in CI:

  • It turns out that if you have a "main package" in a workspace (which we do), then commands like cargo build and cargo test apply to the main package, not all workspace members.
  • cargo build only builds the "default" targets lib and bin. It doesn't build test, example, and bench targets unless you also pass the --all-targets flag.
  • cargo test --examples does not actually run the examples. It only runs the tests defined in the examples.

As I recall, the last one is intentional. The issue is that there is no Cargo command to run all examples automatically. There is a bit of bash code involving jq that can gather all example names and run them, but in our case one of the examples intentionally requires a command line argument, and instead of dealing with the complexity we decided at the time that it was enough just to build the examples and run their tests. Here's a complete list of commands to run all examples:

cargo run --example basic
cargo run --example basic-infection
cargo run --example births-deaths
cargo run --example load-people
cargo run --example network-hhmodel
cargo run --example parameter-loading
cargo run --example random
cargo run --example reports
cargo run --example reports-multi-threaded
cargo run --example runner
cargo run --example time-varying-infection -- examples/time-varying-infection/input.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions