Skip to content

Commit

Permalink
Merge pull request #156 from Zondax/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ftheirs authored Jun 3, 2024
2 parents b440a66 + ed869d9 commit e82af8b
Show file tree
Hide file tree
Showing 59 changed files with 725 additions and 182 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/check_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ on:
branches:
- main
- develop
- master # for safety reasons
- dev # for safety reasons

jobs:
configure:
runs-on: ubuntu-latest
runs-on: zondax-runners
outputs:
uid_gid: ${{ steps.get-user.outputs.uid_gid }}
steps:
Expand All @@ -18,15 +20,17 @@ jobs:

get_version:
needs: configure
runs-on: ubuntu-latest
runs-on: zondax-runners
container:
image: zondax/ledger-app-builder:latest
options: --user ${{ needs.configure.outputs.uid_gid }}
env:
SDK_VARNAME: NANOSP_SDK
outputs:
version: ${{ steps.store-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
- run: make version
Expand All @@ -35,7 +39,7 @@ jobs:

check_app_version:
needs: get_version
runs-on: ubuntu-latest
runs-on: zondax-runners
steps:
- id: checkTag
uses: mukunku/tag-exists-action@v1.0.0
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,23 @@ on:
branches:
- main
- develop
- master # for safety reasons
- dev # for safety reasons

jobs:
analyse:
name: Analyse
if: github.event.repository.private == false
strategy:
matrix:
sdk: ["$NANOS_SDK", "$NANOX_SDK", "$NANOSP_SDK"]
runs-on: ubuntu-latest
sdk: ["$NANOS_SDK", "$NANOX_SDK", "$NANOSP_SDK", "$STAX_SDK"]
runs-on: zondax-runners
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-legacy:latest

steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/guidelines_enforcer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ on:
workflow_dispatch:
push:
branches:
- master
- main
- develop
- master # for safety reasons
- dev # for safety reasons
pull_request:

jobs:
guidelines_enforcer:
if: github.event.repository.private == false
name: Call Ledger guidelines_enforcer
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_guidelines_enforcer.yml@v1
102 changes: 83 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,51 @@ on:
branches:
- main
- develop
- master # for safety reasons
- dev # for safety reasons

jobs:
configure:
runs-on: ubuntu-latest
runs-on: zondax-runners
outputs:
uid_gid: ${{ steps.get-user.outputs.uid_gid }}
steps:
- id: get-user
run: echo "uid_gid=$(id -u):$(id -g)" >> $GITHUB_OUTPUT

build:
runs-on: ubuntu-latest
runs-on: zondax-runners
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y curl protobuf-compiler build-essential git wget unzip python3 python3-pip \
libssl-dev libffi-dev libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \
libgdbm-dev libnss3-dev liblzma-dev libxml2-dev libxmlsec1-dev libffi-dev libyaml-dev
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
- name: Install CMake 3.28
run: |
wget https://github.com/Kitware/CMake/releases/download/v3.28.0/cmake-3.28.0-linux-x86_64.sh
sudo mkdir /opt/cmake
sudo sh cmake-3.28.0-linux-x86_64.sh --skip-license --prefix=/opt/cmake
sudo ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
sudo ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest
- name: Verify CMake version
run: cmake --version
- name: Install deps
run: |
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
make deps
- name: Run CMake
run: mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. && make
- run: make cpp_test

build_ledger:
needs: configure
runs-on: ubuntu-latest
runs-on: zondax-runners
container:
image: zondax/ledger-app-builder:latest
options: --user ${{ needs.configure.outputs.uid_gid }}
Expand All @@ -41,7 +60,7 @@ jobs:
size: ${{steps.build.outputs.size}}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
- name: Build Standard app
Expand All @@ -53,7 +72,7 @@ jobs:
size_nano_s:
needs: build_ledger
runs-on: ubuntu-latest
runs-on: zondax-runners
env:
NANOS_LIMIT_SIZE: 136
steps:
Expand All @@ -62,29 +81,38 @@ jobs:
[ ${{needs.build_ledger.outputs.size}} -le $NANOS_LIMIT_SIZE ]
test_zemu:
runs-on: ubuntu-latest
runs-on: zondax-runners
steps:
- name: Test
run: |
id
echo $HOME
echo $DISPLAY
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y curl protobuf-compiler build-essential git wget unzip python3 python3-pip \
libssl-dev libffi-dev libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \
libgdbm-dev libnss3-dev liblzma-dev libxml2-dev libxmlsec1-dev libffi-dev libyaml-dev
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
- run: sudo apt-get update -y && sudo apt-get install -y libusb-1.0.0 libudev-dev
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install yarn
run: |
npm install -g yarn
- name: Build Ledger app
run: make
- name: Build/Install build js deps
run: make zemu_install
- name: Run zemu tests
run: "cd tests_zemu; yarn test"
- name: Build and run zemu tests
run: |
make test_all
- name: Upload Snapshots (only failure)
if: ${{ failure() }}
uses: actions/upload-artifact@v3
Expand All @@ -95,15 +123,15 @@ jobs:
build_package_nanos:
needs: [configure, build, build_ledger, test_zemu]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
runs-on: zondax-runners
container:
image: zondax/ledger-app-builder:latest
options: --user ${{ needs.configure.outputs.uid_gid }}
env:
BOLOS_SDK: /opt/nanos-secure-sdk
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
- name: Install deps
Expand Down Expand Up @@ -131,15 +159,15 @@ jobs:
build_package_nanosp:
needs: [configure, build, build_ledger, test_zemu]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
runs-on: zondax-runners
container:
image: zondax/ledger-app-builder:latest
options: --user ${{ needs.configure.outputs.uid_gid }}
env:
BOLOS_SDK: /opt/nanosplus-secure-sdk
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
- name: Install deps
Expand All @@ -163,3 +191,39 @@ jobs:
tag_name: ${{ steps.nanosp.outputs.tag_name }}
draft: false
prerelease: false

build_package_stax:
needs: [configure, build, build_ledger, test_zemu]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: zondax-runners
container:
image: zondax/ledger-app-builder:latest
options: --user ${{ needs.configure.outputs.uid_gid }}
env:
BOLOS_SDK: /opt/stax-secure-sdk
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Install deps
run: pip install ledgerblue

- name: Build Stax
shell: bash -l {0}
run: |
make
- name: Set tag
id: stax
run: echo "tag_name=$(./app/pkg/installer_stax.sh version)" >> $GITHUB_OUTPUT
- name: Update Release
id: update_release_2
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
files: |
./app/pkg/installer_stax.sh
tag_name: ${{ steps.stax.outputs.tag_name }}
draft: false
prerelease: false
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ googletest-build/
CMakeFiles/
CMakeCache.txt
unittests
*.cmake
Testing/
cmake-build-fuzz/

Expand Down
45 changes: 34 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,31 @@
#* See the License for the specific language governing permissions and
#* limitations under the License.
#********************************************************************************
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.28)
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.25.5.tar.gz"
SHA1 "a20151e4c0740ee7d0f9994476856d813cdead29"
LOCAL
)

