From 92a67da2818d77944ce9950fc983f6a91a3130df Mon Sep 17 00:00:00 2001 From: arobsn <87387688+arobsn@users.noreply.github.com> Date: Mon, 4 Nov 2024 10:38:54 -0300 Subject: [PATCH] adapt functional tests to the new build ci --- .github/workflows/ci-workflow.yml | 263 +++++++++++++++--------------- 1 file changed, 131 insertions(+), 132 deletions(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 417a1e4..a9bc97d 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -9,132 +9,132 @@ jobs: with: upload_app_binaries_artifact: "compiled_app_binaries" - job_build_nano_debug: - name: Build application for NanoS+, X, Stax, Flex - runs-on: ubuntu-latest - strategy: - matrix: - include: - - SDK: "$NANOX_SDK" - artifact: ergo-app-debug-nanox - - SDK: "$NANOSP_SDK" - artifact: ergo-app-debug-nanosp - - SDK: "$STAX_SDK" - artifact: ergo-app-debug-stax - - SDK: "$FLEX_SDK" - artifact: ergo-app-debug-flex - - container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest - - steps: - - name: Clone - uses: actions/checkout@v4 - - - name: Build - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - make BOLOS_SDK=${{ matrix.SDK }} DEBUG=1 - - - name: Upload app binary - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.artifact }} - path: bin - - job_unit_test: - name: Unit tests - runs-on: ubuntu-latest - - container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest - - steps: - - name: Clone - uses: actions/checkout@v4 - - - name: Build unit tests - run: | - cd unit-tests/ - cmake -Bbuild -H. && make -C build - - - name: Run unit tests - run: | - cd unit-tests/ - make -C build test - - - name: Generate code coverage - run: | - cd unit-tests/ - lcov --directory . -b "$(realpath build/)" --capture --initial -o coverage.base && \ - lcov --rc lcov_branch_coverage=1 --directory . -b "$(realpath build/)" --capture -o coverage.capture && \ - lcov --directory . -b "$(realpath build/)" --add-tracefile coverage.base --add-tracefile coverage.capture -o coverage.info && \ - lcov --directory . -b "$(realpath build/)" --remove coverage.info '*/unit-tests/*' -o coverage.info && \ - genhtml coverage.info -o coverage - - - uses: actions/upload-artifact@v4 - with: - name: code-coverage - path: unit-tests/coverage - - - name: Upload to codecov.io - if: false - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./unit-tests/coverage.info - flags: unittests - name: codecov-app-ergo - fail_ci_if_error: true - verbose: true - - job_generate_doc: - name: Generate project documentation - runs-on: ubuntu-latest - - container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest - - steps: - - name: Clone - uses: actions/checkout@v4 - - - name: HTML documentation - run: doxygen .doxygen/Doxyfile - - - uses: actions/upload-artifact@v4 - with: - name: documentation - path: doc/html - - job_scan_build: - name: Clang Static Analyzer - runs-on: ubuntu-latest - strategy: - matrix: - include: - - SDK: "$NANOSP_SDK" - - SDK: "$STAX_SDK" - - container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest - - steps: - - name: Clone - uses: actions/checkout@v4 - - - name: Build with Clang Static Analyzer - run: | - export BOLOS_SDK=${{ matrix.SDK }} - make clean - scan-build --use-cc=clang -analyze-headers -enable-checker security -enable-checker unix -enable-checker valist -o scan-build --status-bugs make default + # job_build_nano_debug: + # name: Build application for NanoS+, X, Stax, Flex + # runs-on: ubuntu-latest + # strategy: + # matrix: + # include: + # - SDK: "$NANOX_SDK" + # artifact: ergo-app-debug-nanox + # - SDK: "$NANOSP_SDK" + # artifact: ergo-app-debug-nanosp + # - SDK: "$STAX_SDK" + # artifact: ergo-app-debug-stax + # - SDK: "$FLEX_SDK" + # artifact: ergo-app-debug-flex + + # container: + # image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest + + # steps: + # - name: Clone + # uses: actions/checkout@v4 + + # - name: Build + # run: | + # git config --global --add safe.directory "$GITHUB_WORKSPACE" + # make BOLOS_SDK=${{ matrix.SDK }} DEBUG=1 + + # - name: Upload app binary + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ matrix.artifact }} + # path: bin + + # job_unit_test: + # name: Unit tests + # runs-on: ubuntu-latest + + # container: + # image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest + + # steps: + # - name: Clone + # uses: actions/checkout@v4 + + # - name: Build unit tests + # run: | + # cd unit-tests/ + # cmake -Bbuild -H. && make -C build + + # - name: Run unit tests + # run: | + # cd unit-tests/ + # make -C build test + + # - name: Generate code coverage + # run: | + # cd unit-tests/ + # lcov --directory . -b "$(realpath build/)" --capture --initial -o coverage.base && \ + # lcov --rc lcov_branch_coverage=1 --directory . -b "$(realpath build/)" --capture -o coverage.capture && \ + # lcov --directory . -b "$(realpath build/)" --add-tracefile coverage.base --add-tracefile coverage.capture -o coverage.info && \ + # lcov --directory . -b "$(realpath build/)" --remove coverage.info '*/unit-tests/*' -o coverage.info && \ + # genhtml coverage.info -o coverage + + # - uses: actions/upload-artifact@v4 + # with: + # name: code-coverage + # path: unit-tests/coverage + + # - name: Upload to codecov.io + # if: false + # uses: codecov/codecov-action@v4 + # with: + # token: ${{ secrets.CODECOV_TOKEN }} + # files: ./unit-tests/coverage.info + # flags: unittests + # name: codecov-app-ergo + # fail_ci_if_error: true + # verbose: true + + # job_generate_doc: + # name: Generate project documentation + # runs-on: ubuntu-latest + + # container: + # image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest + + # steps: + # - name: Clone + # uses: actions/checkout@v4 + + # - name: HTML documentation + # run: doxygen .doxygen/Doxyfile + + # - uses: actions/upload-artifact@v4 + # with: + # name: documentation + # path: doc/html + + # job_scan_build: + # name: Clang Static Analyzer + # runs-on: ubuntu-latest + # strategy: + # matrix: + # include: + # - SDK: "$NANOSP_SDK" + # - SDK: "$STAX_SDK" + + # container: + # image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest + + # steps: + # - name: Clone + # uses: actions/checkout@v4 + + # - name: Build with Clang Static Analyzer + # run: | + # export BOLOS_SDK=${{ matrix.SDK }} + # make clean + # scan-build --use-cc=clang -analyze-headers -enable-checker security -enable-checker unix -enable-checker valist -o scan-build --status-bugs make default - - name: Upload scan result - uses: actions/upload-artifact@v4 - if: failure() - with: - name: scan-build - path: scan-build + # - name: Upload scan result + # uses: actions/upload-artifact@v4 + # if: failure() + # with: + # name: scan-build + # path: scan-build job_test: name: Functional Tests @@ -143,11 +143,9 @@ jobs: matrix: include: - model: nanox - - model: nanosp - #- model: stax - #- model: flex + - model: nanos2 - needs: job_build_nano_debug + needs: job_build_application_with_reusable_workflow runs-on: ubuntu-latest container: @@ -164,16 +162,17 @@ jobs: - name: Download app binary uses: actions/download-artifact@v4 with: - name: ergo-app-debug-${{matrix.model}} + name: compiled_app_binaries path: bin - name: Run test run: | apt-get update && apt-get install -qy curl netcat-traditional curl -fsSL https://deb.nodesource.com/setup_18.x | bash - - apt-get install -qy nodejs + apt-get install -qy nodejs unzip + unzip ./bin/compiled_app_binaries.zip -d ./bin export SEED=`cat tests/seed.txt` - nohup bash -c "python /speculos/speculos.py bin/app.elf --apdu-port 9999 --api-port 5000 --display headless --model=${{ matrix.model }} --seed \"${SEED}\"" > speculos.log 2<&1 & + nohup bash -c "python /speculos/speculos.py bin/${{ matrix.model }}/bin/app.elf --apdu-port 9999 --api-port 5000 --display headless --model=${{ matrix.model }} --seed \"${SEED}\"" > speculos.log 2<&1 & cd tests && npm install until `nc -w5 -z -v 127.0.0.1 9999`; do sleep 1; done; npm --model=${{matrix.model}} --port=5000 run test