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

feat: add WASM example #1315

Merged
merged 40 commits into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
dbd0049
Add example to workspace
MegaRedHand Jul 4, 2023
cd2923e
Rename example to wasm-demo, and add keywords
MegaRedHand Jul 6, 2023
bf07ed2
Update example
MegaRedHand Jul 6, 2023
55d7a55
Update readme and links
MegaRedHand Jul 7, 2023
c55cca1
Make example show result
MegaRedHand Jul 7, 2023
d74050b
Remove license, makefile, cairo contract
MegaRedHand Jul 7, 2023
d404fd9
Add contract source
MegaRedHand Jul 7, 2023
d316918
Update readme
MegaRedHand Jul 7, 2023
bc54e1d
Update main readme
MegaRedHand Jul 7, 2023
f3897ce
Update changelog
MegaRedHand Jul 7, 2023
72b2c80
Compile example program in CI
MegaRedHand Jul 7, 2023
6489632
Build example program also in CI
MegaRedHand Jul 7, 2023
dd3cb74
Modify dependencies in Makefile
MegaRedHand Jul 7, 2023
15238cc
Compile example program in test_install workflow
MegaRedHand Jul 7, 2023
889f7f3
Cache correctly
MegaRedHand Jul 7, 2023
a64ef69
Activate venv before running make check
MegaRedHand Jul 7, 2023
5c8f41e
Set pyenv local version in install scripts
MegaRedHand Jul 7, 2023
bfb30f6
Remove venv activation from test_install
MegaRedHand Jul 7, 2023
be6f133
Install requirements also in pyenv
MegaRedHand Jul 7, 2023
40d00fa
Add pyenv shims to PATH
MegaRedHand Jul 7, 2023
e7e9b87
Add pyenv shims to path (now for real)
MegaRedHand Jul 7, 2023
f7eb302
Remove unneeded command and add instructions
MegaRedHand Jul 7, 2023
19d5185
Fix workflow
MegaRedHand Jul 7, 2023
324d761
Merge install and compile steps
MegaRedHand Jul 8, 2023
8344d48
Source script
MegaRedHand Jul 8, 2023
9ddeb87
Apply Oppen's suggestions
MegaRedHand Jul 10, 2023
3531900
Add keywords to cli; use check instead of build
MegaRedHand Jul 11, 2023
c1561c5
Upload coverage from both runs and run on release
MegaRedHand Jul 11, 2023
6c40d86
Don't run in release
MegaRedHand Jul 11, 2023
358638d
Shallow clone repo before tests (+prints)
MegaRedHand Jul 11, 2023
b66f7a6
Partition tests to reduce .profraw amount
MegaRedHand Jul 11, 2023
98c619d
Merge branch 'main' into move-wasm-example
MegaRedHand Jul 11, 2023
6cc7f5d
Fix: don't use '/' in the name
MegaRedHand Jul 11, 2023
b6aba8d
Merge branch 'main' into move-wasm-example
MegaRedHand Jul 11, 2023
1209c2f
Fix cache path
MegaRedHand Jul 11, 2023
e6f21e2
Print only on debug
MegaRedHand Jul 11, 2023
e7d8751
Remove fetch-depth: 1 as it's the default
MegaRedHand Jul 11, 2023
62d6d8b
Remove prints
MegaRedHand Jul 11, 2023
c3a04a5
Merge branch 'main' into move-wasm-example
MegaRedHand Jul 13, 2023
a3f7624
Merge branch 'main' into move-wasm-example
MegaRedHand Jul 14, 2023
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
80 changes: 55 additions & 25 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
key: ${{ matrix.program-target }}-cache-${{ hashFiles( 'cairo_programs/**/*.cairo' ) }}
examples/wasm-demo/src/array_sum.json
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
restore-keys: ${{ matrix.program-target }}-cache-

# This is not pretty, but we need `make` to see the compiled programs are
Expand Down Expand Up @@ -81,7 +82,8 @@ jobs:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
key: cairo_test_programs-cache-${{ hashFiles( 'cairo_programs/**/*.cairo' ) }}
examples/wasm-demo/src/array_sum.json
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
- name: Fetch proof programs
uses: actions/cache/restore@v3
with:
Expand Down Expand Up @@ -137,7 +139,8 @@ jobs:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
key: cairo_test_programs-cache-${{ hashFiles( 'cairo_programs/**/*.cairo' ) }}
examples/wasm-demo/src/array_sum.json
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
- name: Fetch proof programs
uses: actions/cache/restore@v3
with:
Expand Down Expand Up @@ -184,17 +187,16 @@ jobs:
- name: Check no-std
run: |
cd ensure-no_std
cargo build --no-default-features
cargo build
cargo check --no-default-features
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to run cargo build instead of a check.

cargo check

tests:
needs: build-programs
strategy:
fail-fast: false
matrix:
special_features: ["", "lambdaworks-felt"]
target: [ test, test-no_std, test-wasm ]
# TODO: features
target: [ test#1, test#2, test-no_std, test-wasm ]
name: Run tests
runs-on: ubuntu-22.04
steps:
Expand All @@ -206,20 +208,15 @@ jobs:
uses: Swatinem/rust-cache@v2
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# This is not pretty, but we need `make` to see the compiled programs are
# actually newer than the sources, otherwise it will try to rebuild them
- name: Restore timestamps
uses: chetan/git-restore-mtime-action@v1

- name: Fetch test programs
uses: actions/cache/restore@v3
with:
path: |
cairo_programs/**/*.casm
cairo_programs/**/*.json
key: cairo_test_programs-cache-${{ hashFiles( 'cairo_programs/**/*.cairo' ) }}
examples/wasm-demo/src/array_sum.json
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'examples/wasm-demo/src/array_sum.cairo') }}
- name: Fetch proof programs
uses: actions/cache/restore@v3
with:
Expand All @@ -239,15 +236,23 @@ jobs:
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest,cargo-llvm-cov,wasm-pack
- name: Run

