fixed travis, added vet and staticcheck in makefile, modified READMEs

This commit is contained in:
Bora M. Alper 2018-12-30 08:21:56 +03:00
parent 3d80f7375c
commit eea341407d
No known key found for this signature in database
GPG Key ID: 8F1A9504E1BD114D
4 changed files with 45 additions and 40 deletions

View File

@ -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"

View File

@ -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

View File

@ -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:

7
pkg/README.md Normal file
View File

@ -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/).**