Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/v0.25dev' into stdevAlDen_t34_…
Browse files Browse the repository at this point in the history
…hardware-wallet_tests

Conflicts:
	Makefile
ref #34
  • Loading branch information
Alvaro Denis committed May 21, 2019
2 parents 3d20e38 + 5112f83 commit e3cb4bd
Show file tree
Hide file tree
Showing 12 changed files with 25,272 additions and 918 deletions.
42 changes: 28 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,56 @@ services:
- docker
language: go
go:
- "1.11.x"

matrix:
include:
- os: linux
dist: xenial
- os: osx
osx_image: xcode8.3

before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update -qq; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update -qq;
fi
- ./ci-scripts/install-travis-gcc.sh
- eval "CC=gcc-6 && CXX=g++-6"

env:
global:
- BUILD_DIR: build
- BUILDLIB_DIR: $BUILD_DIR/libskycoin
- BUILDLIB_DIR: "$BUILD_DIR/libskycoin"
- LIB_DIR: lib
- CGO_ENABLED: 1
- VERSION_UPGRADE_TEST_WAIT_TIMEOUT: 60s
- PATH_DIR: $GOPATH/src/github.com/skycoin/libskycoin/


- PATH_DIR: "$GOPATH/src/github.com/skycoin/libskycoin/"
install:
# Install gox
- go get github.com/gz-c/gox
- go get -t ./...
- make install-linters
- VERSION=1.10.2 ./ci-scripts/install-golangci-lint.sh
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" && mkdir ${DEPS_DIR} && cd ${DEPS_DIR} && travis_retry wget --no-check-certificate https://cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz && echo "f3546812c11ce7f5d64dc132a566b749 *cmake-3.3.2-Linux-x86_64.tar.gz" > cmake_md5.txt && md5sum -c cmake_md5.txt && tar -xvf cmake-3.3.2-Linux-x86_64.tar.gz > /dev/null && mv cmake-3.3.2-Linux-x86_64 cmake-install && PATH=${DEPS_DIR}/cmake-install:${DEPS_DIR}/cmake-install/bin:$PATH && cd ${TRAVIS_BUILD_DIR}; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
sudo apt-get install cmake ;
fi
- make install-deps-libc
- make install-lib-curl

script:
- make check

