Skip to content

Commit

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

Conflicts:
	Makefile
ref #34
  • Loading branch information
Alvaro Denis committed May 26, 2019
2 parents d2135b8 + 5dec78d commit 43a22e5
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 150 deletions.
46 changes: 27 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
- setup_remote_docker:
version: 18.06.0-ce
- run: docker build --build-arg QEMU_PLATFORM --build-arg QEMU_OS=debian --file $GOPATH/src/github.com/skycoin/libskycoin/docker/images/test-arm/Dockerfile $GOPATH/src/github.com/skycoin/libskycoin -t skydev-test
- run: docker build --build-arg QEMU_PLATFORM --build-arg QEMU_OS=fedora --file $GOPATH/src/github.com/skycoin/libskycoin/docker/images/test-arm/Dockerfile $GOPATH/src/github.com/skycoin/libskycoin -t skydev-test

raspberrypi3:
docker:
Expand All @@ -28,8 +27,7 @@ jobs:
- setup_remote_docker:
version: 18.06.0-ce
- run: docker build --build-arg QEMU_PLATFORM --build-arg QEMU_OS=debian --file $GOPATH/src/github.com/skycoin/libskycoin/docker/images/test-arm/Dockerfile $GOPATH/src/github.com/skycoin/libskycoin -t skydev-test
- run: docker build --build-arg QEMU_PLATFORM --build-arg QEMU_OS=fedora --file $GOPATH/src/github.com/skycoin/libskycoin/docker/images/test-arm/Dockerfile $GOPATH/src/github.com/skycoin/libskycoin -t skydev-test


raspberrypi2:
docker:
- image: docker:18.06.0-ce-git
Expand All @@ -43,23 +41,32 @@ jobs:
- setup_remote_docker:
version: 18.06.0-ce
- run: docker build --build-arg QEMU_PLATFORM --build-arg QEMU_OS=debian --file $GOPATH/src/github.com/skycoin/libskycoin/docker/images/test-arm/Dockerfile $GOPATH/src/github.com/skycoin/libskycoin -t skydev-test
- run: docker build --build-arg QEMU_PLATFORM --build-arg QEMU_OS=fedora --file $GOPATH/src/github.com/skycoin/libskycoin/docker/images/test-arm/Dockerfile $GOPATH/src/github.com/skycoin/libskycoin -t skydev-test


bananapi_m1_plus:
docker:
- image: docker:18.06.0-ce-git
working_directory: $GOPATH/src/github.com/skycoin/libskycoin
environment:
QEMU_PLATFORM: bananapi-m1-plus

steps:
- run: mkdir -p $GOPATH/src/github.com/ $GOPATH/src/github.com/skycoin
- checkout
- setup_remote_docker:
version: 18.06.0-ce
- run: docker build --build-arg QEMU_PLATFORM --build-arg QEMU_OS=debian --file $GOPATH/src/github.com/skycoin/libskycoin/docker/images/test-arm/Dockerfile $GOPATH/src/github.com/skycoin/libskycoin -t skydev-test
- run: docker build --build-arg QEMU_PLATFORM --build-arg QEMU_OS=fedora --file $GOPATH/src/github.com/skycoin/libskycoin/docker/images/test-arm/Dockerfile $GOPATH/src/github.com/skycoin/libskycoin -t skydev-test

docker:
- image: docker:18.06.0-ce-git
working_directory: $GOPATH/src/github.com/skycoin/libskycoin
environment:
QEMU_PLATFORM: bananapi-m1-plus

steps:
- run: mkdir -p $GOPATH/src/github.com/ $GOPATH/src/github.com/skycoin
- checkout
- setup_remote_docker:
version: 18.06.0-ce
- run: docker build --build-arg QEMU_PLATFORM --build-arg QEMU_OS=debian --file $GOPATH/src/github.com/skycoin/libskycoin/docker/images/test-arm/Dockerfile $GOPATH/src/github.com/skycoin/libskycoin -t skydev-test

