Skip to content

Commit

Permalink
Add scheduled workflow to test against different Scarb versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ddoktorski committed Nov 12, 2024
1 parent 13ad8b7 commit 9b60196
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Scheduled

on:
pull_request:
paths:
- scripts/get_scarb_versions.sh
- .github/workflows/scheduled.yml
schedule:
- cron: '0 0 * * 3,6'

jobs:
get-scarb-versions:
name: Get Scarb versions
outputs:
versions: ${{ steps.get_versions.outputs.versions }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
with:
tool_versions: |
scarb latest
- name: Get versions
id: get_versions
run: |
scarb_versions=$(./scripts/get_scarb_versions.sh)
echo ${scarb_versions[@]}
echo "versions=[${scarb_versions[@]}]" >> "$GITHUB_OUTPUT"
test-forge-unit-and-integration:
runs-on: ubuntu-latest
needs: get-scarb-versions
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.get-scarb-versions.outputs.versions) }}

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: ${{ matrix.version }}
- uses: software-mansion/setup-universal-sierra-compiler@v1
- name: Install cairo-profiler
run: |
curl -L https://raw.githubusercontent.com/software-mansion/cairo-profiler/main/scripts/install.sh | sh
- run: cargo test --release --lib -p forge
- run: cargo test --release -p forge integration

test-forge-e2e:
runs-on: ubuntu-latest
needs: get-scarb-versions
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.get-scarb-versions.outputs.versions) }}

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: ${{ matrix.version }}
- uses: software-mansion/setup-universal-sierra-compiler@v1
- name: Install cairo-profiler
run: |
curl -L https://raw.githubusercontent.com/software-mansion/cairo-profiler/main/scripts/install.sh | sh
- uses: taiki-e/install-action@nextest

- run: cargo test --release -p forge e2e

test-cast:
runs-on: ubuntu-latest
needs: get-scarb-versions
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.get-scarb-versions.outputs.versions) }}

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: ${{ matrix.version }}
- uses: software-mansion/setup-universal-sierra-compiler@v1

- name: Install starknet-devnet-rs
run: ./scripts/install_devnet.sh

- run: cargo test --release -p sncast
29 changes: 29 additions & 0 deletions scripts/get_scarb_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
set -e

# This script is used to find the following Scarb versions:
# The current major.minor version along with all its patch versions
# The latest patch versions for the two versions preceding the current one

function get_all_patch_versions() {
# Omit version 2.8.0 as it has a bug when using the `assert_macros` package
asdf list all scarb $1 | grep -v "rc" | grep -v "2.8.0"
}

function get_latest_patch_version() {
get_all_patch_versions $1 | sort -u | tail -1
}

major_minor_versions=($(get_all_patch_versions | cut -d . -f 1,2 | sort -u | tail -3))

scarb_versions=()

if [[ ${major_minor_versions[0]} != "2.6" ]]; then
scarb_versions+=($(get_latest_patch_version ${major_minor_versions[0]}))
fi

scarb_versions+=($(get_latest_patch_version ${major_minor_versions[1]}))

scarb_versions+=($(get_all_patch_versions ${major_minor_versions[2]}))

echo \"$(echo ${scarb_versions[@]} | sed 's/ /", "/g')\"

0 comments on commit 9b60196

Please sign in to comment.