feat: Allow pinging a url directly#552
Open
adamspofford-dfinity wants to merge 7 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a convenience to icp network ping so that a positional argument shaped like an http(s) URL is treated as a direct replica endpoint, bypassing project/network configuration loading. It also adjusts CI to deal with Homebrew's rust/rustup formula shadowing the rustup-managed toolchain on the new macOS runner image, and applies the same provisioning step on macOS jobs that previously had none.
Changes:
icp network ping <url>now skips project loading and uses an anonymous agent pointed at the URL directly.- macOS CI jobs get a provisioning step that unlinks Homebrew's
rust/rustupsosetup-rust-toolchainwins;setup-rust-toolchainis reordered to after OS provisioning in the test job. - Help text in
cli.md/ping.rsdocuments the new URL form and normalizes trailing whitespace in the examples block.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
crates/icp-cli/src/commands/network/ping.rs |
Adds URL short-circuit branch in exec and updates after_long_help example. |
docs/reference/cli.md |
Mirrors the new example and whitespace cleanup. |
.github/workflows/test.yml |
Adds macOS Setup image step; moves setup-rust-toolchain after provisioning in the test job. |
.github/scripts/provision-macos-test.sh |
Unlinks Homebrew rust/rustup so the rustup-managed cargo takes precedence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+48
to
+55
| let agent = if let Some(ref name) = args.network_selection.name | ||
| && let Ok(url) = Url::parse(name) | ||
| && (url.scheme() == "http" || url.scheme() == "https") | ||
| { | ||
| // URL supplied directly: skip project loading | ||
| ctx.get_agent_for_url(&IdentitySelection::Anonymous, &url) | ||
| .await? | ||
| } else { |
Comment on lines
+52
to
+54
| // URL supplied directly: skip project loading | ||
| ctx.get_agent_for_url(&IdentitySelection::Anonymous, &url) | ||
| .await? |
Comment on lines
+48
to
+51
| let agent = if let Some(ref name) = args.network_selection.name | ||
| && let Ok(url) = Url::parse(name) | ||
| && (url.scheme() == "http" || url.scheme() == "https") | ||
| { |
Comment on lines
+76
to
+78
| - name: Setup image (macOS) | ||
| if: ${{ contains(matrix.os, 'macos') }} | ||
| run: ./.github/scripts/provision-macos-test.sh |
Comment on lines
+118
to
+120
| - uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4 | ||
| with: | ||
| cache-shared-key: ${{ runner.os }}-test |
Comment on lines
47
to
+72
| pub(crate) async fn exec(ctx: &Context, args: &PingArgs) -> Result<(), anyhow::Error> { | ||
| // Load project | ||
| let _ = ctx.project.load().await?; | ||
|
|
||
| // Convert args to selection and get network | ||
| let selection: Result<_, _> = args.network_selection.clone().into(); | ||
| let network = ctx.get_network_or_environment(&selection?).await?; | ||
|
|
||
| // NetworkAccess | ||
| let access = ctx.network.access(&network).await?; | ||
|
|
||
| // Agent | ||
| // TODO We might want to expose the ctx.create_agent function that takes a NetworkAccess | ||
| // instead of doing this | ||
| let agent = ctx | ||
| .get_agent_for_url(&IdentitySelection::Anonymous, &access.api_url) | ||
| .await?; | ||
|
|
||
| agent.set_root_key(access.root_key); | ||
| let agent = if let Some(ref name) = args.network_selection.name | ||
| && let Ok(url) = Url::parse(name) | ||
| && (url.scheme() == "http" || url.scheme() == "https") | ||
| { | ||
| // URL supplied directly: skip project loading | ||
| ctx.get_agent_for_url(&IdentitySelection::Anonymous, &url) | ||
| .await? | ||
| } else { | ||
| // Load project | ||
| let _ = ctx.project.load().await?; | ||
|
|
||
| // Convert args to selection and get network | ||
| let selection: Result<_, _> = args.network_selection.clone().into(); | ||
| let network = ctx.get_network_or_environment(&selection?).await?; | ||
|
|
||
| // NetworkAccess | ||
| // TODO We might want to expose the ctx.create_agent function that takes a NetworkAccess | ||
| // instead of doing this | ||
| let access = ctx.network.access(&network).await?; | ||
| let agent = ctx | ||
| .get_agent_for_url(&IdentitySelection::Anonymous, &access.api_url) | ||
| .await?; | ||
| agent.set_root_key(access.root_key); | ||
| agent | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.