publish-github-release_32:
docker:
- image: docker:18.06.0-ce-git
steps:
- run: mkdir -p $GOPATH/src/github.com/ $GOPATH/src/github.com/skycoin
- checkout
- setup_remote_docker:
version: 18.06.0-ce
- run: if [[ $CIRCLE_TAG ]]; then docker build --build-arg SHA1=$CIRCLE_SHA1 --build-arg GITHUB_OAUTH_TOKEN --build-arg PROJECT_USERNAME=$CIRCLE_PROJECT_USERNAME --build-arg PROJECT_REPONAME=$CIRCLE_PROJECT_REPONAME --build-arg QEMU_PLATFORM=raspberrypi3 --build-arg VERSION --file $GOPATH/src/github.com/skycoin/libskycoin/docker/images/deploy-arm/Dockerfile $GOPATH/src/github.com/skycoin/libskycoin -t skydev-deploy ; fi


workflows:
version: 2
arm_test:
Expand All @@ -68,3 +75,4 @@ workflows:
- orangepi-plus2
- raspberrypi2
- bananapi_m1_plus
- publish-github-release_32
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@ install:
- go get github.com/gz-c/gox
- go get -t ./...
- make install-linters
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
sudo apt-get install cmake ;
fi
- make install-deps-libc
- make install-lib-curl
- make install-deps-skyapi
script:
- make check
- make build-skyapi
- make lint
- make test-libc
- make lint-libc
- make test-skyapi

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 ./*
- ( cd build && tar czf ../libskycoin-${VERSION}-${OS}-${ARCH}.tar.gz ./* )
- pwd && ls -l .
deploy:
- provider: releases
api_key:
Expand Down
10 changes: 0 additions & 10 deletions .travis/install_lib_curl.sh

This file was deleted.

13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

### Fixed

### Changed

### Removed

## [0.25.1] - 2019-05-24

### Added

- Export functions in Skycoin 0.25.1 core API's
- `skyapi` C client for Skycoin node REST at `lib/curl`.
- Support for building `libskycoin` on ARM and 32 / 64 bits.

Expand All @@ -23,11 +34,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Delete function `SKY_base58_String2Hex`


## [0.25.0] - 2018-12-19

### Added

- Export functions in Skycoin 0.25.0 core API's
- Coinhour burn factor when creating transactions can be configured at runtime with `USER_BURN_FACTOR` envvar
- Max transaction size when creating transactions can be configured at runtime with `USER_MAX_TXN_SIZE` envvar
- Max decimals allowed when creating transactions can be configured at runtime with `USER_MAX_DECIMALS` envvar
Expand Down
63 changes: 45 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DEFAULT_GOAL := help
.PHONY: test-libc test-lint build-libc check
.PHONY: test-libc test-lint build-libc check build build-skyapi test-skyapi
.PHONY: install-linters format clean-libc format-libc lint-libc docs

COIN ?= skycoin
Expand All @@ -23,6 +23,9 @@ SKYVENDOR_REL_PATH = $(SKYSRC_REL_PATH)/vendor
# Compilation output for libskycoin
BUILD_DIR = build
BUILDLIB_DIR = $(BUILD_DIR)/libskycoin
BUILDLIBSKYAPI_DIR = $(BUILD_DIR)/libskyapi
LIBNAME_Linux = libskyapi.so
LIBNAME_Darwin = libskyapi.dylib
LIB_DIR = lib
BIN_DIR = bin
DOC_DIR = docs
Expand Down Expand Up @@ -99,7 +102,12 @@ build-libc-shared: $(BUILDLIB_DIR)/libskycoin.so ## Build libskycoin C shared li

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

build: build-libc ## Build all C libraries
build-skyapi: ## Build skyapi(libcurl based) library
(cd lib/curl && bash ./install_lib_curl.sh)
mkdir -p ./build/libskyapi
cp lib/curl/build/$(LIBNAME_$(UNAME_S)) ./build/libskyapi

build: build-libc build-skyapi ## Build libraries

## Build libskycoin C client library and executable C test suites
## with debug symbols. Use this target to debug the source code
Expand All @@ -119,6 +127,9 @@ test-libc: build-libc ## Run tests for libskycoin C client library
test-hw-crypto: install-deps-libc-linux install-lib-curl build-libc ## 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 -Wl,-rpath,$(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
test-skyapi: build-skyapi ## Run test for skyapi(libcurl based) library

test: test-libc test-skyapi ## Run all test for libskycoin

docs-skyapi: ## Generate SkyApi (libcurl) documentation
openapi-generator generate -g html2 -i lib/swagger/skycoin.v0.25.1.openapi.v2.yml -o $(LIBCURLDOC_DIR)
Expand All @@ -141,7 +152,7 @@ lint-libc: format-libc
clang-tidy lib/cgo/tests/*.c -- $(LIBC_FLAGS) -Wincompatible-pointer-types


check: lint test-libc lint-libc ## Run tests and linters
check: lint test-libc lint-libc test-skyapi ## Run tests and linters

install-linters-Linux: ## Install linters on GNU/Linux
sudo apt-get update
Expand All @@ -160,42 +171,58 @@ 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 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
# install uncrustify
(cd build && git clone https://github.com/uncrustify/uncrustify.git)
(cd build/uncrustify && mkdir build && cd build && cmake .. && make && sudo make install)

install-linters: install-linters-$(UNAME_S) ## Install linters
go get -u github.com/FiloSottile/vendorcheck
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
install-deps-skyapi-Linux:
mkdir -p deps
sudo add-apt-repository ppa:george-edison55/cmake-3.x -y
sudo apt-get update
sudo apt-get install cmake
sudo apt-get install libcurl3-gnutls
sudo apt remove curl
(cd deps && 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/ && ./configure && make && sudo make install)
(cd deps && git clone https://github.com/uncrustify/uncrustify.git && cd uncrustify && mkdir build && cd build && cmake .. && make && sudo make install)

install-deps-skyapi-Darwin:
export LDFLAGS="-L/usr/local/opt/curl/lib"
export CPPFLAGS="-I/usr/local/opt/curl/include"
mkdir -p deps
brew update
brew install openssl curl uncrustify || true
(cd deps && wget http://curl.haxx.se/download/curl-7.58.0.tar.gz && tar -xf curl-7.58.0.tar.gz && cd curl-7.58.0/ && mkdir build && cd build && cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .. && make && sudo make install)

install-deps-libc: install-deps-libc-$(UNAME_S) ## Install deps for libc

check-0.12.0/configure:
install-deps-skyapi: install-deps-skyapi-$(UNAME_S) ## Install skyapi(libcurl based) library.

install-deps-libc-Linux: configure-build ## Install locally dependencies for testing libskycoin
wget -c https://github.com/libcheck/check/releases/download/0.12.0/check-0.12.0.tar.gz
tar -xzf check-0.12.0.tar.gz
cd check-0.12.0 && ./configure --prefix=/usr --disable-static && make && sudo make install

install-deps-libc-linux: configure-build check-0.12.0/configure ## Install locally dependencies for testing libskycoin

install-lib-curl: ## Install Sky Api curl based rest wrapper
bash .travis/install_lib_curl.sh

install-deps-libc-osx: configure-build ## Install locally dependencies for testing libskycoin
install-deps-libc-Darwin: configure-build ## Install locally dependencies for testing libskycoin
brew install check

install-deps: install-deps-libc install-deps-skyapi ## Install deps for libc and skyapi

format: ## Formats the code. Must have goimports installed (use make install-linters).
goimports -w -local github.com/skycoin/skycoin ./lib

clean-libc: ## Clean files generate by library
clean-libc: ## Clean files generated by libc
rm -rfv $(BUILDLIB_DIR)
rm -rfv bin
rm -rfv qemu_test_libskycoin*
rm -rfv include/libskycoin.h

clean-skyapi: ## Clean files generated by skyapi
rm -rfv $(BUILDLIBSKYAPI_DIR)

clean: clean-libc clean-skyapi ## Clean all files generated by libraries

format-libc:
$(PKG_CLANG_FORMAT) -sort-includes -i -assume-filename=.clang-format lib/cgo/tests/*.c
$(PKG_CLANG_FORMAT) -sort-includes -i -assume-filename=.clang-format include/*.h
Expand Down
60 changes: 36 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,48 +46,59 @@ All these make rules require skycoin to be a git submodule of libskycoin
| :------------- | :----------: |
|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
|build-libc |Build libskycoin C client libraries|
|build-skyapi |Build skyapi(libcurl based) library|
|test |Run all test for libskycoin|
|test-libc |Run tests for libskycoin C client library|
|test-skyapi |Run test for skyapi(libcurl based) 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-libraries-deps |Install deps for `lib\curl` wrapper of Skycoin REST API|
|install-deps |Install deps for libc and skyapi|
|install-deps-libc |Install deps for libc|
|install-deps-skyapi |Install skyapi(libcurl based) library.|
|install-linters |Install linters|
|format |Formats the code. Must have goimports installed (use make install-linters).|
|clean-libc |Clean files generate by library|

|clean |Clean all files generated by libraries(libcurl based and libc)|
|clean-libc |Clean files generated by libc|
|clean-skyapi |Clean files generated by skyapi|

## Development setup

### Running tests
### Running tests

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

### Releases
### Releases

#### Update the version
#### 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).
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. If the release process needs modifications, edit these steps before moving forward
0. Ensure that the submodule at `vendor/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. Run `make docs` to regenerate documentation for all libraries and ensure they ar up-to-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).
0. Merge changes in `master` back into `develop` branch to start working towards next stable version.

#### Pre-release testing
#### Pre-release testing

Perform these actions before releasing:
Perform these actions before releasing:

```sh
make check
```

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

We have two branches: `master` and `develop`.
Expand Down Expand Up @@ -148,3 +159,4 @@ 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.

26 changes: 26 additions & 0 deletions docker/images/deploy-arm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARG QEMU_PLATFORM
FROM balenalib/${QEMU_PLATFORM}-debian-golang

ARG GITHUB_OAUTH_TOKEN
ARG PROJECT_USERNAME
ARG PROJECT_REPONAME
ARG SHA1
ADD . $GOPATH/src/github.com/skycoin/libskycoin/

RUN [ "cross-build-start" ]

RUN ls -oa $GOPATH/src/github.com/skycoin/libskycoin/
RUN sh $GOPATH/src/github.com/skycoin/libskycoin/ci-scripts/docker_install_debian.sh
RUN make -C $GOPATH/src/github.com/skycoin/libskycoin dep
RUN go get github.com/gz-c/gox
RUN go get -t ./...
ENV CGO_ENABLED=1
RUN export VERSION="$(git describe --tags --exact-match HEAD 2> /dev/null)"
RUN export ARCH="$(uname -m)"
RUN export OS="$(uname -s)"
RUN make -C $GOPATH/src/github.com/skycoin/libskycoin build
RUN tar -c -z -f libskycoin-${VERSION}-${OS}-${ARCH}.tar.gz -C $GOPATH/src/github.com/skycoin/libskycoin/build $GOPATH/src/github.com/skycoin/libskycoin/build/*
RUN go get github.com/tcnksm/ghr
RUN ghr -t ${GITHUB_OAUTH_TOKEN} -u ${PROJECT_USERNAME} -r ${PROJECT_REPONAME} -c ${SHA1} -delete ${VERSION} libskycoin-${VERSION}-${OS}-${ARCH}.tar.gz

RUN [ "cross-build-end" ]
5 changes: 3 additions & 2 deletions lib/cgo/tests/check_coin.transactions.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,11 @@ START_TEST(TestTransactionUpdateHeader)
Transaction__Handle handle;
coin__Transaction* ptx;
ptx = makeTransaction(&handle);
cipher__SHA256 hash, nullHash, hashInner;
cipher__SHA256 hash;
cipher__SHA256 nullHash = "";
cipher__SHA256 hashInner;
memcpy(&hash, &ptx->InnerHash, sizeof(cipher__SHA256));
memset(&ptx->InnerHash, 0, sizeof(cipher__SHA256));
memset(&nullHash, 0, sizeof(cipher__SHA256));
result = SKY_coin_Transaction_UpdateHeader(handle);
ck_assert(!isU8Eq(ptx->InnerHash, nullHash, sizeof(cipher__SHA256)));
ck_assert(isU8Eq(ptx->InnerHash, hash, sizeof(cipher__SHA256)));
Expand Down
Loading

0 comments on commit 43a22e5

Please sign in to comment.