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

[WIP] Fix/add update gomod #137

Closed
wants to merge 7 commits into from

Conversation

mhchia
Copy link
Collaborator

@mhchia mhchia commented Dec 18, 2018

What was wrong?

#130

How was it fixed?

  • Add package.json back, to specify the dependencies on gx.
  • Add the python script scripts/update-gomod.py, which parses the dependency on gx, turns gx-hash to git commits, and updates them to go.mod and go.sum using go get.

There are two modes in this script: download, and update.

  • download: download and update all dependencies of the current repo according to the gx dependency file package.json, to the path /tmp/gx-git-repos.
  • update: parse the dependencies information described by package.json with BFS and get the gx versions in the format in the below for each dependency. Then, search for the git commit or release version with the gx information, in the downloaded repos which are fetched in mode download. Last, use those git commit or release version, we can do GO111MODULE=on go get {repo}@{commit or version} to update the versions to go.mod
{
    "hash": "QmaqGyUhWLsJbVo1QAujSu13mxNjFJ98Kt2VWGSnShGE1Q",
    "name": "go-libp2p-pubsub",
    "version": "0.11.9",
}

Example

$ cd {path/to/sharding-p2p-poc}
$ python scripts/update-gomod.py download  # Download the git repos of all dependencies(including the indirect ones)
$ python scripts/update-gomod.py update
$ GO111MODULE=on go build

Current issues

  • Haven't verified whether go get truly update the dependency to go.mod or not
  • Seems the version specified in gx(package.json) is not necessarily equaled to the one in git tag

Reference

Cute Animal Picture

put a cute animal picture link inside the parentheses

TODO:
- Ensure modules are truely downloaded before executing `update-gomod`
- Stop after any failure downloads
Besides, Add Exceptions
To save time. Besides, refactor a lot
- extract_gx_path is fixed
- update package.json
@mhchia
Copy link
Collaborator Author

mhchia commented Dec 25, 2018

Note: I'd like to close this PR and reopen it after confirming all deps can be resolved correctly. Moved the script update-gomod.py to another repo https://github.com/mhchia/py-gx-gomod

@mhchia mhchia closed this Dec 25, 2018
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.

1 participant