if(CMAKE_GENERATOR MATCHES "Ninja")
message(FATAL_ERROR "This project does not support the Ninja generator. "
"Please use Unix Makefiles or another supported generator. "
"This error is typical in CLion. In this case, switch to generator Unix Makefiles.")
endif()

########################################################
project(ledger-filecoin VERSION 0.0.0)
enable_testing()

cmake_policy(SET CMP0025 NEW)
set(CMAKE_CXX_STANDARD 20)
cmake_policy(SET CMP0025 NEW)
cmake_policy(SET CMP0144 NEW)

set(HUNTER_STATUS_DEBUG ON)
set(HUNTER_TLS_VERIFY OFF)

enable_testing()

option(ENABLE_FUZZING "Build with fuzzing instrumentation and build fuzz targets" OFF)
option(ENABLE_COVERAGE "Build with source code coverage instrumentation" OFF)
Expand All @@ -28,7 +47,14 @@ string(APPEND CMAKE_C_FLAGS " -fno-omit-frame-pointer -g")
string(APPEND CMAKE_CXX_FLAGS " -fno-omit-frame-pointer -g")
string(APPEND CMAKE_LINKER_FLAGS " -fno-omit-frame-pointer -g")

add_definitions(-DAPP_STANDARD)
hunter_add_package(fmt)
find_package(fmt CONFIG REQUIRED)

hunter_add_package(jsoncpp)
find_package(jsoncpp CONFIG REQUIRED)

hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)

if (ENABLE_FUZZING)
add_definitions(-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1)
Expand Down Expand Up @@ -71,9 +97,6 @@ if (ENABLE_SANITIZERS)
string(APPEND CMAKE_LINKER_FLAGS " -fsanitize=address,undefined -fsanitize-recover=address,undefined")
endif ()

include(cmake/conan/CMakeLists.txt)
add_subdirectory(cmake/gtest)

string(APPEND CMAKE_CXX_FLAGS " -fsanitize=address -fno-omit-frame-pointer")
string(APPEND CMAKE_LINKER_FLAGS " -fsanitize=address -fno-omit-frame-pointer")

Expand Down Expand Up @@ -144,13 +167,13 @@ target_include_directories(unittests PRIVATE


target_link_libraries(unittests PRIVATE
gtest_main
app_lib
CONAN_PKG::fmt
CONAN_PKG::jsoncpp)
GTest::gtest_main
fmt::fmt
JsonCpp::JsonCpp)

add_compile_definitions(TESTVECTORS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tests/")
add_test(unittests ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittests)
add_test(NAME unittests COMMAND unittests)
set_tests_properties(unittests PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests)

##############################################################
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ TESTS_JS_DIR =

ifeq ($(BOLOS_SDK),)
ZXLIB_COMPILE_STAX ?= 1
PRODUCTION_BUILD ?= 0
include $(CURDIR)/deps/ledger-zxlib/dockerized_build.mk
else
default:
Expand All @@ -33,6 +34,6 @@ default:
endif

test_all:
make
PRODUCTION_BUILD=1 make
make zemu_install
make zemu_test
Loading

0 comments on commit e82af8b

Please sign in to comment.