Skip to content

chore: migrate rust/query_stats to icp-cli#1400

Merged
raymondk merged 7 commits into
masterfrom
chore/migrate-rust-query-stats-to-icp-cli
Jun 19, 2026
Merged

chore: migrate rust/query_stats to icp-cli#1400
raymondk merged 7 commits into
masterfrom
chore/migrate-rust-query-stats-to-icp-cli

Conversation

@marc0olo

@marc0olo marc0olo commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

Migrates rust/query_stats from dfx to icp-cli.

Removed: dfx.json, BUILD.md, query-stats.did, .devcontainer/

Changed:

  • Rust source moved from src/lib.rs to backend/lib.rs with a workspace Cargo.toml
  • ic-cdk bumped to 0.20; replaced removed ic_cdk::api::management_canister with ic-cdk-management-canister = "0.1.1"; replaced removed ic_cdk::id() with ic_cdk::api::canister_self()

Added:

  • icp.yaml with @dfinity/rust@v3.3.0 recipe
  • test.sh with 2 tests: load() returns a non-zero timestamp, get_query_stats() returns all four stat fields
  • test-stats.sh — mirrors the Motoko example: makes 13 --query calls every 3s and polls until Number of calls is non-zero (up to 30s)
  • rust-toolchain.toml with wasm32-unknown-unknown target
  • rust-query_stats job in .github/workflows/query_stats.yml using icp-dev-env-rust:1.0.1

Test plan

  • icp network start -d && icp deploy && bash test.sh passes locally
  • bash test-stats.sh shows non-zero stats after ~12s locally
  • CI rust-query_stats job passes

🤖 Generated with Claude Code

@marc0olo marc0olo force-pushed the chore/migrate-rust-query-stats-to-icp-cli branch from 9ad4874 to 5a519c1 Compare June 17, 2026 17:00
@marc0olo marc0olo closed this Jun 19, 2026
@marc0olo marc0olo force-pushed the chore/migrate-rust-query-stats-to-icp-cli branch from 5a519c1 to 8f077c8 Compare June 19, 2026 06:35
marc0olo and others added 2 commits June 19, 2026 09:38
- Replace dfx.json with icp.yaml using @dfinity/rust@v3.3.0 recipe
- Move src/lib.rs to backend/lib.rs; add workspace Cargo.toml
- Update ic-cdk to 0.20 and replace deprecated ic_cdk::api::management_canister
  with ic-cdk-management-canister = "0.1.1"
- Add Makefile with test and test-stats targets (fast API check + polling loop)
- Add rust-toolchain.toml with wasm32-unknown-unknown target
- Update README with icp-cli prerequisites and query stats explanation
- Add rust-query_stats job to .github/workflows/query_stats.yml
- Delete dfx.json, BUILD.md, query-stats.did, .devcontainer/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marc0olo marc0olo reopened this Jun 19, 2026
marc0olo and others added 4 commits June 19, 2026 11:57
…:canister_self()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Drop redundant networks block from icp.yaml
- Remove references to non-existent test-stats.sh and make test-stats
- Simplify README to accurately describe what test.sh does

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tion

Mirrors the Motoko example's test-stats.sh: makes 13 --query calls to
load() every 3s and polls get_query_stats() until Number of calls shows
a non-zero value (or times out after 30s).

13+ calls are needed per round because PocketIC simulates a 13-node
subnet and uses integer division (num_calls / 13).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marc0olo marc0olo marked this pull request as ready for review June 19, 2026 10:54
@marc0olo marc0olo requested review from a team as code owners June 19, 2026 10:54
@marc0olo marc0olo requested a review from Copilot June 19, 2026 10:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Not ready to approve

The Motoko workflow step runs make test but the example directory has no Makefile, so CI will fail unless the workflow is corrected.

Pull request overview

Migrates the rust/query_stats example from dfx to icp-cli, aligning it with the repo’s canonical Rust example layout (workspace + backend/ crate), updated dependencies, and icp-cli based CI/testing.

Changes:

  • Replaced dfx project files with icp.yaml, a Rust workspace Cargo.toml, and updated Cargo.lock for the new dependency set.
  • Moved canister source to backend/lib.rs, upgraded to ic-cdk = 0.20, and switched to ic-cdk-management-canister APIs (plus export_candid!()).
  • Added test.sh + test-stats.sh, and extended the existing query_stats GitHub Actions workflow with a Rust job.
File summaries
File Description
rust/query_stats/test.sh Adds a fast smoke test for load() and get_query_stats() output shape.
rust/query_stats/test-stats.sh Adds a polling/load script to demonstrate non-zero query stats locally.
rust/query_stats/rust-toolchain.toml Ensures the wasm target is available for builds.
rust/query_stats/README.md Updates documentation for icp-cli usage and explains query-stats behavior/requirements.
rust/query_stats/query-stats.did Removes the old dfx-era .did file.
rust/query_stats/icp.yaml Adds icp-cli project definition for the Rust backend canister.
rust/query_stats/dfx.json Removes the old dfx project definition.
rust/query_stats/Cargo.toml Converts the root crate into a workspace.
rust/query_stats/Cargo.lock Updates lockfile for the workspace + upgraded deps (ic-cdk, etc.).
rust/query_stats/BUILD.md Removes ICP Ninja / dfx-oriented build instructions.
rust/query_stats/backend/lib.rs Ports canister code to new layout and updated management-canister APIs; exports candid.
rust/query_stats/backend/Cargo.toml Adds backend crate definition and updated dependencies.
rust/query_stats/.devcontainer/devcontainer.json Removes per-example devcontainer config.
.github/workflows/query_stats.yml Adds Rust job trigger/run and adjusts Motoko job command (currently problematic).

Copilot's findings

  • Files reviewed: 13/14 changed files
  • Comments generated: 2

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/query_stats.yml Outdated
Comment thread rust/query_stats/README.md
…ale)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@raymondk raymondk merged commit 9da5d94 into master Jun 19, 2026
7 checks passed
@raymondk raymondk deleted the chore/migrate-rust-query-stats-to-icp-cli branch June 19, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants