Skip to content

Commit

Permalink
Merge pull request #122 from prasek/ci
Browse files Browse the repository at this point in the history
ci enhancements
  • Loading branch information
jhump authored Apr 16, 2018
2 parents cfdba73 + ad5847c commit 5cc2142
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 106 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
internal/testprotos/protoc
coverage.out
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ sudo: false

matrix:
include:
- go: 1.6
- go: 1.7
- go: 1.8
- go: 1.9
- go: "1.7"
- go: "1.8"
- go: "1.9"
- go: "1.10"
- go: tip

# accomodate forks
before_install:
- mkdir -p $TRAVIS_BUILD_DIR $GOPATH/src/github.com/jhump
- test ! -d $GOPATH/src/github.com/jhump/protoreflect && mv $TRAVIS_BUILD_DIR $GOPATH/src/github.com/jhump/protoreflect || true

script:
- ./ci.sh
- make
88 changes: 88 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# TODO: run golint, errcheck, staticcheck, unused
.PHONY: default
default: deps checkgofmt vet predeclared test

.PHONY: ci
ci: deps checkgofmt vet predeclared testcover

.PHONY: deps
deps:
go get -d -v -t ./...

.PHONY: updatedeps
updatedeps:
go get -d -v -t -u -f ./...

.PHONY: install
install:
go install ./...

.PHONY: checkgofmt
checkgofmt:
@if [ -n "$$(go version | awk '{ print $$3 }' | grep -v devel)" ]; then \
gofmt -s -l . ; \
if [ -n "$$(gofmt -s -l .)" ]; then \
echo "Run gofmt on the above files!"; \
exit 1; \
fi; \
fi

# workaround https://github.com/golang/protobuf/issues/214 until in master
.PHONY: vet
vet:
@echo go vet ./... --ignore internal/testprotos
@for dir in $$(go list ./... | grep -v 'internal/testprotos'); do \
go vet $$dir ; \
done

.PHONY: staticcheck
staticcheck:
@go get honnef.co/go/tools/cmd/staticcheck
staticcheck ./...

.PHONY: unused
unused:
@go get honnef.co/go/tools/cmd/unused
unused ./...

.PHONY: ineffassign
ineffassign:
@go get github.com/gordonklaus/ineffassign
ineffassign .

.PHONY: predeclared
predeclared:
@go get github.com/nishanths/predeclared
predeclared .

# Intentionally omitted from CI, but target here for ad-hoc reports.
.PHONY: golint
golint:
@go get github.com/golang/lint/golint
golint -min_confidence 0.9 -set_exit_status ./...

# Intentionally omitted from CI, but target here for ad-hoc reports.
.PHONY: errchack
errcheck:
@go get github.com/kisielk/errcheck
errcheck ./...

.PHONY: test
test:
go test -cover -race ./...

.PHONY: generate
generate:
go generate github.com/jhump/protoreflect/internal/testprotos/

.PHONY: testcover
testcover:
@echo go test -covermode=atomic ./...
@echo "mode: atomic" > coverage.out
@for dir in $$(go list ./...); do \
go test -race -coverprofile profile.out -covermode=atomic $$dir ; \
if [ -f profile.out ]; then \
tail -n +2 profile.out >> coverage.out && rm profile.out ; \
fi \
done

23 changes: 0 additions & 23 deletions ci.sh

This file was deleted.

4 changes: 3 additions & 1 deletion desc/descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,9 @@ func createMessageDescriptor(fd *FileDescriptor, parent Descriptor, enclosing st
// proto.ExtensionRange is inclusive (and that's how extension ranges are defined in code).
// but protoc converts range to exclusive end in descriptor, so we must convert back
end := r.GetEnd() - 1
ret.extRanges = append(ret.extRanges, proto.ExtensionRange{r.GetStart(), end})
ret.extRanges = append(ret.extRanges, proto.ExtensionRange{
Start: r.GetStart(),
End: end})
}
sort.Sort(ret.extRanges)
ret.isProto3 = fd.isProto3
Expand Down
Loading

0 comments on commit 5cc2142

Please sign in to comment.