Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Starknet Foundry Github Action

If you wish to use Starknet Foundry in your Github Actions workflow, you can use the setup-snfoundry action. This action installs the necessary snforge and sncast binaries.

📝 Note At this moment, only Linux and MacOS are supported.

Example workflow

Make sure you pass the valid path to Scarb.lock to setup-scarb action. This way, all dependencies including snforge_scarb_plugin will be cached between runs.

name: My workflow
on:
  push:
  pull_request:
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Starknet Foundry
        uses: foundry-rs/setup-snfoundry@v3

      - name: Setup Scarb
        uses: software-mansion/setup-scarb@v1
        with:
          scarb-lock: ./hello_starknet/Scarb.lock

      - name: Run tests
        run: cd hello_starknet && snforge test

Workflow With Partitioned Tests

If you have a large number of tests, you can speed up your CI by partitioning tests and running them in parallel jobs. Here's an example workflow that demonstrates how to achieve this:

name: My workflow

on:
  push:
  pull_request:

jobs:
  check:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        partition: [ 1, 2, 3, 4 ]
    steps:
      - uses: actions/checkout@v4

      - name: Setup Starknet Foundry
        uses: foundry-rs/setup-snfoundry@v3

      - name: Setup Scarb
        uses: software-mansion/setup-scarb@v1
        with:
          scarb-lock: ./hello_starknet/Scarb.lock

      - name: Run tests
        run: |
          cd hello_starknet
          snforge test --partition '${{ matrix.partition }}/4'

Read more about tests partitioning here.