Merge pull request #274 from ava-labs/dev #928
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "test/build" | |
on: | |
- push | |
jobs: | |
configure: | |
runs-on: ubuntu-latest | |
outputs: | |
uid_gid: ${{ steps.get-user.outputs.uid_gid }} | |
steps: | |
- id: get-user | |
run: echo "uid_gid=$(id -u):$(id -g)" >> $GITHUB_OUTPUT | |
checks: | |
runs-on: ubuntu-latest | |
container: | |
image: zondax/rust-ci:latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install Miri | |
run: | | |
rustup toolchain install nightly --component miri rustfmt | |
cargo +nightly miri --version | |
- name: Test with Miri | |
env: | |
MIRIFLAGS: "-Zmiri-symbolic-alignment-check \ | |
-Zmiri-check-number-validity \ | |
-Zmiri-permissive-provenance \ | |
-Zmiri-backtrace=full" | |
run: | | |
cargo +nightly miri test --features "full","derive-debug" | |
- name: show versions | |
run: | | |
rustup show | |
- name: rustfmt | |
run: | | |
cargo fmt --version | |
cargo fmt -- --check | |
- name: clippy | |
run: | | |
cargo clippy --version | |
cargo clippy --all-targets --features "full","derive-debug" | |
build: | |
runs-on: ubuntu-latest | |
container: | |
image: zondax/rust-ci:latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Cache/restore Cargo dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ./app/.cargo | |
key: ${{ runner.os }}-${{ hashFiles('./Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ github.sha }} | |
- name: run rust tests | |
run: make rust_test | |
build_ledger: | |
needs: configure | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
sdk: | |
- varname: NANOS_SDK | |
target: nanos | |
- varname: NANOX_SDK | |
target: nanox | |
- varname: NANOSP_SDK | |
target: nanosp | |
- varname: STAX_SDK | |
target: stax | |
container: | |
image: zondax/ledger-app-builder:ledger-d5bfe2e793f15a826971ae9de2adcad524df3e8e | |
env: | |
SDK_VARNAME: ${{ matrix.sdk.varname }} | |
options: --user ${{ needs.configure.outputs.uid_gid }} | |
env: | |
HOME: /home/zondax_circle | |
steps: | |
- run: echo "BOLOS_SDK=${!SDK_VARNAME}" >> "$GITHUB_ENV" | |
shell: bash -l {0} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Cache/restore Cargo dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ./app/.cargo | |
key: ${{ runner.os }}-${{ hashFiles('./Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ github.sha }} | |
- name: Build app | |
shell: bash -l {0} | |
run: make | |
- name: Upload elf | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.sdk.target }}-app | |
path: build/output/*.elf | |
if-no-files-found: error | |
- name: Upload installer | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.sdk.target }}-installer | |
path: build/pkg/*.sh | |
if-no-files-found: error | |
tests_zemu_setup: | |
if: ${{! contains(toJSON(github.event.commits.*.message), '[skip-zemu]')}} | |
runs-on: ubuntu-latest | |
outputs: | |
tests: ${{ steps.get-tests.outputs.tests }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install node | |
uses: actions/setup-node@v3 | |
- name: Install yarn | |
run: npm install -g yarn | |
- name: Build/Install build js deps | |
run: | | |
export PATH=~/.cargo/bin:$PATH | |
make zemu_install | |
- name: Get test files | |
id: get-tests | |
run: | | |
cd zemu | |
TESTS=`yarn test --listTests --json | head -n 3 | tail -n 1 | jq -cM 'to_entries | map({id: .key, file: .value})'` | |
echo "tests=$TESTS" >> "$GITHUB_OUTPUT" | |
test_zemu: | |
needs: [build_ledger, tests_zemu_setup] | |
if: ${{! contains(toJSON(github.event.commits.*.message), '[skip-zemu]')}} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
test: ${{ fromJson(needs.tests_zemu_setup.outputs['tests']) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: /tmp/artifacts | |
- run: | | |
mkdir -p build/output | |
find /tmp/artifacts -type f -name "*.elf" -exec mv {} build/output/ \; | |
- run: sudo apt-get update -y && sudo apt-get install -y libusb-1.0.0 libudev-dev | |
- name: Install node | |
uses: actions/setup-node@v3 | |
- name: Install yarn | |
run: npm install -g yarn | |
- name: Build/Install build js deps | |
run: | | |
export PATH=~/.cargo/bin:$PATH | |
make zemu_install | |
- name: Run zemu tests | |
run: | | |
export PATH=~/.cargo/bin:$PATH | |
cd zemu | |
yarn jest ${{ matrix.test.file }} --maxConcurrency 2 | |
- name: Tar Zemu snapshots | |
if: always() | |
run: tar -cvf snapshots_tmp.tar ./zemu/snapshots-tmp | |
- name: Upload tmp snapshots | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: snapshots-tmp_${{ matrix.test.id }} | |
path: snapshots_tmp.tar | |
#we don't need these snapshots for very long | |
retention-days: 3 |