mirror of
https://github.com/eth-act/ere.git
synced 2026-04-03 03:00:17 -04:00
291 lines
11 KiB
YAML
291 lines
11 KiB
YAML
name: Test and clippy zkVM
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
zkvm:
|
|
description: 'zkVM to test'
|
|
required: true
|
|
type: string
|
|
toolchain:
|
|
description: 'Rust toolchain to use'
|
|
required: false
|
|
type: string
|
|
default: 1.88.0
|
|
# Remove when we use larger runners, currently only needed to skip for zisk
|
|
skip_prove_test:
|
|
description: 'Whether to skip prove test and ere-dockerized test or not'
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
build_image:
|
|
name: Build image
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
outputs:
|
|
image_registry: ${{ steps.image_meta.outputs.image_registry }}
|
|
image_tag: ${{ steps.image_meta.outputs.image_tag }}
|
|
cached_image_tag: ${{ steps.image_meta.outputs.cached_image_tag }}
|
|
base_image: ${{ steps.image_meta.outputs.base_image }}
|
|
base_zkvm_image: ${{ steps.image_meta.outputs.base_zkvm_image }}
|
|
compiler_zkvm_image: ${{ steps.image_meta.outputs.compiler_zkvm_image }}
|
|
server_zkvm_image: ${{ steps.image_meta.outputs.server_zkvm_image }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Free up disk space
|
|
run: bash .github/scripts/free-up-disk-space.sh
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Check Dockerfile changes
|
|
id: changed_files
|
|
uses: tj-actions/changed-files@v46
|
|
with:
|
|
files: |
|
|
docker/Dockerfile.base
|
|
docker/${{ inputs.zkvm }}/**
|
|
scripts/sdk_installers/install_${{ inputs.zkvm }}_sdk.sh
|
|
|
|
- name: Get image metadata
|
|
id: image_meta
|
|
run: |
|
|
ZKVM_CRATE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "ere-${{ inputs.zkvm }}") | .version')
|
|
|
|
GIT_REV="${{ github.sha }}"
|
|
if [ "${{ github.event_name }}" == "pull_request" ] && [ "${{ steps.changed_files.outputs.any_changed }}" == "false" ]; then
|
|
CACHED_GIT_REV="${{ github.event.pull_request.base.sha }}"
|
|
else
|
|
CACHED_GIT_REV="$GIT_REV"
|
|
fi
|
|
|
|
IMAGE_TAG="$ZKVM_CRATE_VERSION-${GIT_REV:0:7}"
|
|
CACHED_IMAGE_TAG="$ZKVM_CRATE_VERSION-${CACHED_GIT_REV:0:7}"
|
|
|
|
IMAGE_REGISTRY="ghcr.io/${{ github.repository }}"
|
|
BASE_IMAGE="$IMAGE_REGISTRY/ere-base:$IMAGE_TAG"
|
|
BASE_ZKVM_IMAGE="$IMAGE_REGISTRY/ere-base-${{ inputs.zkvm }}:$IMAGE_TAG"
|
|
COMPILER_ZKVM_IMAGE="$IMAGE_REGISTRY/ere-compiler-${{ inputs.zkvm }}:$IMAGE_TAG"
|
|
SERVER_ZKVM_IMAGE="$IMAGE_REGISTRY/ere-server-${{ inputs.zkvm }}:$IMAGE_TAG"
|
|
|
|
echo "image_registry=$IMAGE_REGISTRY" >> $GITHUB_OUTPUT
|
|
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
|
|
echo "cached_image_tag=$CACHED_IMAGE_TAG" >> $GITHUB_OUTPUT
|
|
echo "base_image=$BASE_IMAGE" >> $GITHUB_OUTPUT
|
|
echo "base_zkvm_image=$BASE_ZKVM_IMAGE" >> $GITHUB_OUTPUT
|
|
echo "compiler_zkvm_image=$COMPILER_ZKVM_IMAGE" >> $GITHUB_OUTPUT
|
|
echo "server_zkvm_image=$SERVER_ZKVM_IMAGE" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build ere-base image
|
|
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event.pull_request.head.repo.full_name == github.repository && steps.changed_files.outputs.any_changed == 'true')
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: docker/Dockerfile.base
|
|
push: true
|
|
tags: ${{ steps.image_meta.outputs.base_image }}
|
|
|
|
- name: Build ere-base-${{ inputs.zkvm }} image
|
|
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event.pull_request.head.repo.full_name == github.repository && steps.changed_files.outputs.any_changed == 'true')
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: docker/${{ inputs.zkvm }}/Dockerfile.base
|
|
push: true
|
|
tags: ${{ steps.image_meta.outputs.base_zkvm_image }}
|
|
build-args: |
|
|
BASE_IMAGE=${{ steps.image_meta.outputs.base_image }}
|
|
|
|
- name: Build ere-compiler-${{ inputs.zkvm }} image
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: docker/${{ inputs.zkvm }}/Dockerfile.compiler
|
|
push: true
|
|
tags: ${{ steps.image_meta.outputs.compiler_zkvm_image }}
|
|
build-args: |
|
|
BASE_ZKVM_IMAGE=${{ steps.image_meta.outputs.base_zkvm_image }}
|
|
|
|
- name: Build ere-server-${{ inputs.zkvm }} image
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: docker/${{ inputs.zkvm }}/Dockerfile.server
|
|
push: true
|
|
tags: ${{ steps.image_meta.outputs.server_zkvm_image }}
|
|
build-args: |
|
|
BASE_ZKVM_IMAGE=${{ steps.image_meta.outputs.base_zkvm_image }}
|
|
|
|
clippy_via_docker:
|
|
name: Clippy via Docker
|
|
needs: build_image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Free up disk space
|
|
run: bash .github/scripts/free-up-disk-space.sh
|
|
|
|
- name: Cache dependencies
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: rust-${{ inputs.toolchain }}-${{ inputs.zkvm }}-${{ hashFiles('Cargo.lock') }}
|
|
|
|
- name: Pull base zkvm image or build locally
|
|
run: |
|
|
bash .github/scripts/pull-or-build-base-zkvm-image.sh \
|
|
${{ inputs.zkvm }} \
|
|
${{ needs.build_image.outputs.image_registry }} \
|
|
${{ needs.build_image.outputs.image_tag }} \
|
|
${{ needs.build_image.outputs.cached_image_tag }}
|
|
|
|
- name: Run cargo clippy for ere-${{ inputs.zkvm }} via Docker
|
|
run: |
|
|
DOCKER_CMD="docker run \
|
|
--rm \
|
|
--interactive \
|
|
--volume ${{ github.workspace }}:/ere \
|
|
--volume $HOME/.cargo/registry:/usr/local/cargo/registry \
|
|
--volume $HOME/.cargo/git:/usr/local/cargo/git \
|
|
--workdir /ere \
|
|
${{ needs.build_image.outputs.base_zkvm_image }} \
|
|
/bin/bash"
|
|
|
|
cat <<EOF | $DOCKER_CMD
|
|
set -e -o pipefail
|
|
|
|
OPTIONS="--all-targets -- -D warnings"
|
|
cargo clippy --package ere-${{ inputs.zkvm }} \$OPTIONS
|
|
cargo clippy --package ere-compiler --features ${{ inputs.zkvm }} \$OPTIONS
|
|
cargo clippy --package ere-server --features ${{ inputs.zkvm }} \$OPTIONS
|
|
|
|
time chown -R $(id -u):$(id -g) /usr/local/cargo/registry
|
|
time chown -R $(id -u):$(id -g) /usr/local/cargo/git
|
|
time chown -R $(id -u):$(id -g) target
|
|
EOF
|
|
|
|
test_via_docker:
|
|
name: Test via Docker
|
|
needs: build_image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Free up disk space
|
|
run: bash .github/scripts/free-up-disk-space.sh
|
|
|
|
- name: Cache dependencies
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: rust-${{ inputs.toolchain }}-${{ inputs.zkvm }}-${{ hashFiles('Cargo.lock') }}
|
|
|
|
- name: Pull base zkvm image or build locally
|
|
run: |
|
|
bash .github/scripts/pull-or-build-base-zkvm-image.sh \
|
|
${{ inputs.zkvm }} \
|
|
${{ needs.build_image.outputs.image_registry }} \
|
|
${{ needs.build_image.outputs.image_tag }} \
|
|
${{ needs.build_image.outputs.cached_image_tag }}
|
|
|
|
- name: Run cargo test for ere-${{ inputs.zkvm }} via Docker
|
|
run: |
|
|
DOCKER_CMD="docker run \
|
|
--rm \
|
|
--interactive \
|
|
--volume ${{ github.workspace }}:/ere \
|
|
--volume $HOME/.cargo/registry:/usr/local/cargo/registry \
|
|
--volume $HOME/.cargo/git:/usr/local/cargo/git \
|
|
--workdir /ere \
|
|
${{ needs.build_image.outputs.base_zkvm_image }} \
|
|
/bin/bash"
|
|
|
|
cat <<EOF | $DOCKER_CMD
|
|
set -e -o pipefail
|
|
|
|
cargo test --release --package ere-${{ inputs.zkvm }} \
|
|
-- ${{ inputs.skip_prove_test && '--skip prove' || '' }}
|
|
|
|
time chown -R $(id -u):$(id -g) /usr/local/cargo/registry
|
|
time chown -R $(id -u):$(id -g) /usr/local/cargo/git
|
|
time chown -R $(id -u):$(id -g) target
|
|
EOF
|
|
|
|
test_ere_dockerized:
|
|
name: Test ere-dockerized with the selected zkVM
|
|
needs: build_image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Free up disk space
|
|
run: bash .github/scripts/free-up-disk-space.sh
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ inputs.toolchain }}
|
|
|
|
- name: Cache dependencies
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: rust-${{ inputs.toolchain }}-${{ inputs.zkvm }}-${{ hashFiles('Cargo.lock') }}
|
|
|
|
- name: Pull images or build locally
|
|
if: github.event_name == 'pull_request'
|
|
run: |
|
|
bash .github/scripts/pull-or-build-base-zkvm-image.sh \
|
|
${{ inputs.zkvm }} \
|
|
${{ needs.build_image.outputs.image_registry }} \
|
|
${{ needs.build_image.outputs.image_tag }} \
|
|
${{ needs.build_image.outputs.cached_image_tag }}
|
|
|
|
# Build ere-compiler-${{ inputs.zkvm }}
|
|
echo "Building ere-compiler-${{ inputs.zkvm }}"
|
|
docker build \
|
|
--file docker/${{ inputs.zkvm }}/Dockerfile.compiler \
|
|
--tag ${{ needs.build_image.outputs.compiler_zkvm_image }} \
|
|
--build-arg BASE_ZKVM_IMAGE=${{ needs.build_image.outputs.base_zkvm_image }} \
|
|
.
|
|
|
|
# Build ere-server-${{ inputs.zkvm }}
|
|
echo "Building ere-server-${{ inputs.zkvm }}"
|
|
docker build \
|
|
--file docker/${{ inputs.zkvm }}/Dockerfile.server \
|
|
--tag ${{ needs.build_image.outputs.server_zkvm_image }} \
|
|
--build-arg BASE_ZKVM_IMAGE=${{ needs.build_image.outputs.base_zkvm_image }} \
|
|
.
|
|
|
|
- name: Pull ere-compiler-${{ inputs.zkvm }} and ere-server-${{ inputs.zkvm }} images
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
run: |
|
|
docker pull ${{ needs.build_image.outputs.compiler_zkvm_image }}
|
|
docker pull ${{ needs.build_image.outputs.server_zkvm_image }}
|
|
|
|
- name: Run cargo test for ere-${{ inputs.zkvm }} via ere-dockerized
|
|
env:
|
|
ERE_IMAGE_REGISTRY: ${{ needs.build_image.outputs.image_registry }}
|
|
run: |
|
|
cargo test --release --package ere-dockerized \
|
|
-- ${{ inputs.zkvm }} ${{ inputs.skip_prove_test && '--skip prove' || '' }} --test-threads=1
|