diff --git a/.circleci/config.yml b/.circleci/config.yml index 2e2f0f9..8b166d3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,5 +16,8 @@ jobs: paths: - "/go/pkg" - run: - name: test - command: go test + name: tests + command: ./test.bash + - run: + name: fmt + command: ./fmt-check.bash diff --git a/README.md b/README.md index 3bf0eea..278ecab 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,17 @@ You can also use @[stefanmaric](https://github.com/stefanmaric)'s Make an issue or a pull request! :) Remember to `fmt` your `.go`s 😆 +There are also some useful commands at the root of this directory. +They're bash executables since that's how [Go's +source](https://github.com/golang/go/tree/master/src) handles similar +scripts. The list follows: + +- `test.bash`: Runs `go test` in all the submodules of this repo. +- `fmt.bash`: Runs `go fmt` in all the submodules of this repo. +- `fmt-check.bash`: Runs `go fmt -l .` in all the submodules of this + repo. If it finds files that don't have the proper formatting, it + will exit with status code 1. We use this one for CI purposes + ## How to deploy ### Creating a Telegram Bot diff --git a/fmt-check.bash b/fmt-check.bash new file mode 100755 index 0000000..23e54f4 --- /dev/null +++ b/fmt-check.bash @@ -0,0 +1,3 @@ +if [[ $(cd gh && gofmt -l .) ]]; then exit 1; fi +if [[ $(cd handler && gofmt -l .) ]]; then exit 1; fi +if [[ $(cd tg && gofmt -l .) ]]; then exit 1; fi diff --git a/fmt.bash b/fmt.bash new file mode 100755 index 0000000..56b2713 --- /dev/null +++ b/fmt.bash @@ -0,0 +1,3 @@ +(cd gh && go fmt $@) +(cd handler && go fmt $@) +(cd tg && go fmt $@) diff --git a/gh/go.mod b/gh/go.mod new file mode 100644 index 0000000..6d7c5e0 --- /dev/null +++ b/gh/go.mod @@ -0,0 +1,8 @@ +module github.com/berserktech/telebot/gh + +go 1.12 + +require ( + github.com/stretchr/testify v1.3.0 + gopkg.in/go-playground/webhooks.v5 v5.6.0 +) diff --git a/gh/go.sum b/gh/go.sum new file mode 100644 index 0000000..039221b --- /dev/null +++ b/gh/go.sum @@ -0,0 +1,9 @@ +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/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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +gopkg.in/go-playground/webhooks.v5 v5.6.0 h1:z7O1sg1HiNQjoZKALAD6YMcZWgVCgYQmBjoVrbNv3+c= +gopkg.in/go-playground/webhooks.v5 v5.6.0/go.mod h1:LZbya/qLVdbqDR1aKrGuWV6qbia2zCYSR5dpom2SInQ= diff --git a/go.mod b/go.mod index e2ce366..99290e3 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,7 @@ module github.com/berserktech/telebot go 1.12 require ( - github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible - github.com/stretchr/testify v1.3.0 - github.com/technoweenie/multipartstreamer v1.0.1 // indirect - gopkg.in/go-playground/webhooks.v5 v5.6.0 + github.com/berserktech/telebot/gh v0.0.0-20190304044943-f23b8172bf1b + github.com/berserktech/telebot/handler v0.0.0-20190304044943-f23b8172bf1b + github.com/berserktech/telebot/tg v0.0.0-20190304044943-f23b8172bf1b ) diff --git a/go.sum b/go.sum index df8b381..63d9140 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,13 @@ +github.com/berserktech/telebot/gh v0.0.0-20190304043952-352c432d8ea3 h1:SxKGhReIAy12PWQ0/8dXtLkOb5waWOY3cuMXSDM4jdk= +github.com/berserktech/telebot/gh v0.0.0-20190304043952-352c432d8ea3/go.mod h1:+JYyEG3Yiew/VkGIxDGMQslPsVdDixTNNUwVbXSg900= +github.com/berserktech/telebot/gh v0.0.0-20190304044943-f23b8172bf1b h1:DOfFYj0Vhx2Cmu3rh/S7SIbr1cxhuGyFLvPgS+KnM0g= +github.com/berserktech/telebot/gh v0.0.0-20190304044943-f23b8172bf1b/go.mod h1:+JYyEG3Yiew/VkGIxDGMQslPsVdDixTNNUwVbXSg900= +github.com/berserktech/telebot/handler v0.0.0-20190304044943-f23b8172bf1b h1:GoIBGK5HeG8qcyIHnIwgjKyUwR1e617fmwPevixYZLg= +github.com/berserktech/telebot/handler v0.0.0-20190304044943-f23b8172bf1b/go.mod h1:ayZ7mPlETwebs6UjLIETqbAhA3RgfsnjQuMeJmWTMgc= +github.com/berserktech/telebot/tg v0.0.0-20190304043952-352c432d8ea3 h1:fenIkzK1Te5elymv+/BSmLoAEyFCSc4qMkCUdUmKAsk= +github.com/berserktech/telebot/tg v0.0.0-20190304043952-352c432d8ea3/go.mod h1:UmjW19xAK+WFJnyvM+TFFZeueQaaFfVKoqDInnNpFvM= +github.com/berserktech/telebot/tg v0.0.0-20190304044943-f23b8172bf1b h1:FOBJKVal+u6FkcPY1dYp6Y2KPAXUK6dTnSx5c2B6nTU= +github.com/berserktech/telebot/tg v0.0.0-20190304044943-f23b8172bf1b/go.mod h1:UmjW19xAK+WFJnyvM+TFFZeueQaaFfVKoqDInnNpFvM= 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/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU= diff --git a/handler/go.mod b/handler/go.mod new file mode 100644 index 0000000..da7de8d --- /dev/null +++ b/handler/go.mod @@ -0,0 +1,9 @@ +module github.com/berserktech/telebot/handler + +go 1.12 + +require ( + github.com/berserktech/telebot/gh v0.0.0-20190304044943-f23b8172bf1b + github.com/berserktech/telebot/tg v0.0.0-20190304044943-f23b8172bf1b + github.com/technoweenie/multipartstreamer v1.0.1 // indirect +) diff --git a/handler/go.sum b/handler/go.sum new file mode 100644 index 0000000..154c745 --- /dev/null +++ b/handler/go.sum @@ -0,0 +1,18 @@ +github.com/berserktech/telebot/gh v0.0.0-20190304043952-352c432d8ea3 h1:SxKGhReIAy12PWQ0/8dXtLkOb5waWOY3cuMXSDM4jdk= +github.com/berserktech/telebot/gh v0.0.0-20190304043952-352c432d8ea3/go.mod h1:+JYyEG3Yiew/VkGIxDGMQslPsVdDixTNNUwVbXSg900= +github.com/berserktech/telebot/gh v0.0.0-20190304044943-f23b8172bf1b h1:DOfFYj0Vhx2Cmu3rh/S7SIbr1cxhuGyFLvPgS+KnM0g= +github.com/berserktech/telebot/gh v0.0.0-20190304044943-f23b8172bf1b/go.mod h1:+JYyEG3Yiew/VkGIxDGMQslPsVdDixTNNUwVbXSg900= +github.com/berserktech/telebot/tg v0.0.0-20190304043952-352c432d8ea3 h1:fenIkzK1Te5elymv+/BSmLoAEyFCSc4qMkCUdUmKAsk= +github.com/berserktech/telebot/tg v0.0.0-20190304043952-352c432d8ea3/go.mod h1:UmjW19xAK+WFJnyvM+TFFZeueQaaFfVKoqDInnNpFvM= +github.com/berserktech/telebot/tg v0.0.0-20190304044943-f23b8172bf1b h1:FOBJKVal+u6FkcPY1dYp6Y2KPAXUK6dTnSx5c2B6nTU= +github.com/berserktech/telebot/tg v0.0.0-20190304044943-f23b8172bf1b/go.mod h1:UmjW19xAK+WFJnyvM+TFFZeueQaaFfVKoqDInnNpFvM= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU= +github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM= +github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= +gopkg.in/go-playground/webhooks.v5 v5.6.0 h1:z7O1sg1HiNQjoZKALAD6YMcZWgVCgYQmBjoVrbNv3+c= +gopkg.in/go-playground/webhooks.v5 v5.6.0/go.mod h1:LZbya/qLVdbqDR1aKrGuWV6qbia2zCYSR5dpom2SInQ= diff --git a/handler/handler_test.go b/handler/handler_test.go deleted file mode 100644 index 99693c8..0000000 --- a/handler/handler_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package handler - -import ( - "net/http/httptest" - "os" - "testing" -) - -// To run this test, run the following command. Remember to replace the values with valid tokens and IDs: -// PORT=3000 TELEGRAM_TOKEN="TELEGRAM_TOKEN" TELEGRAM_CHAT_ID="TELEGRAM_CHAT_ID" INTEGRATION_TEST=true go test -func TestHandler(t *testing.T) { - if os.Getenv("INTEGRATION_TEST") != "" { - Handler(httptest.NewRecorder(), eventRequest("ping", "")) - } -} diff --git a/test.bash b/test.bash new file mode 100755 index 0000000..3e8c8ff --- /dev/null +++ b/test.bash @@ -0,0 +1,3 @@ +go test ./gh +go test ./tg +go test ./handler diff --git a/tg/go.mod b/tg/go.mod new file mode 100644 index 0000000..bf3f6d2 --- /dev/null +++ b/tg/go.mod @@ -0,0 +1,8 @@ +module github.com/berserktech/telebot/tg + +go 1.12 + +require ( + github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible + github.com/technoweenie/multipartstreamer v1.0.1 // indirect +) diff --git a/tg/go.sum b/tg/go.sum new file mode 100644 index 0000000..8a78530 --- /dev/null +++ b/tg/go.sum @@ -0,0 +1,4 @@ +github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU= +github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM= +github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM= +github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=