CI test more and cache image (#92)

This commit is contained in:
Han
2025-08-15 22:53:12 +08:00
committed by GitHub
parent bf6d94f32a
commit 06d15a4a77
21 changed files with 401 additions and 361 deletions

26
.github/workflows/check-fmt.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Check formatting
on:
push:
branches:
- master
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
name: Check formatting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Run cargo fmt
run: cargo fmt --check --all

View File

@@ -1,35 +0,0 @@
name: Check Base Docker Image
on:
push:
branches:
- master
paths:
- 'docker/base/**'
- '.github/workflows/check_base_image.yml'
pull_request:
branches:
- master
paths:
- 'docker/base/**'
- '.github/workflows/check_base_image.yml'
workflow_dispatch:
jobs:
build_base_image:
name: Build Base Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker base image
run: |
docker build \
--file docker/base/Dockerfile.base \
--tag ere-base-check:latest \
.

View File

@@ -1,41 +0,0 @@
name: Check Non-zkVM crates
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
jobs:
test_interface_crates:
name: Build and Test Interface Crates
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Rust toolchain (stable)
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
key: zkvm-interface-deps
- name: Check zkvm-interface
run: cargo check --package zkvm-interface --verbose
- name: Test zkvm-interface
run: cargo test --package zkvm-interface --verbose
- name: Check formatting for zkvm-interface
run: cargo fmt --package zkvm-interface -- --check
- name: Run Clippy for zkvm-interface
run: cargo clippy --package zkvm-interface -- -D warnings

View File

@@ -1,36 +0,0 @@
name: Check Jolt Docker Image
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
jobs:
build_jolt_image:
name: Build Jolt Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build dependent Docker base image
run: |
docker build \
--file docker/base/Dockerfile.base \
--tag ere-base:latest \
.
- name: Build Jolt Docker image
run: |
docker build \
--file docker/jolt/Dockerfile \
--tag ere-builder-jolt-check:latest \
.

View File

@@ -1,94 +0,0 @@
name: Rust Checks
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
check-fmt:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --check --all
check-clippy:
name: Clippy
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- zkvm: jolt
toolchain: 1.85.0
- zkvm: nexus
toolchain: nightly-2025-06-05
- zkvm: openvm
toolchain: 1.85.0
- zkvm: pico
toolchain: nightly-2024-11-27
- zkvm: risc0
toolchain: 1.85.0
- zkvm: sp1
toolchain: 1.85.0
- zkvm: zisk
toolchain: 1.85.0
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Check clippy ere-${{ matrix.zkvm }}
run: cargo +${{ matrix.toolchain }} clippy --bins --lib --examples --tests --benches -p ere-${{ matrix.zkvm }}
- name: Check clippy ere-cli with feature ${{ matrix.zkvm }}
run: cargo +${{ matrix.toolchain }} clippy --bins --lib --examples --tests --benches -p ere-cli --features cli,${{ matrix.zkvm }}
check-tests:
name: Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
zkvm: [sp1, risc0]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --release -p ere-dockerized -- ${{ matrix.zkvm }}

39
.github/workflows/test-common.yml vendored Normal file
View File

@@ -0,0 +1,39 @@
name: Test and clippy common crates
on:
push:
branches:
- master
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test and clippy crate ${{ matrix.crate }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
crate:
- build-utils
- test-utils
- zkvm-interface
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Run cargo clippy
run: cargo clippy --all-targets --package ${{ matrix.crate }} -- -D warnings
- name: Run cargo test
run: cargo test --release --package ${{ matrix.crate }}

View File

@@ -1,33 +0,0 @@
name: Test Nexus (Docker)
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test-nexus-via-docker-build:
name: Build Nexus Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build ere-base image
run: |
docker build \
--tag ere-base:latest \
--file docker/base/Dockerfile.base .
- name: Build ere-builder-nexus image
run: |
docker build \
--tag ere-builder-nexus:latest \
--file docker/nexus/Dockerfile .

View File

@@ -1,33 +0,0 @@
name: Test OpenVM (Docker)
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test-openvm-via-docker-build:
name: Build OpenVM Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build ere-base image
run: |
docker build \
--tag ere-base:latest \
--file docker/base/Dockerfile.base .
- name: Build ere-builder-openvm image
run: |
docker build \
--tag ere-builder-openvm:latest \
--file docker/openvm/Dockerfile .

View File

@@ -1,33 +0,0 @@
name: Test Pico (Docker)
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test-pico-via-docker-build:
name: Build Pico Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build ere-base image
run: |
docker build \
--tag ere-base:latest \
--file docker/base/Dockerfile.base .
- name: Build ere-builder-pico image
run: |
docker build \
--tag ere-builder-pico:latest \
--file docker/pico/Dockerfile .

View File

@@ -1,34 +0,0 @@
name: Test ZisK (Docker)
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test-zisk-via-docker-build:
name: Build ZisK Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build ere-base image
run: |
docker build \
--tag ere-base:latest \
--file docker/base/Dockerfile.base .
- name: Build ere-builder-zisk image
run: |
docker build \
--tag ere-builder-zisk:latest \
--file docker/zisk/Dockerfile \
--build-arg CI=1 .

19
.github/workflows/test-zkvm-jolt.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Test and clippy Jolt
on:
push:
branches:
- master
pull_request:
jobs:
test:
uses: ./.github/workflows/test-zkvm.yml
permissions:
contents: read
packages: write
with:
zkvm: jolt
toolchain: 1.85.0
test_ere_dockerized: false
test_options: ''

19
.github/workflows/test-zkvm-nexus.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Test and clippy Nexus
on:
push:
branches:
- master
pull_request:
jobs:
test:
uses: ./.github/workflows/test-zkvm.yml
permissions:
contents: read
packages: write
with:
zkvm: nexus
toolchain: nightly-2025-04-06
test_ere_dockerized: false
test_options: ''

19
.github/workflows/test-zkvm-openvm.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Test and clippy OpenVM
on:
push:
branches:
- master
pull_request:
jobs:
test:
uses: ./.github/workflows/test-zkvm.yml
permissions:
contents: read
packages: write
with:
zkvm: openvm
toolchain: 1.85.0
test_ere_dockerized: true
test_options: ''

19
.github/workflows/test-zkvm-pico.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Test and clippy Pico
on:
push:
branches:
- master
pull_request:
jobs:
test:
uses: ./.github/workflows/test-zkvm.yml
permissions:
contents: read
packages: write
with:
zkvm: pico
toolchain: nightly-2024-11-27
test_ere_dockerized: false
test_options: ''

19
.github/workflows/test-zkvm-risc0.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Test and clippy Risc0
on:
push:
branches:
- master
pull_request:
jobs:
test:
uses: ./.github/workflows/test-zkvm.yml
permissions:
contents: read
packages: write
with:
zkvm: risc0
toolchain: 1.85.0
test_ere_dockerized: true
test_options: ''

19
.github/workflows/test-zkvm-sp1.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Test and clippy SP1
on:
push:
branches:
- master
pull_request:
jobs:
test:
uses: ./.github/workflows/test-zkvm.yml
permissions:
contents: read
packages: write
with:
zkvm: sp1
toolchain: 1.85.0
test_ere_dockerized: true
test_options: ''

19
.github/workflows/test-zkvm-zisk.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Test and clippy ZisK
on:
push:
branches:
- master
pull_request:
jobs:
test:
uses: ./.github/workflows/test-zkvm.yml
permissions:
contents: read
packages: write
with:
zkvm: zisk
toolchain: 1.85.0
test_ere_dockerized: false
test_options: 'execute compile'

178
.github/workflows/test-zkvm.yml vendored Normal file
View File

@@ -0,0 +1,178 @@
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.85.0
test_ere_dockerized:
description: 'Whether test ere-dockerized with the selected zkVM or not'
required: false
type: boolean
default: true
# Remove when we use larger runners, currently only needed to skip some zisk test
test_options:
description: 'Cargo test options when testing via Docker'
required: false
type: string
default: ''
env:
CARGO_TERM_COLOR: always
jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.toolchain }}
components: clippy
- name: Run cargo clippy for ere-${{ inputs.zkvm }}
run: |
cargo clippy --all-targets \
--package ere-${{ inputs.zkvm }} \
-- -D warnings
- name: Run cargo clippy for ere-cli with feature ${{ inputs.zkvm }}
run: |
cargo clippy --all-targets \
--package ere-cli \
--features cli,${{ inputs.zkvm }} \
-- -D warnings
build_image:
name: Build image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image_version: ${{ steps.inspect_image.outputs.image_version }}
base_image_tag: ${{ steps.inspect_image.outputs.base_image_tag }}
base_zkvm_image_tag: ${{ steps.inspect_image.outputs.base_zkvm_image_tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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: Get image version and tags of ere-base and ere-base-${{ inputs.zkvm }}
id: inspect_image
run: |
ZKVM_CRATE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "ere-${{ inputs.zkvm }}") | .version')
GIT_REV=$(git rev-parse --short=7 HEAD)
IMAGE_VERSION="$ZKVM_CRATE_VERSION-$GIT_REV"
BASE_IMAGE_TAG="ghcr.io/${{ github.repository }}/ere-base:$IMAGE_VERSION"
BASE_ZKVM_IMAGE_TAG="ghcr.io/${{ github.repository }}/ere-base-${{ inputs.zkvm }}:$IMAGE_VERSION"
echo "image_version=$IMAGE_VERSION" >> $GITHUB_OUTPUT
echo "base_image_tag=$BASE_IMAGE_TAG" >> $GITHUB_OUTPUT
echo "base_zkvm_image_tag=$BASE_ZKVM_IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Build ere-base image
uses: docker/build-push-action@v6
with:
context: .
file: docker/base/Dockerfile.base
push: true
tags: ${{ steps.inspect_image.outputs.base_image_tag }}
- name: Build ere-base-${{ inputs.zkvm }} image
uses: docker/build-push-action@v6
with:
context: .
file: docker/${{ inputs.zkvm }}/Dockerfile
push: true
tags: ${{ steps.inspect_image.outputs.base_zkvm_image_tag }}
build-args: |
CI=1
BASE_IMAGE_TAG=${{ steps.inspect_image.outputs.base_image_tag }}
test_via_docker:
name: Test via Docker
needs: build_image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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: Pull image ere-base-${{ inputs.zkvm }}
run: docker image pull ${{ needs.build_image.outputs.base_zkvm_image_tag }}
- name: Run cargo test for ere-${{ inputs.zkvm }} via Docker
run: |
docker run \
--rm \
--volume ${{ github.workspace }}:/ere \
--workdir /ere \
${{ needs.build_image.outputs.base_zkvm_image_tag }} \
cargo test --release --package ere-${{ inputs.zkvm }} -- ${{ inputs.test_options }}
test_ere_dockerized:
name: Test ere-dockerized with the selected zkVM
if: ${{ inputs.test_ere_dockerized }}
needs: build_image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.toolchain }}
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- 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: Pull image ere-base and ere-base-${{ inputs.zkvm }}
run: |
docker image pull ${{ needs.build_image.outputs.base_image_tag }}
docker image pull ${{ needs.build_image.outputs.base_zkvm_image_tag }}
docker image tag ${{ needs.build_image.outputs.base_image_tag }} ere-base:${{ needs.build_image.outputs.image_version }}
docker image tag ${{ needs.build_image.outputs.base_zkvm_image_tag }} ere-base-${{ inputs.zkvm }}:${{ needs.build_image.outputs.image_version }}
- name: Run cargo test for ere-${{ inputs.zkvm }} via ere-dockerized
run: cargo test --release --package ere-dockerized -- ${{ inputs.zkvm }}

