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

Convert to go module and use GitHub Actions instead of Travis #8

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ First off, glad you're here and want to contribute! :heart:

## Getting Started

There are a number of dev tools required to work with Protokit. To make this a little cleaner and less invasive on your
global $GOPATH, we've elected to use [retool]. This also has the advantage of pinning things like `dep`, or
`protoc-gen-*` to specific versions to avoid inconsistencies between dev machines.

Running `make setup` will fetch [retool] (if it's not installed) and install vendored versions of dep and other tools in
the _tools/_ directory (git ignored). This should be sufficient to get you started.
It's always good to start simple. Clone the repo and `make test` to make sure you're starting from a good place.

## Submitting a PR

Expand All @@ -30,14 +25,12 @@ PR template that should help with this.
I don't want to be too dogmatic about this, but here are some general things I try to keep in mind:

* GoFmt all the things!
* Imports are grouped into external, stdlib, internal groups in each file (see any go file in this repo for an example)
* Test are defined in `<package>_test` packages to ensure only the public interface is tested
* If you export something, make sure you add appropriate godoc comments
* Imports are grouped into external, stdlib, internal groups in each file (see any go file in this repo for an example) - really just use `goimports` and be done with it.
* Test are defined in `<package>_test` packages to ensure only the public interface is tested.
* If you export something, make sure you add appropriate godoc comments and tests.

## Tagging a Release

* Set the `Version` in _version.go_
* Update CHANGELOG.md with the relevant changes
* `make release` - will commit everything, create a tag and push

[retool]: https://github.com/twitchtv/retool
26 changes: 26 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
strategy:
matrix:
go: [ '1.17.2' ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Tests
run: |
make test/ci

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/_tools
/bin
/coverage.txt
/vendor
2 changes: 0 additions & 2 deletions .gofmtignore

This file was deleted.

32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

46 changes: 0 additions & 46 deletions Gopkg.lock

This file was deleted.

37 changes: 0 additions & 37 deletions Gopkg.toml

This file was deleted.

56 changes: 42 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,57 @@
.PHONY: bench release setup test

TEST_PKGS = ./ ./utils
TOOLPATH = $(abspath bin)
VERSION = $(shell cat version.go | sed -n 's/.*const Version = "\(.*\)"/\1/p')

setup:
$(info Synching dev tools and dependencies...)
@if test -z $(which retool); then go get github.com/twitchtv/retool; fi
@retool sync
@retool do dep ensure
BOLD = \033[1m
CLEAR = \033[0m
CYAN = \033[36m

fixtures/fileset.pb: fixtures/*.proto
$(info Generating fixtures...)
@cd fixtures && go generate
help: ## Display this help
@awk '\
BEGIN {FS = ":.*##"; printf "Usage: make $(CYAN)<target>$(CLEAR)\n"} \
/^[a-z0-9]+([\/]%)?([\/](%-)?[a-z\-0-9%]+)*:.*? ##/ { printf " $(CYAN)%-15s$(CLEAR) %s\n", $$1, $$2 } \
/^##@/ { printf "\n$(BOLD)%s$(CLEAR)\n", substr($$0, 5) }' \
$(MAKEFILE_LIST)

bench:
##@ Test

test: fixtures/fileset.pb ## Run unit tests
@go test -race -cover $(TEST_PKGS)

test/bench: ## Run benchmark tests
go test -bench=.

test: fixtures/fileset.pb
@go test -race -cover ./ ./utils
test/ci: $(TOOLPATH)/goverage fixtures/fileset.pb test/bench ## Run CI tests include benchmarks with coverage
@bin/goverage -race -coverprofile=coverage.txt -covermode=atomic $(TEST_PKGS)

test-ci: fixtures/fileset.pb bench
@retool do goverage -race -coverprofile=coverage.txt -covermode=atomic ./ ./utils
##@ Release

release:
release: ## Release a new version
@echo Releasing v${VERSION}...
git add CHANGELOG.md version.go
git commit -m "Bump version to v${VERSION}"
git tag -m "Version ${VERSION}" "v${VERSION}"
git push && git push --tags

################################################################################
# Indirect targets
################################################################################
$(TOOLPATH)/goverage:
@echo "$(CYAN)Installing goverage...$(CLEAR)"
@TOOLPKG=github.com/haya14busa/goverage make build-tool

.PHONY: build-tool
build-tool:
@{ \
TMP_DIR=$$(mktemp -d); \
cd $$TMP_DIR; \
go mod init tmp; \
GOBIN=$(TOOLPATH) go get $(TOOLPKG); \
rm -rf $$TMP_DIR; \
}

fixtures/fileset.pb: fixtures/*.proto
$(info Generating fixtures...)
@cd fixtures && go generate
16 changes: 16 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module github.com/pseudomuto/protokit

go 1.17

require (
github.com/golang/protobuf v1.0.0
github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5
github.com/stretchr/testify v1.2.1
google.golang.org/genproto v0.0.0-20180427144745-86e600f69ee4
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/tools v0.1.9 // indirect
)
38 changes: 38 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.0.0 h1:lsek0oXi8iFE9L+EXARyHIjU5rlWIhhTkjDz3vHhWWQ=
github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5 h1:FdBGmSkD2QpQzRWup//SGObvWf2nq89zj9+ta9OvI3A=
github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5/go.mod h1:0YZ2wQSuwviXXXGUiK6zXzskyBLAbLXhamxzcFHSLoM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U=
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.9 h1:j9KsMiaP1c3B0OTQGth0/k+miLGTgLsAFUCrF2vLcF8=
golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto v0.0.0-20180427144745-86e600f69ee4 h1:0rk3/gV3HbvCeUzVMhdxV3TEVKMVPDnayjN7sYRmcxY=
google.golang.org/genproto v0.0.0-20180427144745-86e600f69ee4/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
13 changes: 0 additions & 13 deletions tools.json

This file was deleted.