Skip to content

Commit

Permalink
⬆️ starknet-foundry 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelStark committed Sep 12, 2023
1 parent 8a22811 commit d6b9eed
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 61 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Za Warudo Book
name: Satoru Book

on:
push:
branches:
- main
pull_request:

jobs:
book:
Expand All @@ -14,17 +13,31 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Check for changes in the book directory
id: check_changes
run: |
if git diff --quiet --exit-code HEAD^ HEAD -- book; then
echo "No changes in the 'book' directory. Exiting..."
exit 0
else
echo "Changes detected in the book directory. Continuing..."
fi
continue-on-error: true

- name: Setup mdBook
if: steps.check_changes.outcome == 'success'
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: "latest"

- run: mdbook build
- name: Build mdBook
if: steps.check_changes.outcome == 'success'
run: mdbook build
working-directory: ./book

- name: Deploy
if: ${{ github.ref == 'refs/heads/main' }} && steps.check_changes.outcome == 'success'
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/book
29 changes: 8 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
on:
pull_request:
branches:
- main
push:
branches:
- main
name: Build

on: [push, pull_request]

env:
SCARB_VERSION: 0.6.1+nightly-2023-08-16
SCARB_VERSION: 0.7.0

# For the moment we will use nightly versions of scarb to be able to use latest features of Cairo.
# The installation process will be a bit different than when using non nightly versions.
# Once Cairo and Scarb will be stable, we will use the stable versions and the `software-mansion/setup-scarb` action.
name: Build
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Scarb
#uses: software-mansion/setup-scarb@v1
# Install Scarb from a nightly release
run: |
NIGHTLY_DATE=$(echo ${SCARB_VERSION} | cut -d '+' -f 2)
wget https://github.com/software-mansion/scarb-nightlies/releases/download/${NIGHTLY_DATE}/scarb-${NIGHTLY_DATE}-x86_64-unknown-linux-gnu.tar.gz
tar -xvf scarb-${NIGHTLY_DATE}-x86_64-unknown-linux-gnu.tar.gz
sudo mv scarb-v${SCARB_VERSION}-x86_64-unknown-linux-gnu/bin/scarb /usr/local/bin
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "0.7.0"
- name: Check cairo format
run: scarb fmt --check
- name: Build cairo programs
Expand Down
44 changes: 35 additions & 9 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
on:
pull_request:
branches:
- main
push:
branches:
- main

name: Security

on: [push, pull_request]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "0.7.0"

- name: Install Semgrep
run: |
pip install semgrep
Expand All @@ -21,4 +20,31 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: semgrep-cairo
path: semgrep-output.txt
path: semgrep-output.txt

- name: Build cairo programs
run: scarb build

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

- name: Check if Caracal is installed
id: check-caracal
run: |
if ! command -v caracal &> /dev/null; then
echo "Caracal is not installed. Installing..."
cargo install --git https://github.com/crytic/caracal --profile release --force
else
echo "Caracal is already installed."
fi
- name: Run Caracal
run: caracal detect . > caracal-output.txt
- name: Save Caracal Output as an Artifact
uses: actions/upload-artifact@v3
with:
name: caracal-cairo
path: caracal-output.txt
27 changes: 9 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
on:
pull_request:
branches:
- main
push:
branches:
- main
name: Test

on: [push, pull_request]

env:
SCARB_VERSION: 0.6.1+nightly-2023-08-16
STARKNET_FOUNDRY_VERSION: 0.3.0
SCARB_VERSION: 0.7.0
STARKNET_FOUNDRY_VERSION: 0.5.0

name: Test
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Scarb
#ses: software-mansion/setup-scarb@v1
# Install Scarb from a nightly release
run: |
NIGHTLY_DATE=$(echo ${SCARB_VERSION} | cut -d '+' -f 2)
wget https://github.com/software-mansion/scarb-nightlies/releases/download/${NIGHTLY_DATE}/scarb-${NIGHTLY_DATE}-x86_64-unknown-linux-gnu.tar.gz
tar -xvf scarb-${NIGHTLY_DATE}-x86_64-unknown-linux-gnu.tar.gz
sudo mv scarb-v${SCARB_VERSION}-x86_64-unknown-linux-gnu/bin/scarb /usr/local/bin
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "0.7.0"
- name: Install starknet foundry
run: curl -L https://raw.githubusercontent.com/foundry-rs/starknet-foundry/master/scripts/install.sh | sh -s -- -v ${STARKNET_FOUNDRY_VERSION}
- name: Run cairo tests
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scarb 0.6.2
scarb 0.7.0
2 changes: 2 additions & 0 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ sierra-replace-ids = true

[dependencies]
starknet = ">=2.1.0"
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.5.0" }


[tool.snforge]
exit_first = false
15 changes: 7 additions & 8 deletions tests/test_lockup_linear.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ use starknet::{
ClassHash,
};
use debug::PrintTrait;
use cheatcodes::PreparedContract;

// Starknet Foundry imports.
use snforge_std::{declare, start_prank, stop_prank, ContractClassTrait};


// Local imports.
use za_warudo::core::lockup_linear::{
Expand Down Expand Up @@ -108,12 +111,8 @@ fn setup_contracts(caller_address: ContractAddress) -> (IZaWarudoLockupLinearSaf

/// Utility function to deploy a `ZaWarudoLockupLinear` contract and return its address.
fn deploy_za_warudo(initial_admin: ContractAddress) -> ContractAddress {
let class_hash = declare('ZaWarudoLockupLinear');
let mut constructor_calldata = array![];
constructor_calldata.append(initial_admin.into());
let prepared = PreparedContract {
class_hash: class_hash, constructor_calldata: @constructor_calldata
};
deploy(prepared).unwrap()
let za_warudo_contract = declare('ZaWarudoLockupLinear');
let mut constructor_calldata = array![initial_admin.into()];
za_warudo_contract.deploy(@constructor_calldata).unwrap()
}

0 comments on commit d6b9eed

Please sign in to comment.