Commit Graph

54 Commits (d55666043bf00a30c0698c5dbbd1645769f91c34)

Author SHA1 Message Date
Anastasis Andronidis e27a76ae81 hack and hooks scripts for generating swagger docs 2015-08-22 02:27:41 +02:00
Saad Ali ee89f55bb9 Merge pull request #12188 from eparis/godeps-clean-test
verify-godeps.sh script to make sure all of Godeps is easily reproducible
2015-08-19 16:57:22 -07:00
Eric Paris 3a2dd10545 Speed up pre-commit by always passing at least one file to programs
Some programs like the boilerplate or the flag checker will check the
whole repo if they aren't given a specific set of files to test. If you
use `git commit --amend` to change commit messages you will be calling
these functions with no args, and thus it take a lot longer to commit no
changes than it does to actually commit changes!
2015-08-16 22:15:24 -05:00
Eric Paris 823392e4e3 New test and commit hook to make sure changes to Godeps are reproducable
It is a pretty slow test (it downloads fresh) all of kube's Godeps, so only
run it when needed in pre-commit hook.

This also means that random changes to other non-kube repositories could
cause travis/shippable to just randomly stop working for all PRs which touch
Godeps after that moment (even though no changes have been made to Godeps by
us).  Examples would be things like other repos completely disappearing. Or
even the directory we include disappearing in master in the remote
project (even though the directory may exist at the commit we care
about) This is a bugwin godep, but it is a problem we have seen happen
with kube Godeps.
2015-08-14 14:21:43 -04:00
Eric Paris 8a91d86783 Speed up pre-commit boilerplate by only checking changed files
Although the boilerplate checker was very fast it can be faster. With
this change we can hand the boilerplate a list of files which need to be
checked or give it no files. If given no files it will run all files in
the repo. Before you had to explicitly tell the boiler checker the
'extention' of the the files.  In this case we let the checker figure it
out and load the headers as needed.

Doing the whole repo takes about 0.4 seconds. Doing a single go file
takes < .04 seconds.
2015-08-14 10:19:33 -04:00
Eric Paris f54098fe00 Verify all flag usage does not use _
This works by defining two 'static' lists in hack. The first is the list
of all flags in the project which use a `-` or an `_` in their name. All
files being processed by verify-flags-underscore.py (or all files in the
repo if no filename arguments are given) will be searched for flag
declaration using a simple regex. Its not super smart. If a flag is
found which is not in the static list it will complain/reject the commit
until a human adds it to the list. If we do not keep a static list of
flags it takes >.2 seconds to find them 'all' at runtime. Since this is
run in pre-commit saving every part of a second helps.

After it finds all of the flags it runs all of the arguments (or all
files in repo if no arguments) looking for usage of those flags which
includes an `_`. There are lots of places where these are false
positives. For example we have a flag named oom-adj-score but the kernel
calls it oom_adj_score. To handle this we keep a second 'whitelist' of
lines which are allowed to use these flag names with an `_`.

Running the entire git repo looking for flags in every golang file and
looking in every single file for bad usage takes about 8.75 seconds.

