Skip to content
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

feat: support analysis of URLs #246

Merged
merged 9 commits into from
Nov 4, 2024
Merged

feat: support analysis of URLs #246

merged 9 commits into from
Nov 4, 2024

Conversation

a-frantz
Copy link
Member

@a-frantz a-frantz commented Nov 1, 2024

Adds remote file support to wdl-analysis and the wdl binary.

With this change, we have the option to stop cloning repos in Gauntlet.

Before submitting this PR, please make sure:

  • You have added a few sentences describing the PR here.
  • You have added yourself or the appropriate individual as the assignee.
  • You have added at least one relevant code reviewer to the PR.
  • Your code builds clean without any errors or warnings.
  • You have added tests (when appropriate).
  • You have updated the README or other documentation to account for these
    changes (when appropriate).
  • You have added an entry to the relevant CHANGELOG.md (see
    "keep a changelog" for more information).
  • Your commit messages follow the conventional commit style.

@a-frantz a-frantz self-assigned this Nov 4, 2024
@a-frantz a-frantz marked this pull request as ready for review November 4, 2024 15:45
wdl-lsp/src/server.rs Outdated Show resolved Hide resolved
@@ -103,7 +105,15 @@ async fn analyze<T: AsRef<dyn Rule>>(
},
);

analyzer.add_documents(vec![path]).await?;
// Convert the file to a either a local URL or a remote URL
let file = if file.starts_with("http://") || file.starts_with("https://") {
Copy link
Member

Choose a reason for hiding this comment

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

Is this sufficient? What about other protocols such as FTP? Or URLs that omit the leading protocol?

Copy link
Member Author

Choose a reason for hiding this comment

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

Would it be better to just always call Url::parse(), and if that fails attempt PathBuf::from() (and if that fails, bail!())?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just typed up the following and it seems to work:

    let file = if let Ok(url) = Url::parse(&file) {
        url
    } else if let Some(url) = path_to_uri(&PathBuf::from(file.clone())) {
        url
    } else {
        bail!("failed to convert `{file}` to a URI", file = file)
    };

Copy link
Member

Choose a reason for hiding this comment

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

That's what I was wondering. I'm curious to hear other thoughts on this, but it makes sense to me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it makes sense to attempt to parse it as a URI and fallback to treating it as a path (also, path_to_uri should probably be changed to take impl AsRef<Path> instead of &Path).

Regarding the supported schemes for the URIs, I think only http, https, and file should be supported as it's the only schemes required by the standard for import statements (with file currently deprecated and http should definitely be deprecated, but isn't currently).

Copy link
Collaborator

@peterhuene peterhuene left a comment

Choose a reason for hiding this comment

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

Looks good, just the nit comment.

wdl/src/bin/wdl.rs Outdated Show resolved Hide resolved
Co-Authored-By: Peter Huene <[email protected]>
@a-frantz a-frantz merged commit 263e095 into main Nov 4, 2024
16 checks passed
@a-frantz a-frantz deleted the feat/analyze-urls branch November 4, 2024 19:29
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.

3 participants