diff --git a/.travis.yml b/.travis.yml index c362ad8..3b089dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,24 @@ language: c matrix: include: - - os: linux + - name: "Linux Ubuntu" + # In linux you must keep the use of python2 ot it will fail + os: linux env: - PIP='sudo pip' addons: apt: sources: - ubuntu-toolchain-r-test - - os: osx + - name: "MacOS / OSX" + os: osx env: - PYTHON=python3 + env: global: - GOPATH: "$HOME/go" + - APPVEYOR: false before_script: - mkdir -p ~/bin diff --git a/Makefile b/Makefile index b2f22a0..a6f1995 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,21 @@ define is_version_correct $(if $(shell echo $1 | egrep '^[0-9]+\.[0-9]+\.[0-9]+$$'),1,0) endef +ifeq ($(TRAVIS),true) + OS_NAME=$(TRAVIS_OS_NAME) +else + ifeq ($(UNAME_S),Linux) + OS_NAME=linux + endif + ifeq ($(UNAME_S),Darwin) + OS_NAME=osx + endif + UNAME_W = $(shell uname -s | cut -d "_" -f1 ) + ifeq ($(UNAME_W),MINGW64) + OS_NAME=windows + endif +endif + VERSION_IS_SEMANTIC_COMPLIANT = 0 ifeq ($(call is_version_correct,$(VERSION_FIRMWARE)),0) VERSION_FIRMWARE = $(VERSION_FIRMWARE_RAW) @@ -69,11 +84,12 @@ ID_PRODUCT=1 LANG=1 COMBINED_VERSION=v$(VERSION_BOOTLOADER)-v$(VERSION_FIRMWARE)-$(ID_VENDOR)-$(ID_PRODUCT)-$(LANG) -ifeq ($(UNAME_S), Darwin) +ifeq ($(OS_NAME), osx) LD_VAR=DYLD_LIBRARY_PATH else LD_VAR=LD_LIBRARY_PATH endif + check-version: ## Check that the tiny-firmware/VERSION match the current tag @./ci-scripts/version.sh > tiny-firmware/VERSION @if [ $$VERSION_IS_SEMANTIC_COMPLIANT -eq 1 ]; then git diff --exit-code tiny-firmware/VERSION; fi @@ -93,6 +109,7 @@ install-linters: install-linters-$(UNAME_S) ## Install code quality checking too lint: check-format ## Check code quality yamllint -d relaxed .travis.yml + yamllint -d relaxed appveyor.yml format: # Format C code in the project $(eval SRC := $(shell find . -type f -name *.c -o -name *.h | egrep -v "^(./tiny-firmware/protob/|./tiny-firmware/vendor/|./check-0.12.0)")) @@ -105,7 +122,7 @@ build-deps: ## Build common dependencies (protob) $(MAKE) -C tiny-firmware/protob/ build-c # UNIX symbolic links don't supported by Windows, so the best way # to use them is to create proper one in the begining of build -ifeq ($(OS),Windows_NT) +ifeq ($(OS_NAME), windows) ( cd ./tiny-firmware/vendor && rm skycoin-crypto) ( cd ./tiny-firmware/vendor && cmd /c 'mklink /d skycoin-crypto ..\..\skycoin-api\') endif @@ -286,7 +303,11 @@ clean-lib: ## Delete all files generated by tiny-firmware library dependencies clean: bootloader-clean firmware-clean setup-libskycoin ## Delete all files generated by build make -C tiny-firmware/vendor/libskycoin clean-libc +ifeq ($(OS_NAME), windows) + rm -rdf ./tiny-firmware/vendor/libskycoin +else rm -f ./tiny-firmware/vendor/libskycoin +endif $(MAKE) -C skycoin-api/ clean $(MAKE) -C tiny-firmware/emulator/ clean $(MAKE) -C tiny-firmware/protob/ clean-c diff --git a/appveyor.yml b/appveyor.yml index 9a8ffed..038cfde 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,72 @@ +os: Windows Server 2012 R2 +platform: x64 + +environment: + global: + APPVEYOR: true + GOPATH: C:\Users\appveyor\go + PYTHON: python3 + +install: + # deps via pacman + - ps: | + $env:MSYSTEM="MINGW64" + C:\msys64\usr\bin\bash --login -c "mkdir -p /var/cache/pacman/pkg" + C:\msys64\usr\bin\bash --login -c "pacman -S --noconfirm unzip" + C:\msys64\usr\bin\bash --login -c "pacman -S --noconfirm protobuf" + C:\msys64\usr\bin\bash --login -c "pacman -S --noconfirm mingw-w64-x86_64-SDL2" + C:\msys64\usr\bin\bash --login -c "pacman -S --noconfirm mingw-w64-x86_64-check" + C:\msys64\usr\bin\bash --login -c "pacman -S --noconfirm mingw-w64-x86_64-clang" + C:\msys64\usr\bin\bash --login -c "pacman -S --noconfirm mingw-w64-x86_64-protobuf-c" + C:\msys64\usr\bin\bash --login -c "pacman -S --noconfirm mingw-w64-x86_64-go" + C:\msys64\usr\bin\bash --login -c "pacman -S --noconfirm tree" + choco install python3 --params "/InstallDir:C:\python3.8" + + # ARM toolchain + - if not exist "gcc-arm-none-eabi.zip" curl -L -o gcc-arm-none-eabi.zip https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-win32.zip + - unzip -o -q gcc-arm-none-eabi.zip -d c:\gcc\ + - set PATH=%PATH%;c:\gcc\bin + + # git recursive + - git submodule update --init --recursive + + # python stuff + - pip --version + - which pip + - pip install yamllint + + # sudo stuff + - ps: | + $env:MSYSTEM="MINGW64" + C:\msys64\usr\bin\bash --login -c "curl -s https://raw.githubusercontent.com/imachug/win-sudo/master/install.sh | sh" + C:\msys64\usr\bin\bash --login -c "mkdir -p /usr/local/bin && cp ~/bin/win-sudo/s/* /usr/local/bin/" + C:\msys64\usr\bin\bash --login -c "sudo mkdir testing_sudo_power" + +cache: + - gcc-arm-none-eabi.zip + +build_script: + - ps: | + $env:MSYSTEM="MINGW64" + C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; make check-protob" + C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; make lint" + C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; make -C tiny-firmware/protob build-c" + C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; FIRMWARE_SIGNATURE_PUB_KEY1=0241d51e593f681006f9f3c4a0ec744d459c960601b4ed770d979c32ace63b0a7a make test" + #C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; make clean" + #C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; make emulator" + #C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; make clean" + #C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; make bootloader-mem-protect" + #C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; make bootloader-clean" + #C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; make full-firmware + #C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; make clean" -build: off test_script: - - echo "No tests here yet" + - ps: | + $env:MSYSTEM="MINGW64" + #C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; make check" +on_finish: + - ps: | + $env:MSYSTEM="MINGW64" + #C:\msys64\usr\bin\bash -l -c "cd /c/projects/skywallet-mcu ; cat ./test.log" diff --git a/ci-scripts/verify_protob_hash.sh b/ci-scripts/verify_protob_hash.sh index 2782e38..cbcc1b6 100755 --- a/ci-scripts/verify_protob_hash.sh +++ b/ci-scripts/verify_protob_hash.sh @@ -5,20 +5,20 @@ PROTOB_HASH=$(git -C tiny-firmware/protob/ rev-parse HEAD) # make sure submodule has correct origin url SUBMODULE_ORIGIN_URL=$(git -C tiny-firmware/protob remote get-url origin) -if ! echo "$SUBMODULE_ORIGIN_URL" | grep -q "https://github.com/fibercrypto/skywallet-protob.git"; then +if ! echo "$SUBMODULE_ORIGIN_URL" | grep -q "https://github.com/fibercrypto/skywallet-protob.git" ; then echo "invalid repository $SUBMODULE_ORIGIN_URL" exit 1 fi # if PR then determine base branch and do checks below -if "$TRAVIS_PULL_REQUEST" != "false" ; then +if [ "$APPVEYOR" == "false" -a "$TRAVIS_PULL_REQUEST" != "false" ] ; then echo "Merging changes into $TRAVIS_PULL_REQUEST_BRANCH" # fetch recent 50 commits # hardware wallet should not get too behind protob repository git -C tiny-firmware/protob/ fetch origin $TRAVIS_PULL_REQUEST_BRANCH PROTOB_REMOTE_HASH=$(git -C tiny-firmware/protob log remotes/origin/$TRAVIS_PULL_REQUEST_BRANCH --pretty=oneline | head -50 | cut -c 1-40) - if ! echo "$PROTOB_REMOTE_HASH" | grep -q "$PROTOB_HASH"; then + if [ ! echo "$PROTOB_REMOTE_HASH" | grep -q "$PROTOB_HASH" ] ; then echo "commit hash $PROTOB_HASH not present in recent 50 '$TRAVIS_PULL_REQUEST_BRANCH' commits" exit 1 fi diff --git a/tiny-firmware/protob b/tiny-firmware/protob index 8ce918b..81be0e9 160000 --- a/tiny-firmware/protob +++ b/tiny-firmware/protob @@ -1 +1 @@ -Subproject commit 8ce918b0c1c3d7e3d315ee19e2d097ea4ee78838 +Subproject commit 81be0e9029a26fadc841a14e84bd8a822b2dd8b5