before_deploy:
- export VERSION="$(git describe --tags --exact-match HEAD 2> /dev/null)"
- export ARCH="$(uname -m)"
- export OS="$(uname -s)"
- make build
- tar -c -z -f libskycoin-${VERSION}-${OS}-${ARCH}.tar.gz -C build ./*
deploy:
- provider: releases
api_key:
secure: ZqagrrwPFXs4bgHV9lJkZaex6dxAEUJprSdhsqJLYTkF4uBN5VYNM4KCy+azBabV8pVLxiCCZ8G/ocRw+omQgzJ/1lymNtYez8C/SLAuKzOFxdTxkvyQ9pW5Xr+fjptTEpe/E/lRYvS6LFtQEEpbrtjW/km9HWc7EdMNxUaGhBCRun0YhK3a7JSpQE7JbsyR691Zco8hLb2b5PO8qYx5NoVWHKPMLMYUZhbSZbWs0Viu8s8t9VLVhrSIudAKnQiNs5viWp0YZy6U6mRMuBeZ7wazebx0d/BAj78f+atGOZIiJbHgOxupnhhgR10X7b5B89JggxVe3IFr5t96qz3VV4aTl1yuLZ3i8eYanMIvdirnpPU36bbfAVMJuG7L4hFmZ+pD22ZmiOI4COqHDxSd0gF8DUri+Cf9S+5RF5Kk3YBArQzdue6DjNPBtKyQja1xINfj3Go2LQnaKH+/ffzBJIlw9TICcqf241FS3bNtx0QvUDV/+ezqy0dcD7xKOoUQmLDhyWt5NltNKu/JjoCwj99B9P45GQHJCrSvMu71hwNYlTJxtTJuLIVRXqI5BUEGpnBK99MV+6nycl0ePla4zXTBbJ/uOFzwfj1njAdw2DT4ceTsvtkTAc9qEi3S1hrRL2z3mHQ4loZCTJ9Nn9Cx0WOgfs/bCDvExa7b+AJ3ScE=
file:
- libskycoin-${VERSION}-${OS}-${ARCH}.tar.gz
skip_cleanup: true
draft: true
overwrite: true
on:
repo: skycoin/hardware-wallet
tags: true
notifications:
email: false
webhooks: https://fathomless-fjord-24024.herokuapp.com/notify
webhooks: https://fathomless-fjord-24024.herokuapp.com/notify
431 changes: 3 additions & 428 deletions CHANGELOG.md

Large diffs are not rendered by default.

33 changes: 17 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DEFAULT_GOAL := help
.PHONY: test-libc test-lint build-libc check
.PHONY: install-linters format clean-libc format-libc lint-libc
.PHONY: install-linters format clean-libc format-libc lint-libc docs

COIN ?= skycoin

Expand Down Expand Up @@ -28,7 +28,8 @@ BIN_DIR = bin
DOC_DIR = docs
INCLUDE_DIR = include
LIBSRC_DIR = lib/cgo
LIBDOC_DIR = $(DOC_DIR)/libc
LIBSKYDOC_DIR = $(DOC_DIR)/libc
LIBCURLDOC_DIR = $(DOC_DIR)/curl
SWAGGER_SPEC_DIR = lib/swagger
SWAGGER_CLIENT_DIR = lib/curl

Expand Down Expand Up @@ -92,14 +93,13 @@ $(BUILDLIB_DIR)/libskycoin.a: $(LIB_FILES) $(SRC_FILES) $(HEADER_FILES)
go build -buildmode=c-archive -o $(BUILDLIB_DIR)/libskycoin.a $(LIB_FILES)
mv $(BUILDLIB_DIR)/libskycoin.h $(INCLUDE_DIR)/

## Build libskycoin C static library
build-libc-static: $(BUILDLIB_DIR)/libskycoin.a
build-libc-static: $(BUILDLIB_DIR)/libskycoin.a ## Build libskycoin C static library

## Build libskycoin C shared library
build-libc-shared: $(BUILDLIB_DIR)/libskycoin.so
build-libc-shared: $(BUILDLIB_DIR)/libskycoin.so ## Build libskycoin C shared library

## Build libskycoin C client libraries
build-libc: configure-build build-libc-static build-libc-shared
build-libc: configure-build build-libc-static build-libc-shared ## Build libskycoin C client libraries

build: build-libc ## Build all C libraries

## Build libskycoin C client library and executable C test suites
## with debug symbols. Use this target to debug the source code
Expand All @@ -120,11 +120,14 @@ test-hw-crypto: ## Run tests for hardware wallet crypto API
$(CC) -o $(BIN_DIR)/test_hardwarewallet $(LIB_DIR)/cgo/tests/*.common.c $(LIB_DIR)/cgo/tests/testutils/libsky_string.c $(LIB_DIR)/cgo/tests/testutils/libsky_assert.c $(LIB_DIR)/cgo/tests/testutils/common.c $(LIB_DIR)/cgo/tests/test_main_hw.c -L$(HARDWARE_WALLET_ROOT_DIR)/skycoin-api -lskycoin-crypto-wrapper -lskycoin-crypto `pkg-config --cflags --libs check` -lpthread -Ilib/cgo -Iinclude -Ibuild/usr/include -I$(HARDWARE_WALLET_ROOT_DIR)
$(BIN_DIR)/test_hardwarewallet

docs-libc:
docs-skyapi: ## Generate SkyApi (libcurl) documentation
openapi-generator generate -g html2 -i lib/swagger/skycoin.v0.25.1.openapi.v2.yml -o $(LIBCURLDOC_DIR)

docs-libc: ## Generate libskycoin documentation
doxygen ./.Doxyfile
moxygen -o $(LIBDOC_DIR)/API.md $(LIBDOC_DIR)/xml/
moxygen -o $(LIBSKYDOC_DIR)/API.md $(LIBSKYDOC_DIR)/xml/

docs: docs-libc
docs: docs-libc docs-skyapi ## Generate documentation for all libraries

lint: ## Run linters. Use make install-linters first.
vendorcheck ./...
Expand All @@ -141,6 +144,7 @@ lint-libc: format-libc
check: lint test-libc lint-libc ## Run tests and linters

install-linters-Linux: ## Install linters on GNU/Linux
sudo apt-get update
sudo apt-get install $(PKG_CLANG_FORMAT)
sudo apt-get install $(PKG_CLANG_LINTER)

Expand All @@ -156,7 +160,7 @@ install-deps-Linux: ## Install deps on GNU/Linux
install-deps-Darwin: ## Install deps on Mac OSX
brew install $(PKG_LIB_TEST)

install-libraries-deps: ## Install deps on GNU/Linux
install-libraries-deps: ## Install deps for lib\curl wrapper of Skycoin REST API
if [[ "$(UNAME_S)" == "Linux" ]]; then (cd build && wget --no-check-certificate https://cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz && echo "f3546812c11ce7f5d64dc132a566b749 *cmake-3.3.2-Linux-x86_64.tar.gz" > cmake_md5.txt && md5sum -c cmake_md5.txt && tar -xvf cmake-3.3.2-Linux-x86_64.tar.gz > /dev/null && mv cmake-3.3.2-Linux-x86_64 cmake-install && PATH=$(pwd)/build/cmake-install:$(pwd)/build/cmake-install/bin:$PATH ) ; fi
(cd build && wget http://curl.haxx.se/download/curl-7.58.0.tar.gz && tar -xvf curl-7.58.0.tar.gz && cd curl-7.58.0/ && bash ./configure && make && sudo make install)
if [[ "$(UNAME_S)" == "Darwin" ]]; then brew install curl ; fi
Expand All @@ -166,10 +170,7 @@ install-libraries-deps: ## Install deps on GNU/Linux

install-linters: install-linters-$(UNAME_S) ## Install linters
go get -u github.com/FiloSottile/vendorcheck
# For some reason this install method is not recommended, see https://github.com/golangci/golangci-lint#install
# However, they suggest `curl ... | bash` which we should not do
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
VERSION=1.10.2 ./ci-scripts/install-golangci-lint.sh
cat ./ci-scripts/install-golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.10.2

install-deps-libc: install-deps-libc-$(OSNAME) install-libraries-deps

Expand Down
111 changes: 110 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,59 @@ The Skycoin C library is made of the following components

Consult respective `README` files for further details.

<!-- MarkdownTOC levels="1,2,3,4,5" autolink="true" bracket="round" -->
- [Make rules](#make-rules)
- [Development setup](#development-setup)
- [Running tests](#running-tests)
- [Releases](#releases)
- [Update the version](#update-the-version)
- [Pre-release testing](#pre-release-testing)
- [Creating release builds](#creating-release-builds)
<!-- /MarkdownTOC -->

## Make Rules

All these make rules require skycoin to be a git submodule of pyskycoin

- `build-libc`
* Compiles skycoin C language library.
- `test-libc`
* Compiles skycoin C language library and executes the tests.
- `build-libc-static`
* Build libskycoin C static library
- `build-libc-shared`
* Build libskycoin C shared library


## Development setup

### Running tests

```sh
$ make test-libc
```

### Releases

#### Update the version

0. If the `master` branch has commits that are not in `develop` (e.g. due to a hotfix applied to `master`), merge `master` into `develop` (and fix any build or test failures)
0. Switch to a new release branch named `release-X.Y.Z` for preparing the release.
0. Ensure that the submodule at `gopath/src/github.com/skycoin/skycoin` is in sync with respect to the corresponding tag in https://github.com/skycoin/skycoin repository.
0. Update `CHANGELOG.md`: move the "unreleased" changes to the version and add the date.
0. Follow the steps in [pre-release testing](#pre-release-testing)
0. Make a PR merging the release branch into `master`
0. Review the PR and merge it
0. Tag the `master` branch with the version number. Version tags start with `v`, e.g. `v0.20.0`. Sign the tag. If you have your GPG key in github, creating a release on the Github website will automatically tag the release. It can be tagged from the command line with `git tag -as v0.20.0 $COMMIT_ID`, but Github will not recognize it as a "release".
0. Release builds are created and uploaded by travis. To do it manually, checkout the master branch and follow the [create release builds instructions](#creating-release-builds).

#### Pre-release testing

Perform these actions before releasing:

```sh
make check
```
## Development

We have two branches: `master` and `develop`.
Expand Down Expand Up @@ -58,4 +111,60 @@ Stable development branches are created most of the time for the following reaso
The following rules are enforced

- Contributions must comply to the development guidelines documented in the [Skycoin wiki](https://github.com/skycoin/skycoin/wiki).
- C / C++ code must comply to the [Bitcoin C coding style](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style-c) (enforced by `clang-format`).
- C / C++ code must comply to the [Bitcoin C coding style](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style-c) (enforced by `clang-format`).

### SkyApi libcurl client for Skycoin REST API

This wrapper is auto-generated by `openapi-generator` directly from [Skycoin REST API code](https://github.com/skycoin/skycoin/tree/master/src/api).

For further instructions see [Autogenerated documentation](./lib/curl/README.md).

### Doxygen comment syntax

If you want to continue with `the doxygen way`(we recommend it) of coding and document functions, structs, and functions, you should follow the specifications found in the [Doxygen official site](http://www.doxygen.nl/manual/docblocks.html).

An example of documentation using `doxygen` is the next:

```c
/**
* Addresses of Bitcoin accounts
*/
typedef struct {
GoUint8_ Version; ///< Address version identifier.
///< Used to differentiate testnet
///< vs mainnet addresses, for instance.
cipher__Ripemd160 Key; ///< Address hash identifier.
} cipher__BitcoinAddress;
```
This code example can be found at `include/cipher.bitcoin.go.h`.

Inside `/* */` we found struct documentation, meanwhile `//<` symbol is used to describe fields of the struct.

