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

Make go.thethings.network/lorawan-stack/v3/cmd a module #2495

Closed
wants to merge 4 commits into from

Conversation

johanstokking
Copy link
Member

@johanstokking johanstokking commented May 7, 2020

Summary

Replaces #2493

Make go.thethings.network/lorawan-stack/v3/cmd a module

Changes

  • Move tools.go into new tools mod
  • Make cmd a module
  • Build development tooling to .bin instead of go run which would use the repo's module

Notes for Reviewers

  1. Check need for the replacements in /go.mod and /cmd/go.mod
  2. Make sure that we can use the tools in /cmd/tools.go. I'm also open to a /tools module
  3. Check if we need to merge some changes from github.com/robertkrimen/otto in github.com/TheThingsIndustries/otto
  4. Figure out how we can update .bin binaries if modules update in tools/go.mod; maybe always install on make init?

Checklist

  • Scope: The referenced issue is addressed, there are no unrelated changes.
  • Compatibility: The changes are backwards compatible with existing API, storage, configuration and CLI, according to the compatibility commitments in README.md. The target branch is set to master if the changes are fully compatible with existing API, database, configuration and CLI.
  • Testing: The changes are covered with unit tests. The changes are tested manually as well.
  • Documentation: Relevant documentation is added or updated.
  • Changelog: Significant features, behavior changes, deprecations and fixes are added to CHANGELOG.md.
  • Commits: Commit messages follow guidelines in CONTRIBUTING.md, there are no fixup commits left.

@johanstokking johanstokking added c/shared This is shared between components tooling Development tooling labels May 7, 2020
@johanstokking johanstokking added this to the May 2020 milestone May 7, 2020
@johanstokking johanstokking changed the base branch from develop to master May 7, 2020 13:17
@johanstokking johanstokking force-pushed the feature/cmd-mod branch 2 times, most recently from ceda264 to 54123b2 Compare May 7, 2020 14:33
@johanstokking johanstokking removed their assignment May 7, 2020
@johanstokking johanstokking added the blocked This can't continue until another issue or pull request is done label May 7, 2020
@johanstokking
Copy link
Member Author

Blocked by #2496

@johanstokking
Copy link
Member Author

johanstokking commented May 7, 2020

In order to use versioned tools, I would suggest;

  • put tools.go in cmd, or move to tools/main.go and init new module
  • install the tools via go install to a shared repo-local bin folder
  • use the binaries from the bin folder instead of the go run construct in mage (via execGo)

Example Makefile (tools/Makefile):

GO = go
GOBIN = $(PWD)/.bin
export GOBIN

.PHONY: deps.dev
deps.dev:
	@cat main.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % $(GO) install %

And then shell exec tools like ./.bin/unconvert instead of constructing shell exec go run github.com/mdempsky/unconvert in mage and travis

@coveralls
Copy link

coveralls commented May 7, 2020

Coverage Status

Coverage decreased (-0.002%) to 73.122% when pulling 49d17a60ceb38cdfac73fefe5190f5430d656ccd on feature/cmd-mod into c637d93 on master.

@johanstokking johanstokking changed the base branch from master to feature/update-deps May 7, 2020 21:11
@johanstokking johanstokking force-pushed the feature/cmd-mod branch 2 times, most recently from 03eab01 to 1b308c3 Compare May 7, 2020 21:23
@johanstokking johanstokking self-assigned this May 7, 2020
@johanstokking johanstokking marked this pull request as ready for review May 7, 2020 21:34
@johanstokking johanstokking changed the base branch from feature/update-deps to master May 8, 2020 09:53
$(MAGE): magefile.go $(wildcard .mage/*.go)
GO111MODULE=on go install github.com/magefile/mage
GO111MODULE=on go run github.com/magefile/mage -compile $(MAGE)
$(GOBIN):
Copy link
Member Author

Choose a reason for hiding this comment

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

Should we turn this into $(GOBIN): tools/go.mod for it to track that file for changes to the tools and versions?

@@ -14,7 +14,7 @@

// +build tools

package tools
package main
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

@rvolosatovs
Copy link
Contributor

The benefit of using go run to run commands is the automatic installation/versioning with no Makefile etc. maintenance cost. What's the benefit of using compiled binaries? How do you propose to keep them up-to-date?

@johanstokking
Copy link
Member Author

The benefit of using go run to run commands is the automatic installation/versioning with no Makefile etc. maintenance cost.

Yes, that definitely has benefits. But I do want to keep those modules (and replacements) out of the project root's go.mod. Two possible steps forward:

  1. go run from the tools dir and account for that in the paths
  2. Watch tools/go.mod in the Makefile so that changes trigger reinstallation

@rvolosatovs
Copy link
Contributor

rvolosatovs commented May 8, 2020

I'd vote for 1. We could move all the mage stuff there as well, in fact, I believe. That way we'd have everything tooling-related with all the dependency hell isolated in ./tools and a clean top-level module at root. I believe we don't need a ./cmd module either this way.

To clarify, that means running ./tools/mage instead of ./mage.

@johanstokking johanstokking removed their assignment May 8, 2020
@johanstokking
Copy link
Member Author

OK, please try if that works.

@johanstokking
Copy link
Member Author

That way we'd have everything tooling-related with all the dependency hell isolated in ./tools and a clean top-level module at root

Looking at replacements we have in this changeset;

@johanstokking johanstokking removed the blocked This can't continue until another issue or pull request is done label May 12, 2020
@rvolosatovs rvolosatovs mentioned this pull request May 19, 2020
6 tasks
@johanstokking johanstokking deleted the feature/cmd-mod branch May 26, 2020 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/shared This is shared between components tooling Development tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants