-
Notifications
You must be signed in to change notification settings - Fork 8
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
chore: run only rust tests affected with changed files #928
chore: run only rust tests affected with changed files #928
Conversation
440184f
to
3282a2b
Compare
0f30db8
to
607c923
Compare
607c923
to
d55637c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…-run-only-rust-tests-affected-with-changed-files
10b935e
to
3a1392f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of the crates don't compile on their own, for example calimero-server
, calimero-node-primitives
, calimero-config
etc, relying instead for merod
& meroctl
to maximally define all the minimum feature requirements to satisfy all the crates.
Not an ideal situation, but quite the effort to untangle. It's tracked by #265 under
cargo check
to ensure theHEAD
builds right
- We need to walk the dep tree, creating a dependency graph and build each crate in order of dependence so we can guarantee all crates build independently as well as when linked. (See fix: handle outcome sender errors in the node and JSONRPC server #258 (comment))
- Don't forget to build examples
This PR attempts to test each crate independently, it will break in cases where cargo build
for a specific crate doesn't work.
if mode is not "all", this will not test apps and contracts? they don't have calimero-
prefix, nor are they in crates/*
folder.
We should revert this.
# Remove duplicates | ||
unique_changed_crates=() | ||
for item in "${changed_crates[@]}"; do | ||
# Check if item is already in unique_array | ||
duplicate=false | ||
for unique_item in "${unique_changed_crates[@]}"; do | ||
if [[ "$item" == "$unique_item" ]]; then | ||
duplicate=true | ||
break | ||
fi | ||
done | ||
# If item is not a duplicate, add it to unique_array | ||
if ! $duplicate; then | ||
unique_changed_crates+=("$item") | ||
fi | ||
done | ||
echo "Unique crates from changed files" "${unique_changed_crates[@]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uniq
command?
# get list of all dependencies from the crate including external dependencies | ||
dependencies=($(cargo metadata --format-version=1 --no-deps | jq -r --arg CRATE "$calimero_package_name" ' | ||
.packages[] | | ||
select(.dependencies | any(.name == $CRATE)) | | ||
.name | ||
')) | ||
|
||
for dep in "${dependencies[@]}"; do | ||
# Compare dependency with list of crates from workspace to skip external dependencies | ||
calimero_dep_crate_path="${dep/calimero-/crates/}" | ||
for crate in "${all_crates[@]}"; do | ||
if [[ "$crate" == "$calimero_dep_crate_path" ]]; then | ||
echo "Found matching dependency: $calimero_dep_crate_path" | ||
dep_arr+=("$calimero_dep_crate_path") | ||
fi | ||
done | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't need to test dependencies of changed crates, but "dependents" of changed crates.
calimero-node
depends on calimero-context
which depends on calimero-primitives
, if calimero-context
changes we need to test that as well as calimero-node
, but not necessarily calimero-primitives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It tests dependencies which imports changed crate
crate_package_name=("${crate/crates\//calimero-}") | ||
if [[ "$crate_package_name" == "calimero-merod" ]]; then | ||
echo "Testing crate merod" | ||
cargo +nightly test -p "merod" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why test with nightly?
This reverts commit 1ff1351.
Tested with changed files
https://github.com/calimero-network/core/actions/runs/11698775125
./scripts/test.sh now accepts --all or --local {changed_files}
Docs calimero-network/calimero-network.github.io#48