Documentation
CI/CD Service

Deployment and Testing with Foundry

Learn how to deploy and test your Foundry project's contracts with BuildBear's CI/CD service.

Install the BuildBear Foundry Fork

Using Foundry with BuildBear's CI/CD service requires installing our fork of Foundry, which includes essential updates for:

  • Generating enhanced artifacts for test simulation
  • Enabling automatic contract verification
  • Improved integration with BuildBear's infrastructure

Install our Foundry fork instead of the standard version:

curl -L https://github.com/BuildBearLabs/foundry/releases/latest/download/foundry_nightly_linux_amd64.tar.gz | tar xzf - -C ~/.foundry/bin/

Cheatcode Support: BuildBear currently supports 45 Foundry cheat codes. You can see the entire list here.

Setup GitHub Actions

BuildBear's CI/CD system uses GitHub Actions. We encourage you to check out the official GitHub Actions documentation for more information. For the purposes of this quickstart, you'll only need to create a .github/workflows directory at the top-level of your repository. Workflows are YAML files that we'll put in this folder.

Workflow File

To get started with Foundry you can use this workflow:

name: Deploy to BuildBear Sandbox
 
on: [push]
 
jobs:
  test:
    runs-on: ubuntu-latest
 
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          submodules: recursive
 
      - name: Install BuildBear's Foundry Fork
        run: |
          curl -L https://raw.githubusercontent.com/BuildBearLabs/foundry/master/foundryup/install | bash
          foundryup
        shell: bash
 
      - name: Show Forge version
        run: forge --version
 
      - name: Run Forge Tests # Optional
        run: forge test -vvv
 
      - name: Run BB Action CI
        uses: BuildBearLabs/[email protected]
        with:
          network: |
            [
              {
                "chainId": 1,
                "blockNumber": 12000000 # Optional
              },
              {
                "chainId": 10
              }
            ]
          deploy-command: "make deploy"
          buildbear-token: "${{ secrets.BUILDBEAR_TOKEN }}"

A few things to notice about this portion of the workflow:

  • At the time of writing, v1.0.0 is the current version of the action, please check the BB CI Action GitHub repo for the latest version.
  • network is a list that can take multiple chain objects and their specified IDs, as well as an optional blockNumber.
  • For the deploy-command you can use either a script or a Foundry command directly.