2015-03-02

Go, GitHub and Travis : a small lesson in dependencies

Recently, I ran into a small, but interesting, issue in a new open-source project that I am working on: RxnWeaver. It is being developed in Go. Inspired by a few other projects that I follow, I set up Travis CI for this project.

I do the development in my fork of the project, before raising periodic (or need-based) pull requests to the main repository.

In a particular commit, I happened to add a few exported constants to a package (let us call this Package A) in the repository. In the next commit, I added code that depended on some of those constants, to a different package (let us call this Package B) in the repository. As usual, I pushed the commits to my GitHub fork after making sure that the code was formatted with go fmt and that the tree builds without errors. I raised a pull request to the main repository, and the fun began!

Travis CI reported failure saying that the build did not complete successfully. A little investigation revealed the cause. In Package B, references to Package A use the official github.com/RxnWeaver/RxnWeaver import paths. The official version of the package there, however, has the old set of constants that does not include the new and required ones. Therefore, Package B could not be built.

The commit, though, that was intended to update Package A was part of the same pull request!

Of course, it was easy to fix, but the simple lesson is: if you do not want to have to use the command line and some git trickery, do not forget to raise a pull request (and have it merged) for each piece that could be used as a dependency in a different Go package!

Post a Comment