Running it in the precommit hook where we only check things that changed
takes about .06 seconds.
2015-08-12 16:17:02 -04:00
Eric Paris 3b7c39656c Split hack/{verify,update}-* files so we don't always go build
Right now some of the hack/* tools use `go run` and build almost every
time. There are some which expect you to have already run `go install`.
And in all cases the pre-commit hook, which runs a full build wouldn't
want to do either, since it just built!

This creates a new hack/after-build/ directory and has the scripts which
REQUIRE that the binary already be built. It doesn't test and complain.
It just fails miserably. Users should not be in this directory. Users
should just use hack/verify-* which will just do the build and then call
the "after-build" version. The pre-commit hook or anything which KNOWS
the binaries have been built can use the fast version.
2015-08-11 14:20:46 -04:00
Eric Paris 985fa94ebd Move description.sh from hack/ to hooks/
Just to get everything in one place...
2015-08-11 14:20:38 -04:00
Eric Paris 302cb7dc7f Move boilerplate from hooks/ to hack/
Hooks seems like they should be hooks. Not sure hack makes a lot more
sense, but it has more stuff already.
2015-08-11 14:20:38 -04:00
Eric Paris 340a99c373 Use hack/verify-boilerplate.sh in pre-commit hook
Using the hack/ version is probably a little slower, but it still only
takes about .2 seconds. So probably worth the reduction in code.
2015-08-10 17:41:36 -04:00
Veres Lajos 9f77e49109 typofix - https://github.com/vlajos/misspell_fixer 2015-08-08 22:31:48 +01:00
Dawn Chen 2abf5dfb1f Merge pull request #10498 from thockin/hostport-to-service
Fix leaking process in hostport proxy
2015-08-06 10:50:44 -07:00
Chao Xu 70a29c1a3a address comments, wait for travis pass 2015-07-27 21:08:02 -07:00
Chao Xu 464385281b add a tool in cmd/ to check links in go file. Currently it's only used to check the links in api descriptions (pkg/api/.../types.go). 2015-07-24 20:21:16 -07:00
Tim Hockin efa76b72ae Run the build once during presubmit 2015-07-02 14:43:43 -07:00
Tim Hockin 38bddc2a97 Fix boilerplate for sh to allow alt shebangs 2015-06-30 18:49:59 -07:00
nikhiljindal a89d2da249 Adding a script to verify that swagger spec is updated 2015-06-08 04:04:57 -07:00
Wojciech Tyczynski 33318f0162 Use generated DeepCopy methods. 2015-05-28 09:03:27 +02:00
Jeff Lowdermilk 3cf4d9b2e6 Delete fails on notfound errors.
If deleting multiple resources, command will continue on error and
report not found resources at the end.
2015-05-27 16:02:54 -07:00
Wojciech Tyczynski 2df11cea32 Automatically generate conversions 2015-05-20 17:11:18 +02:00
Tim Hockin 4e9d3f7700 Use color in pre-commit 2015-05-13 12:59:04 -07:00
Tim Hockin d0b2a418db Make git hooks print more nicely 2015-05-13 12:50:25 -07:00
Tim Hockin f11ba4a1b5 Switch git hooks to use pre-commit 2015-05-13 12:50:25 -07:00
Eric Paris b7365ccace Check if people copy, but do not update the boilerplate
We found in that someone just copied/pasted the boilerplate language into
their code. But the boilerplate contains 2014, not 2015. We have 2 ways
to fix this.

1) Update the boilerplate to 2015 so people would get the right one.
2) Update the boilerplate so it doesn't make sense and then warn when
people use it.

This PR takes the second option. While options #1 seems easier, it will
get wrong in 2016, 17, 18 and it's unlikely anyone remember why they
need to update the boilerplate text and the regex rewrite. So just
make the humans do a tiny bit more work now.
2015-05-12 21:26:44 -04:00
Eric Paris 71d54198ed Spelll extension gooder 2015-05-08 19:19:33 -04:00
Eric Paris b503214fee Fix boilerplate check crash if .go file has no comments
Clayton pointed out that if he created a file with no /* in it anywhere
the boilerplate logic would crash like:

$ hack/verify-boilerplate.sh
Traceback (most recent call last):
  File "hack/../hooks/boilerplate.py", line 87, in <module>
    sys.exit(main())
  File "hack/../hooks/boilerplate.py", line 83, in main
    if not file_passes(filename, extention, ref, p):
  File "hack/../hooks/boilerplate.py", line 38, in file_passes
    while data[0] != "/*\n":
IndexError: list index out of range

That is because we were just stripping everything before the first line
that contained exacly "/*".  If no such line existed it got to the end
and just kept going.

This does something smarter. We use a regex to look for one or more
lines which start // +build followed by a single newline and remove only
those.  This obviously found one place where the package name was above
the license and was being missed by both the old and the new checker.

It also fixed the python spew and just tells you your file fails.
2015-05-08 17:30:40 -04:00
Eric Paris c9cd50dc49 Check python files for valid license boilerplate 2015-05-04 18:37:47 -04:00
Eric Paris f4d0b8df3a Do all boilerplate checks in 1 python call
It's just a little bit faster.....

BEFORE:
$ time hack/verify-boilerplate.sh

real	0m9.378s
user	0m3.405s
sys	0m13.906s

AFTER:
$ time hack/verify-boilerplate.sh

real	0m0.181s
user	0m0.114s
sys	0m0.068s
2015-05-01 20:46:57 -04:00
Eric Paris 6b3a6e6b98 Make copyright ownership statement generic
Instead of saying "Google Inc." (which is not always correct) say "The
Kubernetes Authors", which is generic.
2015-05-01 17:49:56 -04:00
Eric Paris ddca8248fe Check v1beta3 description on git commit
v1beta3 is no longer a special little snowflake
2015-05-01 14:10:50 -04:00
nikhiljindal 7c99865c94 Fixing hooks/description to catch API fields without description tags 2015-04-28 18:32:15 -07:00
Vishnu Kannan 17446061b0 Turn on "description:" verification for v1beta3 API. 2015-03-06 23:53:35 +00:00
Tim Hockin 60e7002474 Fix errant error message from boilerplate check 2015-01-19 14:23:24 -08:00
Fumitoshi Ukai 54f498acd5 cloudprovider/gce: use golang.org/x/oauth2
code.google.com/p/goauth2 is deprecated.
use golang.org/x/oauth2 instead.

hooks/prepare-commit-msg ignore Godeps
for sh's boilerplate check.
2015-01-16 12:17:52 +09:00
Brendan Burns dc0d197c40 Fix a path in the error message. 2015-01-15 14:06:48 -08:00
Brendan Burns 718a563b1f Add a gendocs pre-submit hook. 2015-01-15 09:52:51 -08:00
Dawn Chen 9e99f9953a Fix the boilerplate issue for header with "Copyright 2015". 2015-01-05 13:27:30 -08:00
Brian Grant 2ac8400cb2 Add API documentation pre-commit hook. 2014-11-20 20:25:44 +00:00
Sam Ghods 98c3a00233 Adding files to Godeps should not trigger gofmt or boilerplate warnings 2014-09-03 17:00:30 -07:00
Clayton Coleman 693051c1ca Boilerplate should ignore Go build tags 2014-08-23 11:44:21 -04:00
derekwaynecarr 8c07a0f524 Fix verify-boilerplate 2014-08-15 13:12:01 -05:00
Daniel Smith 260af3017b Make boilerplate hook work for .sh files, too. 2014-06-25 17:11:48 -07:00
Daniel Smith e4c47f0219 Merge pull request #231 from brendandburns/hooks
Fixed the boilerplate hook to work on OS X, where apparently wc add's spaces
2014-06-24 15:12:25 -07:00
Daniel Smith 4f81008ab9 Merge pull request #230 from thockin/cleanups
Slightly friendlier pre-commit errors.
2014-06-24 15:11:08 -07:00
Brendan Burns 2c404aba0f Fixed the boilerplate hook to work on OS X, where apparently wc add's spaces 2014-06-24 15:02:48 -07:00
Tim Hockin b6d5faf276 Slightly friendlier pre-commit errors.
Make the pre-commit check spit out cut-and-paste commands and be more
obvious about errors.  Tested by making an invalid change and observing the
message generated.
2014-06-24 15:01:08 -07:00
Brendan Burns 20ba523266 Remove an erroneous debug statement. 2014-06-24 13:23:58 -07:00
Brendan Burns 5756189f0d Added a proxy server to cloudcfg 2014-06-24 11:15:08 -07:00
Daniel Smith 756ba6958d Add boilerplate checking to hook 2014-06-23 12:00:16 -07:00
Joe Beda d230625e1a Move third_party code under third_party/src so it can be used in $GOPATH. 2014-06-13 17:15:49 -07:00