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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools.vpm: add manifest fetch for hg repositories, add test #20107

Merged
merged 6 commits into from Dec 7, 2023

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented Dec 6, 2023

The PR resolves a todo by fetching and checking the manifest for mercurial repos before installation and adds a first test for projects using mercurial.

mercurial only needs installation on mac runners. It's a default for Ubuntu and Windows runners: https://github.com/actions/runner-images

馃[deprecated] Generated by Copilot at 27e71e2

Improved the vpm tool's support for installing V modules from Mercurial repositories. Added tests, refactored code, and fixed parsing errors for Mercurial URLs. Modified the macOS CI workflow to install mercurial as a dependency. Added a test_utils module with a helper function for running a local Mercurial server.

馃[deprecated] Generated by Copilot at 27e71e2

  • Add support for installing V modules from Mercurial repositories (link, link, link)
  • Fix typo in comment in parse.v (link)
  • Extract common logic for decoding manifest from HTTP response into get_manifest_from_resp function in parse.v (link)
  • Add helper functions for testing Mercurial repositories in test_utils/utils.v (link)
  • Simplify initialization of test project directory using git init command in install_test.v (link)
  • Include error message when parsing v.mod file fails in install_test.v, install_version_input_test.v, and install_version_test.v (link, link, link)
  • Install mercurial as a dependency for macOS CI tests in .github/workflows/macos_ci.yml (link)

@@ -106,6 +106,9 @@ fn get_mod_vpm_info(name string) !ModuleVpmInfo {
fn get_ident_from_url(raw_url string) !(string, string) {
url := urllib.parse(raw_url) or { return error('failed to parse module URL `${raw_url}`.') }
publisher, mut name := url.path.trim_left('/').rsplit_once('/') or {
if settings.vcs == .hg && raw_url.count(':') > 1 {
return '', 'test_module'
Copy link
Member Author

Choose a reason for hiding this comment

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

Anything would be fine here. This just makes sure a name is returned when a localhost address is fetched during tests that doesn't contain a path after the domain. The eventual module name is derived from the manifest.

@ttytm ttytm marked this pull request as draft December 6, 2023 22:18
@ttytm ttytm force-pushed the tools/vpm/fetch-hg-manifest branch from 27e71e2 to 28d5474 Compare December 6, 2023 23:08
@ttytm ttytm marked this pull request as ready for review December 7, 2023 01:42
@@ -166,15 +167,14 @@ fn test_install_potentially_conflicting() {

fn test_get_installed_version() {
test_project_path := os.join_path(test_path, 'test_project')
os.mkdir_all(test_project_path)!
mut res := os.execute('git init ${test_project_path}')
Copy link
Member

Choose a reason for hiding this comment

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

Very nice ... I did not know, that git init folder will create it.

import net
import time

fn hg_serve(hg_path string, path string) (&os.Process, int) {
Copy link
Member

Choose a reason for hiding this comment

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

Hm, this should have needed pub. I am not sure, why it did not fail to compile... Perhaps because it is used in a test file?

import time

fn hg_serve(hg_path string, path string) (&os.Process, int) {
mut port := 8000
Copy link
Member

@spytheman spytheman Dec 7, 2023

Choose a reason for hiding this comment

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

Start probing from some more obscure port. 8000 and 8080 are very likely to be taken by other tests, between the time you check, and the time the mercurial server starts.

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Excellent work.

@spytheman spytheman merged commit 7b44bb9 into vlang:master Dec 7, 2023
42 checks passed
@ttytm ttytm deleted the tools/vpm/fetch-hg-manifest branch December 15, 2023 22:07
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.

None yet

2 participants