Skip to content

feat!: introduce machine init and entrypoint config and options #772

feat!: introduce machine init and entrypoint config and options

feat!: introduce machine init and entrypoint config and options #772

Workflow file for this run

name: Build/Test/Release
on: [push]
env:
KERNEL_VERSION: v0.17.0
LINUX_VERSION: 5.15.63-ctsi-2-v0.17.0
ROOTFS_VERSION: v0.18.0
TEST_VERSION: v0.29.0
CARTESI_TESTS_PATH: /usr/share/cartesi-machine/tests
CARTESI_IMAGES_PATH: /usr/share/cartesi-machine/images
CARTESI_UARCH_PATH: /usr/share/cartesi-machine/uarch/uarch-ram.bin
jobs:
build:
name: Build
runs-on: ubuntu-latest-8-cores
permissions:
packages: write
contents: read
steps:
- name: Checkout machine emulator source code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup variables
run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build docker image
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ github.repository_owner }}/machine-emulator:devel.build
push: false
load: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
GIT_COMMIT=${GITHUB_SHA}
MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }}
project: ${{ vars.DEPOT_PROJECT }}
token: ${{ secrets.DEPOT_TOKEN }}
- name: Build debian package (amd64)
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
target: debian-packager
platforms: linux/amd64
tags: cartesi/machine-emulator:amd64_deb
push: false
load: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
GIT_COMMIT=${GITHUB_SHA}
MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }}
project: ${{ vars.DEPOT_PROJECT }}
token: ${{ secrets.DEPOT_TOKEN }}
- name: Export deb package artifact (amd64)
run: make copy BUILD_PLATFORM=linux/amd64 ARCH=amd64 DEBIAN_IMG=cartesi/machine-emulator:amd64_deb
- name: Build debian package (arm64)
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
target: debian-packager
platforms: linux/arm64
tags: cartesi/machine-emulator:arm64_deb
push: false
load: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
GIT_COMMIT=${GITHUB_SHA}
MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }}
project: ${{ vars.DEPOT_PROJECT }}
token: ${{ secrets.DEPOT_TOKEN }}
- name: Export deb package artifact (arm64)
run: make copy BUILD_PLATFORM=linux/arm64 ARCH=arm64 DEBIAN_IMG=cartesi/machine-emulator:arm64_deb
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: artifacts
path: |
uarch-ram.bin
cartesi-machine-v${{ env.MACHINE_EMULATOR_VERSION }}_amd64.deb
cartesi-machine-v${{ env.MACHINE_EMULATOR_VERSION }}_arm64.deb
test_amd64:
name: Test (linux/amd64)
needs: build
runs-on: ubuntu-latest-8-cores
steps:
- name: Checkout machine emulator source code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup variables
run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build docker image
id: docker_build
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
target: installer
platforms: linux/amd64
tags: ${{ github.repository_owner }}/machine-emulator:devel
push: false
load: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
GIT_COMMIT=${GITHUB_SHA}
MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }}
project: ${{ vars.DEPOT_PROJECT }}
token: ${{ secrets.DEPOT_TOKEN }}
- name: Download [rootfs.ext2]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/image-rootfs
tag: ${{ env.ROOTFS_VERSION }}
file: rootfs-${{ env.ROOTFS_VERSION }}.ext2
- name: Download [kernel.bin]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/image-kernel
tag: ${{ env.KERNEL_VERSION }}
file: linux-${{ env.LINUX_VERSION }}.bin
- name: Move images to cartesi images folder
run: |
mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }}
mv linux-*.bin rootfs-*.ext2 ${{ env.CARTESI_IMAGES_PATH }}
cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin
cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2
- name: Download test suite
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/machine-tests
tag: ${{ env.TEST_VERSION }}
file: machine-tests-${{ env.TEST_VERSION }}.tar.gz
- name: Untar test suite
run: mkdir -p ${{ env.CARTESI_TESTS_PATH }} && tar -xzf machine-tests-${{ env.TEST_VERSION }}.tar.gz -C ${{ env.CARTESI_TESTS_PATH }}
- name: Simple boot inside the docker image
run: docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine /bin/true
- name: Run test suite inside the docker image
run: docker run --rm -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test-path=${{ env.CARTESI_TESTS_PATH }} run
- name: Save and Load
run: |
mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }}/snapshots
docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine --max-mcycle=0 --rollup --store=${{ env.CARTESI_IMAGES_PATH }}/snapshots/save_and_load_test
docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine --load=${{ env.CARTESI_IMAGES_PATH }}/snapshots/save_and_load_test
sudo rm -rf ${{ env.CARTESI_IMAGES_PATH }}/snapshots
- name: Run test scripts
run: |
docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/run.sh
- name: Run grpc lua test scripts
run: |
docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-grpc-server.sh remote-cartesi-machine cartesi-machine cartesi-machine-tests ${{ env.CARTESI_TESTS_PATH }}
- name: Run jsonrpc lua test scripts
run: |
docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-jsonrpc-server.sh jsonrpc-remote-cartesi-machine cartesi-machine cartesi-machine-tests ${{ env.CARTESI_TESTS_PATH }}
- name: Run Merkle tree tests
run: |
docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-merkle-tree-hash --log2-root-size=30 --log2-leaf-size=12 --input=./src/tests/test-merkle-tree-hash
- name: Run C API tests
run: |
docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-machine-c-api
- name: Test microarchitecture interpreter
run: |
docker run --rm -t ${{ github.repository_owner }}/machine-emulator:devel make uarch-tests run-uarch-tests JOBS=-j$(nproc)
- name: Run rv64ui test suite on microarchitecture
run: |
docker run --rm -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/uarch-riscv-tests --test-path=${{ env.CARTESI_TESTS_PATH }} run
- name: Run test suite with Microarchitecture
run: |
docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test-path=${{ env.CARTESI_TESTS_PATH }} --uarch-ram-length=0x20000 --uarch-ram-image=${{ env.CARTESI_UARCH_PATH }} --jobs=$(nproc) run_uarch
- name: Run test suite with microarchitecture and host based interpreters comparing machine hashes at every step
run: |
docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test="^rv64ui.*$" --test-path=${{ env.CARTESI_TESTS_PATH }} --uarch-ram-length=0x20000 --uarch-ram-image=${{ env.CARTESI_UARCH_PATH }} --jobs=$(nproc) run_host_and_uarch
- name: Create uarch json logs to be used to test the Solidity based microarchitecture interpreter
run: |
mkdir -p /opt/cartesi/share/logs/uarch-riscv-tests-json-logs
docker run --rm -v /opt/cartesi/share/logs:/opt/cartesi/share/logs -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/uarch-riscv-tests --test-path=${{ env.CARTESI_TESTS_PATH }} --output-dir=/opt/cartesi/share/logs/uarch-riscv-tests-json-logs --proofs --proofs-frequency=1 json-logs
- name: Compress uarch json logs
run: tar -czf uarch-riscv-tests-json-logs.tar.gz -C /opt/cartesi/share/logs/uarch-riscv-tests-json-logs .
- name: Upload uarch json logs to be used to test the Solidity based microarchitecture interpreter
uses: actions/upload-artifact@master
with:
name: artifacts
path: uarch-riscv-tests-json-logs.tar.gz
test_arm64:
name: Test (linux/arm64)
needs: build
runs-on: ubuntu-latest-8-cores
steps:
- name: Checkout machine emulator source code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup variables
run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build docker image
id: docker_build
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
target: installer
platforms: linux/arm64
tags: ${{ github.repository_owner }}/machine-emulator:devel
push: false
load: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
GIT_COMMIT=${GITHUB_SHA}
MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }}
project: ${{ vars.DEPOT_PROJECT }}
token: ${{ secrets.DEPOT_TOKEN }}
- name: Download [rootfs.ext2]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/image-rootfs
tag: ${{ env.ROOTFS_VERSION }}
file: rootfs-${{ env.ROOTFS_VERSION }}.ext2
- name: Download [kernel.bin]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/image-kernel
tag: ${{ env.KERNEL_VERSION }}
file: linux-${{ env.LINUX_VERSION }}.bin
- name: Move images to cartesi images folder
run: |
mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }}
mv linux-*.bin rootfs-*.ext2 ${{ env.CARTESI_IMAGES_PATH }}/
cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin
cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2
- name: Download test suite
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/machine-tests
tag: ${{ env.TEST_VERSION }}
file: machine-tests-${{ env.TEST_VERSION }}.tar.gz
- name: Untar test suite
run: mkdir -p ${{ env.CARTESI_TESTS_PATH }} && tar -xzf machine-tests-${{ env.TEST_VERSION }}.tar.gz -C ${{ env.CARTESI_TESTS_PATH }}
- name: Simple boot inside the docker image
run: docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine /bin/true
- name: Run test suite inside the docker image
run: docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test-path=${{ env.CARTESI_TESTS_PATH }} run
- name: Save and Load
run: |
mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }}/snapshots
docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine --max-mcycle=0 --rollup --store=${{ env.CARTESI_IMAGES_PATH }}/snapshots/save_and_load_test
docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine --load=${{ env.CARTESI_IMAGES_PATH }}/snapshots/save_and_load_test
sudo rm -rf ${{ env.CARTESI_IMAGES_PATH }}/snapshots
- name: Run test scripts
run: |
docker run --platform linux/arm64 -e "CARTESI_CONCURRENCY_UPDATE_MERKLE_TREE=1" --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/run.sh
- name: Run grpc lua test scripts
run: |
docker run --platform linux/arm64 -e "CARTESI_CONCURRENCY_UPDATE_MERKLE_TREE=1" --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-grpc-server.sh remote-cartesi-machine cartesi-machine cartesi-machine-tests ${{ env.CARTESI_TESTS_PATH }}
- name: Run jsonrpc lua test scripts
run: |
docker run --platform linux/arm64 -e "CARTESI_CONCURRENCY_UPDATE_MERKLE_TREE=1" --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-jsonrpc-server.sh jsonrpc-remote-cartesi-machine cartesi-machine cartesi-machine-tests ${{ env.CARTESI_TESTS_PATH }}
- name: Run Merkle tree tests
run: |
docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-merkle-tree-hash --log2-root-size=30 --log2-leaf-size=12 --input=./src/tests/test-merkle-tree-hash
- name: Run C API tests
run: |
docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-machine-c-api
- name: Test microarchitecture interpreter
run: |
docker run --platform linux/arm64 --rm -t ${{ github.repository_owner }}/machine-emulator:devel make uarch-tests JOBS=-j$(nproc)
- name: Run rv64ui test suite on microarchitecture
run: |
docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/uarch-riscv-tests --test-path=${{ env.CARTESI_TESTS_PATH }} run
- name: Run test suite with Microarchitecture
run: |
docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test-path=${{ env.CARTESI_TESTS_PATH }} --uarch-ram-length=0x20000 --uarch-ram-image=${{ env.CARTESI_UARCH_PATH }} --jobs=$(nproc) run_uarch
- name: Run test suite with microarchitecture and host based interpreters comparing machine hashes at every step
run: |
docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test="^rv64ui%-v%-add.bin$" --test-path=${{ env.CARTESI_TESTS_PATH }} --concurrency=update_merkle_tree:1 --uarch-ram-length=0x20000 --uarch-ram-image=${{ env.CARTESI_UARCH_PATH }} --jobs=$(nproc) run_host_and_uarch
static-analysis:
name: Static Analysis
needs: build
runs-on: ubuntu-latest-8-cores
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup variables
run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build docker image
id: docker_build
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
target: builder
platforms: linux/amd64
tags: ${{ github.repository_owner }}/machine-emulator:devel
push: false
load: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
GIT_COMMIT=${GITHUB_SHA}
MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }}
project: ${{ vars.DEPOT_PROJECT }}
token: ${{ secrets.DEPOT_TOKEN }}
- name: Check format (C++)
run: |
docker run --rm -t ${{ github.repository_owner }}/machine-emulator:devel make check-format
- name: Check format (Lua)
run: |
docker run --rm -t ${{ github.repository_owner }}/machine-emulator:devel make check-format-lua
- name: Lint (C++)
run: |
docker run --rm -t ${{ github.repository_owner }}/machine-emulator:devel make -j$(nproc) lint
- name: Lint (Lua)
run: |
docker run --rm -t ${{ github.repository_owner }}/machine-emulator:devel make check-lua
coverage:
name: Coverage
runs-on: ubuntu-latest-8-cores
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup variables
run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build docker image
id: docker_build
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
target: installer
platforms: linux/amd64
tags: ${{ github.repository_owner }}/machine-emulator:coverage
push: false
load: true
cache-from: type=gha,scope=debian-coverage
cache-to: type=gha,mode=max,scope=debian-coverage
build-args: |
GIT_COMMIT=${GITHUB_SHA}
RELEASE=no
COVERAGE=yes
MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }}
project: ${{ vars.DEPOT_PROJECT }}
token: ${{ secrets.DEPOT_TOKEN }}
- name: Download [rootfs.ext2]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/image-rootfs
tag: ${{ env.ROOTFS_VERSION }}
file: rootfs-${{ env.ROOTFS_VERSION }}.ext2
- name: Download [kernel.bin]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/image-kernel
tag: ${{ env.KERNEL_VERSION }}
file: linux-${{ env.LINUX_VERSION }}.bin
- name: Move images to cartesi images folder
run: |
mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }}
mv linux-*.bin rootfs-*.ext2 ${{ env.CARTESI_IMAGES_PATH }}/
cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin
cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2
- name: Download test suite
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/machine-tests
tag: ${{ env.TEST_VERSION }}
file: machine-tests-${{ env.TEST_VERSION }}.tar.gz
- name: Untar test suite
run: |
mkdir -m 775 -p ${{ env.CARTESI_TESTS_PATH }} /opt/cartesi/share/coverage
tar -xzf machine-tests-${{ env.TEST_VERSION }}.tar.gz -C ${{ env.CARTESI_TESTS_PATH }}
- name: Run coverage
run: |
docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v /opt/cartesi/share/coverage:/opt/cartesi/share/coverage -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:coverage make -j1 test-all coverage-report COVERAGE_OUTPUT_DIR=/opt/cartesi/share/coverage
- name: Show coverage summary
run: cat /opt/cartesi/share/coverage/coverage.txt
- name: Show uncovered lines
if: false
run: grep -F -e "=====:" -e "#####:" /opt/cartesi/share/coverage/gcc/*.gcov
- name: Upload coverage detailed report
uses: actions/upload-artifact@master
with:
name: coverage-report
path: /opt/cartesi/share/coverage
sanitize:
name: Sanitize
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Setup variables
run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build docker image
id: docker_build
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
target: installer
platforms: linux/amd64
tags: ${{ github.repository_owner }}/machine-emulator:sanitize
push: false
load: true
cache-from: type=gha,scope=debian-sanitize
cache-to: type=gha,mode=max,scope=debian-sanitize
build-args: |
RELEASE=no
GIT_COMMIT=${GITHUB_SHA}
SANITIZE=yes
MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }}
project: ${{ vars.DEPOT_PROJECT }}
token: ${{ secrets.DEPOT_TOKEN }}
- name: Download [rootfs.ext2]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/image-rootfs
tag: ${{ env.ROOTFS_VERSION }}
file: rootfs-${{ env.ROOTFS_VERSION }}.ext2
- name: Download [kernel.bin]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/image-kernel
tag: ${{ env.KERNEL_VERSION }}
file: linux-${{ env.LINUX_VERSION }}.bin
- name: Move images to cartesi images folder
run: |
mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }}
mv linux-*.bin rootfs-*.ext2 ${{ env.CARTESI_IMAGES_PATH }}/
cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin
cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2
- name: Download test suite
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/machine-tests
tag: ${{ env.TEST_VERSION }}
file: machine-tests-${{ env.TEST_VERSION }}.tar.gz
- name: Untar test suite
run: |
mkdir -m 775 -p ${{ env.CARTESI_TESTS_PATH }}
tar -xzf machine-tests-${{ env.TEST_VERSION }}.tar.gz -C ${{ env.CARTESI_TESTS_PATH }}
- name: Run tests with sanitizer
run: |
docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:sanitize make sanitize=yes test test-hash test-scripts test-jsonrpc test-c-api test-uarch-for-coverage test-linux-workload
publish_artifacts:
name: Publish artifacts
needs: [static-analysis, coverage, sanitize, test_amd64, test_arm64]
runs-on: ubuntu-22.04
steps:
- name: Checkout emulator source code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup variables
run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup debian docker image tags
id: docker_image_tags
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository_owner }}/machine-emulator
docker.io/${{ github.repository_owner }}/machine-emulator,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/tags/v') }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}},enable=${{startsWith(github.ref, 'refs/tags/v')}}
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build debian based docker image
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.docker_image_tags.outputs.tags }}
push: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
GIT_COMMIT=${GITHUB_SHA}
MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }}
project: ${{ vars.DEPOT_PROJECT }}
token: ${{ secrets.DEPOT_TOKEN }}
- name: Download artifacts
uses: actions/download-artifact@master
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Create uarch json logs TAR
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: mv artifacts/uarch-riscv-tests-json-logs.tar.gz artifacts/uarch-riscv-tests-json-logs-v${{ env.MACHINE_EMULATOR_VERSION }}.tar.gz
- name: Upload TAR and DEB to GitHub Release
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
draft: true
files: |
artifacts/uarch-riscv-tests-json-logs-*.tar.gz
artifacts/cartesi-machine-*.deb
artifacts/uarch-ram.bin