Skip to content

Commit

Permalink
Sync v0.21.x with recently added apis (#56)
Browse files Browse the repository at this point in the history
* Implement list msgfee API; Implement ABCIPrefixQuery (#50)

* Implement ABCIPrefixQuery

* Implement msgfee api

* Generate swagger docs

* Implement ABCIPrefixQuery

* Implement msgfee api

* Generate swagger docs

* Fix test

* Improve docs

* Apply review recommendations

* Organize readme (#52)

* Add dockerize swagger docs generation (#53)

* Implement nonce api (#51)

* Implement get nonce with address API

* Implement get nonce with pubkey  API

* Apply review recommendations

* Implement ABCIKeyQueryIter (#58)

* Return multiple username on /username/owner (#59)

* Implement integration tests (#61)

* Prepare integration test code

* Add travis script; Edit readme

* Multisig contract it

* Fix multisig/contracts api; add it tests for the api

* Test EscrowEscrows handler

* Move testing tools to bnsapitest

* Fix escrow escrows test and handler

* Add ExtractOffsetFromParam func

* Add todo

* Refactor bns client and fix tests

* Delete hard coded testnet url

* Import dec and enc functions from bnscli

* Add new tests

* Implement ID tests

* Run go mod tidy

* Fix client

* Fix offset logic and queries

* Update docs

* Fix account owner test

* Implement tx submit endpoint (#54)

* Delete sub directories under handlers and move all to root (#62)

* Add username/resolve; delete static tendermint ip

* AccountResolveHandler rename; add endpoints to default handler

* Sync weave 0.21.x with master

* Downgrade tendermint and weave
  • Loading branch information
orkunkl authored Apr 3, 2020
1 parent 477a9e5 commit dc8e494
Show file tree
Hide file tree
Showing 32 changed files with 10,370 additions and 908 deletions.
104 changes: 56 additions & 48 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ language: go
dist: xenial

services:
- docker
- docker

addons:
apt:
packages:
- docker-ce
- apt-cacher-ng
- docker-ce
- apt-cacher-ng

cache:
directories:
Expand All @@ -21,12 +21,12 @@ cache:
- /var/cache/apt-cacher-ng

os:
- linux
- linux

go:
# When changing, remember to update MAIN_GO_VERSION below.
- "1.13.5"
- master
# When changing, remember to update MAIN_GO_VERSION below.
- "1.13.5"
- master

env:
global:
Expand All @@ -41,56 +41,64 @@ env:
- IMAGE_NAME="iov1/bnsapi:${BUILD_VERSION}"

install:
- wget --quiet https://github.com/tendermint/tendermint/releases/download/${TM_VERSION}/tendermint_${TM_VERSION}_linux_amd64.zip -O tendermint_linux_amd64.zip &&
unzip tendermint_linux_amd64.zip &&
sudo install -D -m 777 -o root tendermint /usr/local/bin
- wget --quiet https://github.com/tendermint/tendermint/releases/download/${TM_VERSION}/tendermint_${TM_VERSION}_linux_amd64.zip -O tendermint_linux_amd64.zip &&
unzip tendermint_linux_amd64.zip &&
sudo install -D -m 777 -o root tendermint /usr/local/bin
- wget --quiet https://github.com/swaggo/swag/releases/download/v1.6.5/swag_1.6.5_Linux_i386.tar.gz -O swag_linux_amd64.zip &&
tar -xvzf swag_linux_amd64.zip;
sudo install -D -m 777 -o root swag /usr/local/bin

script:
- set -eo pipefail
# TODO uncomment when bnsd is imported
# - make protolint
# - make protodocs
- make install
- make all
# - if [[ "$TRAVIS_GO_VERSION" == "$MAIN_GO_VERSION" ]]; then
# make cover;
# ./coverage/upload.sh;
# fi;
- printenv TRAVIS_COMMIT_MESSAGE > commit.msg
- unset TRAVIS_COMMIT_MESSAGE && printenv | grep -Ev "PATH|path|GEM" > env.list
- export TRAVIS_COMMIT_MESSAGE=`cat commit.msg` && rm -rf commit.msg
# - docker run -it --rm --env-file env.list -v "$(pwd):/usr/src/app" iov1ops/danger:latest > danger.out; cat danger.out
- if [[ "$TRAVIS_GO_VERSION" == "$MAIN_GO_VERSION" && "$TRAVIS_OS_NAME" == "linux" ]]; then
release_latest=$( [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_TAG" == "" && "$TRAVIS_PULL_REQUEST_BRANCH" == "" ]] && echo "yes" || echo "no" );
release_tag=$( [[ "$TRAVIS_TAG" != "" ]] && echo "yes" || echo "no" );

if [[ $release_latest == "yes" || $release_tag == "yes" ]]; then
make dist;
fi;
- set -eo pipefail
# TODO uncomment when bnsd is imported
# - make protolint
# - make protodocs
- make swaggerdocs
- make install
- make all
# - if [[ "$TRAVIS_GO_VERSION" == "$MAIN_GO_VERSION" ]]; then
# make cover;
# ./coverage/upload.sh;
# fi;
- printenv TRAVIS_COMMIT_MESSAGE > commit.msg
- unset TRAVIS_COMMIT_MESSAGE && printenv | grep -Ev "PATH|path|GEM" > env.list
- export TRAVIS_COMMIT_MESSAGE=`cat commit.msg` && rm -rf commit.msg
# - docker run -it --rm --env-file env.list -v "$(pwd):/usr/src/app" iov1ops/danger:latest > danger.out; cat danger.out
- if [[ "$TRAVIS_GO_VERSION" == "$MAIN_GO_VERSION" && "$TRAVIS_OS_NAME" == "linux" ]]; then
release_latest=$( [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_TAG" == "" && "$TRAVIS_PULL_REQUEST_BRANCH" == "" ]] && echo "yes" || echo "no" );
release_tag=$( [[ "$TRAVIS_TAG" != "" ]] && echo "yes" || echo "no" );

if [[ $release_latest == "yes" ]]; then
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin;
docker tag "iov1/bnsapi:${BUILD_VERSION}" "iov1/bnsapi:latest" ;
docker push "iov1/bnsapi:latest";
docker logout;
fi;
if [[ $release_latest == "yes" || $release_tag == "yes" ]]; then
make dist;
fi;

if [[ $release_tag == "yes" ]]; then
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin;
docker tag "iov1/bnsapi:${BUILD_VERSION}" "iov1/bnsapi:$TRAVIS_TAG" ;
docker push "iov1/bnsapi:$TRAVIS_TAG";
docker logout;
if [[ -z "$IT_TENDERMINT" ]]; then
(cd cmd/bnsapi; make it-test);
fi;

if [[ $release_latest == "yes" ]]; then
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin;
docker tag "iov1/bnsapi:${BUILD_VERSION}" "iov1/bnsapi:latest" ;
docker push "iov1/bnsapi:latest";
docker logout;
fi;

if [[ $release_tag == "yes" ]]; then
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin;
docker tag "iov1/bnsapi:${BUILD_VERSION}" "iov1/bnsapi:$TRAVIS_TAG" ;
docker push "iov1/bnsapi:$TRAVIS_TAG";
docker logout;
fi;
fi;
fi;

notifications:
email: false

# whitelist long living branches to avoid testing feature branches twice (as branch and as pull request)
branches:
only:
- master
- /^v[0-9]+\.[0-9]+\.x$/
- /^v[0-9]+\.[0-9]+\.[0-9]+$/
# milestone releases
- weave-v0.21.x
- master
- /^v[0-9]+\.[0-9]+\.x$/
- /^v[0-9]+\.[0-9]+\.[0-9]+$/
# milestone releases
- weave-v0.21.x
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test:
# go install -mod=readonly ./cmd/bnscli # TODO uncomment when bnsd/bnscli is imported

go vet -mod=readonly ./...
go test -mod=readonly -race ./...
go test -mod=readonly -race -short ./...

lint:
@go mod vendor
Expand Down Expand Up @@ -79,3 +79,6 @@ protogen:
protodocs:
./scripts/clean_protos.sh
./scripts/build_protodocs_docker.sh

swaggerdocs:
cd cmd/bnsapi && make docs && cd -;
13 changes: 11 additions & 2 deletions cmd/bnsapi/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.PHONY: all dist clean build install image test run
.PHONY: all dist clean build install image test run swagger-docs

BUILD_VERSION ?= manual
BUILD_FLAGS := -mod=readonly -ldflags "-X main.buildHash=`git log -1 --pretty=format:"%H"` -X util.BuildVersion=${BUILD_VERSION}"
IMAGE_NAME = "iov1/bnsapi:${BUILD_VERSION}"
SWAG_BASE := docker run --rm -v $(shell pwd):/work iov1/swag-docker:latest
DOCKER_BUILD_FLAGS := -a -installsuffix cgo
BUILDOUT ?= bnsapi

Expand All @@ -23,7 +24,15 @@ image:
docker build --pull -t $(IMAGE_NAME) .

test:
go test -mod=readonly -race ./...
go test -mod=readonly -race -short ./...

it-test:
go test -mod=readonly -run Integration ./...

run:
go run .

swagger-docs:
@cp -r ../../vendor .
$(SWAG_BASE) swag init --parseVendor
@rm -rf vendor
24 changes: 19 additions & 5 deletions cmd/bnsapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ serialization and REST for API.
This service is intended to provide very little logic and should be save to be
exposed to the public.


This application follows [12 factor app](https://12factor.net/) principles as
close as possible.

- Logs are written to stdout.
- Configuration is done via environment variables.


# Configuration
## Configuration

To configure `bnsapi` instance use environment variables.

Expand All @@ -32,8 +30,24 @@ result can be paginated using `offset=<key>`. Offset is inclusive.
Each listing result can be filtered using at most one filter at a time.
`offset` is not a filter.

## Docs
## Swagger Docs

To see documentation:
- Run the project `make run`

- Run the project `make run`.
- Go to `localhost:$PORT/docs`

### Generating docs

- Install [go swag]($ go get -u github.com/swaggo/swag/cmd/swag) globally.
- `go mod vendor`
- `swag init -parseVendor`

## Integration tests

- Set environment value `IT_TENDERMINT` to the address of the network to test against
- run `make it-test`

## Development

Make sure to enable `export GO111MODULE=on`
Loading

0 comments on commit dc8e494

Please sign in to comment.