-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
improve repo tooling #805
improve repo tooling #805
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: BenTheElder The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
050c09f
to
7e5fb90
Compare
7e5fb90
to
6360dd0
Compare
/retest |
GO111MODULE=on bin/golangci-lint \ | ||
--enable=golint --enable=vet --enable=gofmt \ | ||
--enable=misspell \ | ||
run ./pkg/... ./cmd/... . |
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.
this includes staticcheck and other lints by default, we're explicitly enabling a few that are not on by default:
- standard go lints (golint, vet, gofmt)
- misspell
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.
iterative (hot) run:
[bentheelder@bentheelder-macbookpro:~/go/src/sigs.k8s.io/kind·2019-08-22T21:38:14-0700·shell-nits@245ca10]
$ time hack/verify/lint.sh
real 0m7.842s
user 0m23.441s
sys 0m4.258s
much faster than running these individually.
I'm exploring the additional lints we can enable, but may leave that for a follow up.
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.
that's progress
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.
it's more like a minute on a cold run, but that's not bad considering how much static analysis we're getting. this already caught some bugs we hadn't before, just with the default checks.
k8s.io/code-generator v0.0.0-20190311093542-50b561225d70 | ||
k8s.io/gengo v0.0.0-20190327210449-e17681d19d3a // indirect | ||
k8s.io/klog v0.3.0 // indirect | ||
) | ||
|
||
// deal with golangci-lint being broken |
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.
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.
basically: go 1.13 is stricter about the timestamps matching the source when using a pseudo-version, the module proxy is equally strict now even in 1.12 / 1.11. golangci-lint needs to update their go.mod upstream, there are PRs open for this.
/cc @aojea |
cd "${REPO_ROOT}" | ||
fi | ||
|
||
if [[ "${VERIFY_SPELLING:-true}" == "true" ]]; then |
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.
these are all in lint.sh now, by way of golangci-lint
SOURCE_DIR="${SOURCE_DIR:-$(pwd -P)}" | ||
# default to disabling CGO for easier reproducible builds and cross compilation | ||
export CGO_ENABLED="${CGO_ENABLED:-0}" | ||
# the container image, by default a recent official golang image |
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.
when do you say recent do you want to do this smarter?
https://gist.github.com/n8henrie/1043443463a4a511acf98aaa4f8f0f69#file-get_golang-sh-L11
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.
we could use golang:latest
but that might get a bit surprising ... probably best to periodically manually update it.
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.
(also golang:latest
actually works currently, but it's not reproducible..., this is)
|
||
# cd to the repo root |
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.
why do you move this before checking?
if there are no arguments and the next if
fails we don't need to cd to the repo root, right?
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.
for consistency with the other scripts. it doesn't matter but it's easier to spot check these between the scripts (EG if we tweak the REPO_ROOT
logic)
/lgtm |
@@ -1,58 +0,0 @@ | |||
#!/usr/bin/env bash |
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.
this was unintentional, I think...
set
on one line in all of the scripts, it's shorter and just as clearBASH_SOURCE[0]
+pwd -P
trick instead ofgit ...
to make scripts work from tarballs etc. instead of just from git clonesgo_container.sh
and move it up tohack/
since we want people to use thisgolangci-lint