View File

@@ -10,13 +10,13 @@ COPY scripts/sdk_installers/install_nexus_sdk.sh /tmp/install_nexus_sdk.sh
RUN chmod +x /tmp/install_nexus_sdk.sh
# Run the Nexus SDK installation script.
# This script installs the specific Rust toolchain (nightly-2025-06-05)
# This script installs the specific Rust toolchain (nightly-2025-04-06)
# and installs cargo-nexus
# The CARGO_HOME from ere-base (e.g., /root/.cargo) will be used, and cargo-nexus will be in its bin.
RUN /tmp/install_nexus_sdk.sh && rm /tmp/install_nexus_sdk.sh # Clean up the script
# Define the Nexus toolchain for convenience in subsequent commands if needed, though cargo pico should use it.
ENV NEXUS_TOOLCHAIN_VERSION="nightly-2025-06-05"
# Define the Nexus toolchain for convenience in subsequent commands if needed.
ENV NEXUS_TOOLCHAIN_VERSION="nightly-2025-04-06"
# Set default toolchain
RUN rustup default "$NEXUS_TOOLCHAIN_VERSION"

View File

@@ -31,15 +31,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
clang && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/$(. /etc/os-release && echo "${ID}${VERSION_ID}" | tr -d '.')/$(uname -i)/cuda-keyring_1.1-1_all.deb && \
# If current environment is in CI or not.
ARG CI
RUN [ -n "$CI" ] || \
(wget https://developer.download.nvidia.com/compute/cuda/repos/$(. /etc/os-release && echo "${ID}${VERSION_ID}" | tr -d '.')/$(uname -i)/cuda-keyring_1.1-1_all.deb && \
dpkg -i cuda-keyring_1.1-1_all.deb && \
rm cuda-keyring_1.1-1_all.deb && \
apt update && \
apt install -y cuda-toolkit-12-9 && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# If current environment is in CI or not.
ARG CI
apt-get clean && rm -rf /var/lib/apt/lists/*)
# Copy the ZisK SDK installer script from the workspace context
COPY scripts/sdk_installers/install_zisk_sdk.sh /tmp/install_zisk_sdk.sh

View File

@@ -59,21 +59,23 @@ else
exit 1
fi
# Step 3: Build cargo-zisk-gpu from source with GPU features enabled
TEMP_DIR=$(mktemp -d)
git clone https://github.com/0xPolygonHermez/zisk.git --single-branch --branch "v$ZISK_VERSION" "$TEMP_DIR/zisk"
cd "$TEMP_DIR/zisk"
cargo build --release --features gpu
cp ./target/release/cargo-zisk "${HOME}/.zisk/bin/cargo-zisk-gpu"
cp ./target/release/libzisk_witness.so "${HOME}/.zisk/bin/libzisk_witness_gpu.so"
rm -rf "$TEMP_DIR"
# Step 3: Build cargo-zisk-gpu from source with GPU features enabled (skip if in CI)
if [ -z $CI ]; then
TEMP_DIR=$(mktemp -d)
git clone https://github.com/0xPolygonHermez/zisk.git --single-branch --branch "v$ZISK_VERSION" "$TEMP_DIR/zisk"
cd "$TEMP_DIR/zisk"
cargo build --release --features gpu
cp ./target/release/cargo-zisk "${HOME}/.zisk/bin/cargo-zisk-gpu"
cp ./target/release/libzisk_witness.so "${HOME}/.zisk/bin/libzisk_witness_gpu.so"
rm -rf "$TEMP_DIR"
echo "Checking for cargo-zisk-gpu CLI tool..."
if cargo-zisk-gpu --version; then
echo "cargo-zisk-gpu CLI tool verified successfully."
else
echo "Error: 'cargo-zisk-gpu --version' failed." >&2
exit 1
echo "Checking for cargo-zisk-gpu CLI tool..."
if cargo-zisk-gpu --version; then
echo "cargo-zisk-gpu CLI tool verified successfully."
else
echo "Error: 'cargo-zisk-gpu --version' failed." >&2
exit 1
fi
fi
# Step 4: Make sure `lib-c`'s build script is ran.