After that, run `make docs` for a new docs generation. You can found the api documentation at `docs/libc` folder.

### Makefile targets:

|Target |Help|
| :------------- | :----------: |
|build-libc-static |Build libskycoin C static library|
|build-libc-shared |Build libskycoin C shared library|
|build-libc |Build libskycoin C client libraries|
|build |Build all C libraries
|test-libc |Run tests for libskycoin C client library|
|docs |Generate documentation for all libraries|
|docs-libc |Generate libskycoin documentation|
|docs-skyapi |Generate SkyApi (libcurl) documentation|
|lint |Run linters. Use make install-linters first.|
|check |Run tests and linters|
|install-linters-Linux |Install linters on GNU/Linux|
|install-linters-Darwin |Install linters on Mac OSX|
|install-deps-Linux |Install deps on GNU/Linux|
|install-deps-Darwin |Install deps on Mac OSX|
|install-libraries-deps |Install deps for `lib\curl` wrapper of Skycoin REST API|
|install-linters |Install linters|
|install-deps-libc-linux |Install locally dependencies for testing libskycoin|
|install-lib-curl |Install Sky Api curl based rest wrapper|
|install-deps-libc-osx |Install locally dependencies for testing libskycoin|
|format |Formats the code. Must have goimports installed (use make install-linters).|
|clean-libc |Clean files generate by library|

2 changes: 2 additions & 0 deletions ci-scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "Init"
make -C $GOPATH/src/github.com/skycoin/libskycoin build-libc
Loading

0 comments on commit e3cb4bd

Please sign in to comment.