Skip to content

feat: Allow pinging a url directly#552

Open
adamspofford-dfinity wants to merge 7 commits into
mainfrom
spofford/ping-url
Open

feat: Allow pinging a url directly#552
adamspofford-dfinity wants to merge 7 commits into
mainfrom
spofford/ping-url

Conversation

@adamspofford-dfinity
Copy link
Copy Markdown
Contributor

No description provided.

@adamspofford-dfinity adamspofford-dfinity marked this pull request as ready for review May 15, 2026 18:24
@adamspofford-dfinity adamspofford-dfinity requested a review from a team as a code owner May 15, 2026 18:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/rustup so setup-rust-toolchain wins; setup-rust-toolchain is reordered to after OS provisioning in the test job.
  • Help text in cli.md / ping.rs documents 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
};
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.

2 participants