- name: Run ${{ matrix.target }}
run: |
# this splits the `test#1` into `test` and `1`
export MATRIX_TARGET=${{ matrix.target }}
export NAME=${MATRIX_TARGET%#*}
export PARTITION=${MATRIX_TARGET#*#}
# FIXME: we need to update the Makefile to do this correctly
case ${{ matrix.target }} in
case ${NAME} in
'test')
cargo llvm-cov nextest --lcov --output-path lcov-${{ matrix.target }}.info --workspace --features "cairo-1-hints, test_utils, ${{ matrix.special_features }}"
cargo llvm-cov nextest --lcov --output-path lcov-${{ matrix.target }}-${{ matrix.special_features }}.info \
--partition count:${PARTITION}/2 \
--workspace --features "cairo-1-hints, test_utils, ${{ matrix.special_features }}"
;;
'test-no_std')
cargo llvm-cov nextest --lcov --output-path lcov-${{ matrix.target }}.info --workspace --no-default-features --features "${{ matrix.special_features }}"
cargo llvm-cov nextest --lcov --output-path lcov-${{ matrix.target }}-${{ matrix.special_features }}.info \
--workspace --no-default-features --features "${{ matrix.special_features }}"
;;
'test-wasm')
# NOTE: release mode is needed to avoid "too many locals" error
Expand All @@ -259,8 +264,8 @@ jobs:
if: matrix.target != 'test-wasm'
uses: actions/cache/save@v3
with:
path: lcov-${{ matrix.target }}.info
key: codecov-cache-${{ matrix.target }}-${{ github.sha }}
path: lcov-${{ matrix.target }}-${{ matrix.special_features }}.info
key: codecov-cache-${{ matrix.target }}-${{ matrix.special_features }}-${{ github.sha }}


build-release:
Expand Down Expand Up @@ -399,17 +404,42 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Fetch results for tests with stdlib
- name: Fetch results for tests with stdlib (part. 1)
uses: actions/cache/restore@v3
with:
path: lcov-test#1-.info
key: codecov-cache-test#1--${{ github.sha }}
fail-on-cache-miss: true
- name: Fetch results for tests with stdlib (part. 2)
uses: actions/cache/restore@v3
with:
path: lcov-test.info
key: codecov-cache-test-${{ github.sha }}
path: lcov-test#2-.info
key: codecov-cache-test#2--${{ github.sha }}
fail-on-cache-miss: true
- name: Fetch results for tests without stdlib
uses: actions/cache/restore@v3
with:
path: lcov-test-no_std.info
key: codecov-cache-test-no_std-${{ github.sha }}
path: lcov-test-no_std-.info
key: codecov-cache-test-no_std--${{ github.sha }}
fail-on-cache-miss: true

- name: Fetch results for tests with stdlib (w/lambdaworks; part. 1)
uses: actions/cache/restore@v3
with:
path: lcov-test#1-lambdaworks-felt.info
key: codecov-cache-test#1-lambdaworks-felt-${{ github.sha }}
fail-on-cache-miss: true
- name: Fetch results for tests with stdlib (w/lambdaworks; part. 2)
uses: actions/cache/restore@v3
with:
path: lcov-test#2-lambdaworks-felt.info
key: codecov-cache-test#2-lambdaworks-felt-${{ github.sha }}
fail-on-cache-miss: true
- name: Fetch results for tests without stdlib (w/lambdaworks)
uses: actions/cache/restore@v3
with:
path: lcov-test-no_std-lambdaworks-felt.info
key: codecov-cache-test-no_std-lambdaworks-felt-${{ github.sha }}
fail-on-cache-miss: true

- name: Upload coverage to codecov.io
Expand Down
20 changes: 9 additions & 11 deletions .github/workflows/test_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jobs:
python-version: '3.9'
cache: 'pip'

- name: Install dependencies
run: bash install.sh

- name: Compile project
run: cargo check
# NOTE: we do it in one step because GitHub cleans the PATH between steps
- name: Install dependencies and compile project
run: |
source install.sh
make check

install_debian:
name: "Install on debian-11"
Expand Down Expand Up @@ -77,10 +77,8 @@ jobs:
key: ${{ runner.os }}-python-install-${{ github.sha }}
restore-keys: ${{ runner.os }}-python-install-

- name: Install dependencies
run: bash install.sh

- name: Compile project
# NOTE: we do it in one step because GitHub cleans the PATH between steps
- name: Install dependencies and compile project
run: |
. "$HOME/.cargo/env"
cargo check
source install.sh
make check
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#### Upcoming Changes

* feat: updated the old WASM example and moved it to [`examples/wasm-demo`](examples/wasm-demo/) [#1315](https://github.com/lambdaclass/cairo-vm/pull/1315)

* feat: add `arbitrary` feature to enable arbitrary derive in `Program` and `CairoRunConfig`

* feat(fuzzing): add `arbitrary` feature to enable arbitrary derive in `Program` and `CairoRunConfig` [#1306](https://github.com/lambdaclass/cairo-vm/pull/1306) [#1330](https://github.com/lambdaclass/cairo-vm/pull/1330)
Expand Down
Loading
Loading