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

Continuous Integration #47

Merged
merged 5 commits into from
Dec 29, 2017
Merged

Continuous Integration #47

merged 5 commits into from
Dec 29, 2017

Conversation

kriskowal
Copy link
Member

This change adds Travis configuration and Makefile details to run tests and lint.

@kriskowal
Copy link
Member Author

Luke, these are your father’s Makefiles.

@@ -62,7 +62,7 @@ func Draw(dst *display.Display, r image.Rectangle, src image.Image, sp image.Poi
DrawBitmap(dst, r, bits, sp, on)
}

// DrawBitmap
// DrawBitmap FIXME
Copy link
Member Author

Choose a reason for hiding this comment

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

Addressing this down the stack in #44

Copy link
Contributor

@jcorbin jcorbin left a comment

Choose a reason for hiding this comment

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

Can't say that I "approve" of all the imported cargo, and especially I think that "staticcheck" is a bridge too far at this point... but that could largely be out of lack of familiarity with it.

The "performance" remarks circa the makefile shell convolutions, I'm really more interested to chase to whatever upstream you're cargoing here, and aren't material to bork's "scale" ;-)

Per my comment on the go test ./... line, I suspect that much of the alacritty around "but not vendor" isn't necessary anymore.

Makefile Outdated
@@ -1,5 +1,84 @@
PACKAGES := $(shell ./scripts/packages.sh)
Copy link
Contributor

Choose a reason for hiding this comment

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

Strongly prefer these inlined, having them in a script only increases cognitive load.

Makefile Outdated

ERRCHECK_FLAGS ?= -ignoretests

# Files whose first line contains "Code generated by" are generated.
Copy link
Contributor

Choose a reason for hiding this comment

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

first line seems awfully strict... but ok, I guess we don't yet generate #! files ;-)

Makefile Outdated
# Files whose first line contains "Code generated by" are generated.
GENERATED_GO_FILES := $(shell \
find $(GO_FILES) \
-exec sh -c 'head -n1 {} | grep "Code generated by\|Automatically generated by " >/dev/null' \; \
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow so how about something more like:

find . -name '*.go' | \
    xargs grep -nm1 "Code generated by\|Automatically generated by" | \
    grep '\.go:[0-9]:' | cut -d: -f1
  • runs a batched number of greps (probably one for small projects)
  • runs one program (another grep) to implement "is in the first N lines (N=10 for mine)"
  • doesn't need to run a sub-shell for each file

So in short it runs N/g + 4 programs rather than 3*N + 1 programs (where g = (execveMaxBufferSize - length(ourGrepCommand)) / averageFileName .

(yes of course that should be shipped as find -print0 ... | xargs -0 ..., but the above reads clearer as a review comment ;-) )

But... where is all this coming from, we don't even code generate yet... do we have plans to?

Makefile Outdated
-exec sh -c 'head -n1 {} | grep "Code generated by\|Automatically generated by " >/dev/null' \; \
-print)

LINT_EXCLUDES_EXTRAS := bindata.go
Copy link
Contributor

Choose a reason for hiding this comment

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

why is it extra? do they not add a generated marker (i.e. I see a "Code generated by ..." in a project's bindata.go locally)

Makefile Outdated
test:
go test ./...
Copy link
Contributor

Choose a reason for hiding this comment

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

The prior suffices since go 1.9 (golang/go#19090) do we really have to cargo in all this plaque?

Makefile Outdated

.PHONY: install-ci
install-ci:
go get -u github.com/golang/dep/cmd/dep
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be one unified go get -u -v foo bar baz.

You could even get cute and go for go get -u -v github.com/golang/{dep/cmd/dep,lint/golint} github.com/{kisielk/errcheck} honnef.co/go/tools/cmd/staticcheck.

Either way, let's add that -v flag, so that travis console output becomes more debuggable Just In Case (tm).

Makefile Outdated
@[ ! -s "$(STATICCHECK_LOG)" ] || (echo "staticcheck failed:" | cat - $(STATICCHECK_LOG) && false)

.PHONY: lint
lint: gofmt govet golint errcheck staticcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

Would like to consider using https://github.com/alecthomas/gometalinter going forward at least, even if you'd rather not in this one...

@@ -109,6 +109,9 @@ func (c Cursor) Reset(buf []byte) ([]byte, Cursor) {
c.Foreground = Colors[7]
c.Background = Colors[0]
buf = append(buf, "\033[m"...)
// Adding this superfluous return worked around staticcheck SA4005:
Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh, than can we just not adopt staticcheck for now? Errcheck's signal/noise is just barely at "not annoying" levels, I don't have a feel yet for staticcheck; also I'm concerned because I've only ever encountered staticcheck in terms of "the one that goes really slow, so you probably don't want your editor running it everytime"... :notsureif:

Copy link
Contributor

Choose a reason for hiding this comment

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

Found dominikh/go-tools#141 for context, author says that check is broken and needs to be redone...

Copy link
Member Author

Choose a reason for hiding this comment

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

I’ve taken staticcheck out, but it did catch the reason my sigwinch's were not working, so now the showroom proof resizes properly.


.PHONY: install-ci
install-ci:
go get -u github.com/golang/dep/cmd/dep github.com/golang/lint/golint github.com/kisielk/errcheck
Copy link
Member Author

Choose a reason for hiding this comment

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

CI choked on curly brace expansion.

Copy link
Contributor

Choose a reason for hiding this comment

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

probably posix sh vs bash-ism fwiw

@kriskowal
Copy link
Member Author

Stripped down to minimum cargo. Somehow bindata’s not causing a problem, and we don’t have any other codegen that may or may not pass gofmt yet. Also clawed back some simplicity since we don’t need to filter logs to determine whether lint checks pass.

@kriskowal kriskowal merged commit 932c161 into master Dec 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants