-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
chore: added formatting check to circle-ci #733
Conversation
3b6c670
to
ee64b9e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but can we add proto as well.. BTW I thought we are doing this already (:
b8752ef
to
4a5f036
Compare
mhmhm. That's might be golang version issue ): |
which could make it quite difficult to contribute for people if we require certain golang version. However it might be the case that go1.11 vs go1.10 differs only, and seems like supporting go1.11 and above could work. |
Ignore me, it just a matter of pinning Do you know how to do it? It's quite easy - just mimick what |
hmm looking at the Makefile and @go get -u golang.org/x/tools/cmd/goimports I wasn't able to find any mention on goimport versions.. it looks like it's not versioned at all? But I ran the From those findings I'd suspect the formatting to depend on golang version as you said earlier. But I'm struggling to find any more info about this. How to reproduce:
docker run -it -v $PWD:/go/src/github.com/improbable-eng/thanos -w /go/src/github.com/improbable-eng/thanos golang:1.10 make format
git diff > golang1.10.patch
git reset --hard HEAD
docker run -it -v $PWD:/go/src/github.com/improbable-eng/thanos -w /go/src/github.com/improbable-eng/thanos golang:1.11 make format
git diff > golang1.11.patch
git reset --hard HEAD
diff --color golang1.10.patch golang1.11.patch |
What about this? I think this will help: #737 Can you review? (: |
Thanks, I totally overlooked the But still, running in clean containers should have download the same revisions and still there were differences. But I'll rebase on your PR and try. |
4a5f036
to
e12f2f0
Compare
Are you sure you used pinned version for |
Yes, I ran also directly the After some digging I found out that there were changes in formatting in Also https://tip.golang.org/pkg/go/format/ states
I'm trying to find out if I |
So.. The Possibly formatting using the docker as I posted before is pretty easy also but that assumes docker installed. |
Gee, I thought this will be just adding one line of yaml :D |
Thanks for great research! This is so annoying... So options:
I think 4 or 3 might good for quick win here, but not sure yet.
|
I'm looking at building Downloading go sources for given version, extracting the I'm not sure if I'm going the right direction. Will see I'll be off for few days now so hopefully will bet back to it asap. |
Well, we could fork goimports basically if neccessary ): |
I'd rather avoid forking if possible from the mIntainance point of view. |
echo "Code is not well formatted. Run 'make format' before pushing the code." | ||
exit 1 | ||
fi | ||
- run: make proto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could not run this command, because there is no protoc
binary in CI container. In my container, I also installed the protocol buffer implementation from https://github.com/google/protobuf and ran make proto
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, let's fix this in separate PR
I can download certain version of I'd decide between:
If anyone has other idea. |
Let's abort it for now... When we moved to go modules we would need to pin to 1.11+ so we can decide later. Thanks for this deep research @FUSAKLA! |
Looking at other projects about this issue in golang/go#26228 you can find some debated arguments on those issues:
And based on https://tip.golang.org/doc/go1.11:
|
Eventually I found the https://github.com/alecthomas/gometalinter which could possibly solve our issue. It already vendors in all the linters (check out the list there is loads of them), runs them in parallel and allows to configure them all using one JSON. The only downside it that it only checks the code. It doesn't modify it. Also installation is by downloading prebuilt binaries of those linters. GOMETALINTER_INSTALL_SCRIPT=https://raw.githubusercontent.com/alecthomas/gometalinter/master/scripts/install.sh
curl -sL $GOMETALINTER_INSTALL_SCRIPT | BINDIR=/go/bin TAG=v2.0.12 sh
gometalinter --deadline 10m --disable-all --enable=goimports [--enable possibly many other checks] This is all that is needed to check consistently on multiple golang versions. |
Could we not use that gometalinter in the CI/pre-commit step and still use the individual tools installed by this as |
Yes we can use those pre-built binaries as standalone commands and don't use the gometalinter. |
Signed-off-by: Martin Chodur <[email protected]>
e12f2f0
to
b078015
Compare
Yea, downloading them might be better, but the problem is that.. gometalinter does not use goimports at the very end anyway? |
closing this in favor of #1227 |
Signed-off-by: Martin Chodur [email protected]
Added check for code formatting to circle-ci
Changes