Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/CD crates.io & docker auto publish #27

Merged
merged 8 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Ignore the entire target directory, as it's used for build artifacts
/target

# Ignore any generated documentation
/doc

# Ignore temporary files
*.rs.bk
*.rs.swp
*.rs.swo

# Ignore build scripts output
/build.rs

# Ignore files for specific editors or IDEs
*.iml
*.idea
.vscode
*.swp

# Ignore OS generated files
.DS_Store
Thumbs.db

# Ignore backup and log files
*.log
*.bak
*.tmp
*.old
*.swp

# Ignore git-related files
.git
.gitignore

Dockerfile
61 changes: 61 additions & 0 deletions .github/workflows/cargo_publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Manual Publish to Crates.io

on:
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest

env:
WORKING_DIR: ${{ github.workspace }}
WORKING_DIR_CLI: ${{ github.workspace }}/cli
WORKING_DIR_PROOF_PARSER: ${{ github.workspace }}/proof_parser

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Cache Cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-

- name: Cache Cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-

- name: Install dependencies
run: cargo fetch

- name: Run tests
run: cargo test --all

- name: Publish crates to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: |
cargo publish -p swiftness_transcript --token $CARGO_REGISTRY_TOKEN --manifest-path ${{ env.WORKING_DIR }}/Cargo.toml
cargo publish -p swiftness_pow --token $CARGO_REGISTRY_TOKEN --manifest-path ${{ env.WORKING_DIR }}/Cargo.toml
cargo publish -p swiftness_commitment --token $CARGO_REGISTRY_TOKEN --manifest-path ${{ env.WORKING_DIR }}/Cargo.toml
cargo publish -p swiftness_fri --token $CARGO_REGISTRY_TOKEN --manifest-path ${{ env.WORKING_DIR }}/Cargo.toml
cargo publish -p swiftness_air --token $CARGO_REGISTRY_TOKEN --manifest-path ${{ env.WORKING_DIR }}/Cargo.toml
cargo publish -p swiftness_stark --token $CARGO_REGISTRY_TOKEN --manifest-path ${{ env.WORKING_DIR }}/Cargo.toml
cargo publish -p swiftness_proof_parser --token $CARGO_REGISTRY_TOKEN --manifest-path ${{ env.WORKING_DIR_PROOF_PARSER }}/Cargo.toml
cargo publish -p swiftness --token $CARGO_REGISTRY_TOKEN --manifest-path ${{ env.WORKING_DIR_CLI }}/Cargo.toml
53 changes: 53 additions & 0 deletions .github/workflows/docker_publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish Docker Image

on:
workflow_dispatch:
inputs:
version:
description: "Docker image version"
required: true
default: "latest"

jobs:
build-and-push:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
layout:
[
"dex",
"recursive",
"recursive_with_poseidon",
"small",
"starknet",
"starknet_with_keccak",
]
hash: ["blake2s", "keccak"]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
driver: docker-container

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: runtime.dockerfile
tags: "okm165/swiftness:${{ github.event.inputs.version }}"
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
build-args: |
FEATURES=${{ matrix.layout }},${{ matrix.hash }}
20 changes: 14 additions & 6 deletions .github/workflows/npm_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ jobs:
strategy:
fail-fast: false
matrix:
layout: ["dex", "recursive", "recursive_with_poseidon", "small", "starknet", "starknet_with_keccak"]
layout:
[
"dex",
"recursive",
"recursive_with_poseidon",
"small",
"starknet",
"starknet_with_keccak",
]
hash: ["blake2s", "keccak"]

steps:
Expand All @@ -23,7 +31,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18' # specify your desired Node.js version
node-version: "18" # specify your desired Node.js version

- name: Configure npm
run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
Expand All @@ -38,22 +46,22 @@ jobs:
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-

- name: Cache Cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-

- name: Install wasm-pack
run: cargo install wasm-pack

- name: Build package
run: wasm-pack build --out-dir pkg --target web --features ${{ matrix.layout }},${{ matrix.hash }} --no-default-features
working-directory: ${{ env.WORKING_DIR }}

- name: Rename package
run: |
jq --arg layout "${{ matrix.layout }}" --arg hash "${{ matrix.hash }}" \
Expand Down
11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# Swiftness CairoVM Verifier

<div align="center">

![Version](https://img.shields.io/badge/v0.0.5-green?style=flat-square&logo=git&logoColor=white&label=version)
![Continuous Integration](https://img.shields.io/github/actions/workflow/status/iosis-tech/swiftness/ci.yml?style=flat-square&logo=githubactions&logoColor=white&label=Continuous%20Integration)

![Crates.io Version](https://img.shields.io/crates/v/swiftness?style=flat-square&logo=lootcrate&link=https%3A%2F%2Fcrates.io%2Fcrates%2Fswiftness)
![docs.rs](https://img.shields.io/docsrs/swiftness?style=flat-square&logo=docsdotrs&link=https%3A%2F%2Fdocs.rs%2Fswiftness%2Flatest%2Fswiftness%2F)
![hub.docker](https://img.shields.io/docker/pulls/okm165/swiftness?style=flat-square&logo=docker&logoColor=white&label=docker&link=https%3A%2F%2Fhub.docker.com%2Frepository%2Fdocker%2Fokm165%2Fswiftness%2Fgeneral)

</div>

Swiftness is a Rust implementation of the Cairo-VM STARK verifier with layouts, inspired by StarkWare's [Cairo-verifier](https://github.com/starkware-libs/cairo-lang) in Cairo0.


## Getting Started

### Verify an Example Proof
Expand Down
14 changes: 11 additions & 3 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "swiftness"
description = "CLI toolkit to use Swiftness - Rust CairoVM Verifier implementation"
description = "Swiftness - Rust CairoVM Verifier implementation"
edition = "2021"
license-file = "LICENSE"
readme = "../README.md"
Expand Down Expand Up @@ -34,5 +34,13 @@ starknet_with_keccak = [
"swiftness_air/starknet_with_keccak",
"swiftness_stark/starknet_with_keccak",
]
keccak = ["swiftness_stark/keccak"]
blake2s = ["swiftness_stark/blake2s"]
keccak = [
"swiftness_air/keccak",
"swiftness_stark/keccak",
"swiftness_proof_parser/keccak"
]
blake2s = [
"swiftness_air/blake2s",
"swiftness_stark/blake2s",
"swiftness_proof_parser/blake2s"
]
Loading
Loading