Checks are missing in release builds
On the current master
, building ghostflow-director
using the release
profile (cargo build --release
) results in a failure of the test test_checks_exist
with error "the allow_robot check should be supported". This is also seen trying to run ghostflow-director
to validate otherwise valid YAML config files with the checks:
argument set at any level and with any of the available checks.
I'm not a Rust expert, but digging through things, this looks almost certainly related to: https://github.com/dtolnay/inventory/issues/32. Trying a very dumb binary project with
# Cargo.toml
[package]
name = "check-git-checks"
version = "0.1.0"
edition = "2021"
[dependencies]
inventory = "~0.1"
git-checks-config = "~0.1"
git-checks-core = "^1.0"
git-checks = { version = "^4.0", features = ["config"] }
and
// main.rs
use git_checks_config::{BranchCheckConfig, CommitCheckConfig, TopicCheckConfig};
use git_checks;
use inventory;
fn main() {
println!("Hello, world!");
for check in inventory::iter::<BranchCheckConfig> {
println!("Found BranchCheck: {}", check.name());
}
for check in inventory::iter::<CommitCheckConfig> {
println!("Found CommitCheck: {}", check.name());
}
for check in inventory::iter::<TopicCheckConfig> {
println!("Found TopicCheck: {}", check.name());
}
}
Results in output:
$ cargo run
Hello, world!
... all checks printed ...
Found TopicCheck: bad_commit/topic
$
and
$ cargo run --release
Hello, world!
$
I've tried out the suggested incremental
and codegen-units
changes with RUSTFLAGS
in the inventory linked issue, but at least for the above example, these don't seem to change things (but I could well be doing something wrong here).
What does seem to fix things is pulling in one single thing from the git_checks
crate:
// main.rs
use git_checks_config::{BranchCheckConfig, CommitCheckConfig, TopicCheckConfig};
use git_checks::AllowRobot;
use inventory;
fn main() {
println!("Hello, world!");
let _x = AllowRobot::builder();
for check in inventory::iter::<BranchCheckConfig> {
println!("Found BranchCheck: {}", check.name());
}
for check in inventory::iter::<CommitCheckConfig> {
println!("Found CommitCheck: {}", check.name());
}
for check in inventory::iter::<TopicCheckConfig> {
println!("Found TopicCheck: {}", check.name());
}
}
which (with no other changes) results in:
$ cargo run --release
Hello, world!
... all checks printed ...
Found TopicCheck: bad_commit/topic
$
This isn't super-critical, but I've until now been doing our deployment of ghostflow-director
in Docker/OpenShift using release builds for size/speed. I suspect using Debug builds for now will be o.k., but would be nice to have a working Release option.
I'm not enough of an Rust expert to suggest the best fix for this. Perhaps if something from git_checks
needs to be pulled in, it could provide a function get_checks
or similar? That could be used in ghostflow-director
both in test_checks_exist
to dynamically get the "standard" checks, maybe also to help with documenting checks and their allowed config?
Would be happy to prepare a MR for review on that if, or for other suggestions!