diff --git a/.travis.yml b/.travis.yml index af852d9..8d95e61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,10 @@ # https://docs.travis-ci.com/user/reference/overview/#virtualisation-environment-vs-operating-system sudo: false -dist: trusty +dist: xenial language: go go: - - "1.10" + - "1.11" # Only clone the most recent commit. git: @@ -16,41 +16,26 @@ env: before_install: # Dump environment variables - printenv - # Download the binary to bin folder in $GOPATH + # Download dep binary to bin folder in $GOPATH - curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o $GOPATH/bin/dep # Make the binary executable - chmod +x $GOPATH/bin/dep install: - - "go get -u github.com/jteeuwen/go-bindata/..." - - "dep ensure" + - "go get -u -v github.com/kevinburke/go-bindata/..." + - "go get -u -v honnef.co/go/tools/cmd/staticcheck" + - "make ensure" before_script: - - "go-bindata - -o=\"${GOPATH}/src/github.com/boramalper/magnetico/cmd/magneticow/bindata.go\" - -prefix=\"${GOPATH}/src/github.com/boramalper/magnetico/cmd/magneticow/data/\" - ${GOPATH}/src/github.com/boramalper/magnetico/cmd/magneticow/data/..." + - "make magneticod" + - "make magneticow" script: # The Unit Tests - - "go test github.com/boramalper/magnetico/cmd/magneticod/..." - - "go test github.com/boramalper/magnetico/cmd/magneticow/..." - - "go test github.com/boramalper/magnetico/pkg/persistence/..." + - "make test" # Static Analysis (vet) - - "go vet github.com/boramalper/magnetico/cmd/magneticod/..." - - "go vet github.com/boramalper/magnetico/cmd/magneticow/..." - - "go vet github.com/boramalper/magnetico/pkg/persistence/..." + - "make vet" - # Formatting Errors - # - # Since gofmt returns zero even if there are files to be formatted, we use: - # - # ! gofmt -d ${GOPATH}/path/ 2>&1 | read - # - # to return 1 if there are files to be formatted, and 0 if not. - # - # https://groups.google.com/forum/#!topic/Golang-Nuts/pdrN4zleUio - - "! gofmt -l ${GOPATH}/src/github.com/boramalper/magnetico/cmd/magneticod/ 2>&1 | read" - - "! gofmt -l ${GOPATH}/src/github.com/boramalper/magnetico/cmd/magneticow/ 2>&1 | read" - - "! gofmt -l ${GOPATH}/src/github.com/boramalper/magnetico/pkg/persistence/ 2>&1 | read" + # Check formatting + - "make check-formatting" diff --git a/Makefile b/Makefile index 81cc7de..65fab64 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: test format magneticod magneticow ensure test-magneticod test-magneticow test-persistence image image-magneticow image-magneticod +.PHONY: test format vet staticcheck magneticod magneticow ensure image image-magneticow image-magneticod all: test magneticod magneticow @@ -23,19 +23,32 @@ image: image-magneticod image-magneticow ensure: dep ensure -v -test-magneticod: - go test github.com/boramalper/magnetico/cmd/magneticod/... +vet: + go vet github.com/boramalper/magnetico/... -test-magneticow: - go test github.com/boramalper/magnetico/cmd/magneticow/... +staticcheck: + staticcheck github.com/boramalper/magnetico/... -test-persistence: - go test github.com/boramalper/magnetico/pkg/persistence/... - -test: test-persistence test-magneticod test-magneticow +test: + go test github.com/boramalper/magnetico/... format: - gofmt -w cmd/magneticod - gofmt -w cmd/magneticow - gofmt -w pkg/persistence + gofmt -w ${GOPATH}/src/github.com/boramalper/magnetico/cmd/ + gofmt -w ${GOPATH}/src/github.com/boramalper/magnetico/pkg/ +# Formatting Errors +# Since gofmt returns zero even if there are files to be formatted, we use: +# +# ! gofmt -d ${GOPATH}/path/ 2>&1 | read +# +# to return 1 if there are files to be formatted, and 0 if not. +# https://groups.google.com/forum/#!topic/Golang-Nuts/pdrN4zleUio +# +# How can I use Bash syntax in Makefile targets? +# Because `read` is a bash command. +# https://stackoverflow.com/a/589300/4466589 +# +check-formatting: SHELL:=/bin/bash # HERE: this is setting the shell for check-formatting only +check-formatting: + ! gofmt -l ${GOPATH}/src/github.com/boramalper/magnetico/cmd/ 2>&1 | tee /dev/fd/2 | read + ! gofmt -l ${GOPATH}/src/github.com/boramalper/magnetico/pkg/ 2>&1 | tee /dev/fd/2 | read diff --git a/README.md b/README.md index 359c919..2770e56 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # magnetico *Autonomous (self-hosted) BitTorrent DHT search engine suite.* -[![chat on gitter](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/magnetico-dev/magnetico-dev) [![Build Status on Travis CI](https://travis-ci.org/boramalper/magnetico.svg?branch=go-rewrite)](https://travis-ci.org/boramalper/magnetico) [![Build status on AppVeyor](https://ci.appveyor.com/api/projects/status/u2jtbe6jutya7p0x/branch/go-rewrite?svg=true)](https://ci.appveyor.com/project/boramalper/magnetico/branch/go-rewrite) +[![chat on gitter](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/magnetico-dev/magnetico-dev) [![Build Status on Travis CI](https://travis-ci.org/boramalper/magnetico.svg?branch=go-rewrite)](https://travis-ci.org/boramalper/magnetico) [![Build status on AppVeyor](https://ci.appveyor.com/api/projects/status/u2jtbe6jutya7p0x/branch/go-rewrite?svg=true)](https://ci.appveyor.com/project/boramalper/magnetico/branch/go-rewrite) magnetico is the first autonomous (self-hosted) BitTorrent DHT search engine suite that is *designed for end-users*. The suite consists of two packages: diff --git a/pkg/README.md b/pkg/README.md new file mode 100644 index 0000000..ceacb37 --- /dev/null +++ b/pkg/README.md @@ -0,0 +1,7 @@ +# magnetico/pkg +[![GoDoc](https://godoc.org/github.com/boramalper/magnetico?status.svg)](https://godoc.org/github.com/boramalper/magnetico) + +- The most significant package is `persistence`, that abstracts access to the + magnetico databases with different engines (currently, only SQLite). + +**For REST-ful magneticow API, see [https://app.swaggerhub.com/apis/boramalper/magneticow-api/](https://app.swaggerhub.com/apis/boramalper/magneticow-api/).**