Documentation

CI/CD Workflow for Web3 with BuildBear

Guide to set up CI/CD using the BuildBear GitHub App to build, deploy, verify, and test smart contracts in isolated sandbox environments.

Overview

BuildBear's CI/CD Service automates the creation of sandbox environments and plugin installations, enabling you to test and deploy contracts either on a schedule or whenever you trigger a GitHub Action workflow.

Key benefits:

  • GitHub Actions Integration: Use familiar GitHub Actions workflows without learning new configurations
  • Foundry Support: Full compatibility with Foundry projects including 45 cheatcodes
  • Enhanced Debugging: Access the BuildBear dashboard directly from GitHub logs for quick analysis

Tutorial Scope

This tutorial guides you through:

  1. Cloning a modified Uniswap V4 Core repository
  2. Setting up BuildBear's CI/CD workflow
  3. Automating contract building, deployment, verification, and testing in isolated sandboxes
  4. Gaining full observability into contract interactions via transaction hashes

Prerequisites

We'll use a modified version of Uniswap V4 Core available at:
https://github.com/JustUzair/bb-ci-cd-v4-core

You can also use any other foundry contracts repository instead of the Uniswap V4: Checkout how to set it up below.

This modified version of the repository contains an additional deploy script to deploy some core contracts

You can either:

  • Fork the repository to make changes
  • Clone it directly to your local machine

This feature is currently in Beta Access. Contact us at [email protected] to request access.

Installation and Setup

Step 1: Install the BuildBear GitHub App

  1. Navigate to the CI/CD Dashboard using the sidebar link CI/CD Dashboard
  2. Click "Install App"
  3. Select repositories to grant access (all or specific ones) GitHub App Installation
  4. Confirm installation GitHub App Installation Successful

Step 2: Configure Repository Access

  1. From the CI/CD Dashboard, select your repository Select Repository
  2. Click "Add Project"

After adding the repository, copy the displayed API key and add it to your GitHub Repository Secrets as BUILDBEAR_API_KEY or any other variable name.

Github Repo Secrets

Step 3: Verify Setup

Your repository now appears in the CI/CD Dashboard. The initial view will be empty until you set up workflows.

Repository Added Repository Added Expanded

Workflow Configuration

File Structure

The Uniswap V4 Core repository includes a buildbear.yml file in .github/workflows. If missing, create it manually with this content:

name: V4-Core-Workflow
 
on: [push]
 
# Workflow
 
jobs:
  test:
    runs-on: ubuntu-latest
 
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          submodules: recursive
 
      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
 
      # Cache Foundry repository
      - name: Cache Foundry repository
        uses: actions/cache@v3
        with:
          path: foundry
          key: ${{ runner.os }}-foundry-${{ hashFiles('**/foundry/.gitmodules') }}
          restore-keys: |
            ${{ runner.os }}-foundry-
 
      # Cache build artifacts
      - name: Cache build artifacts
        uses: actions/cache@v3
        with:
          path: $HOME/.config/.foundry/bin
          key: ${{ runner.os }}-forge-${{ hashFiles('foundry/Cargo.toml') }}
          restore-keys: |
            ${{ runner.os }}-forge-
 
      - name: Clone Foundry repository
        run: |
          if [ ! -d "foundry" ]; then
            git clone https://github.com/BuildBearLabs/foundry.git
          fi
        shell: bash
 
      - name: Build Foundry from source
        run: |
          cd foundry
          cargo build
          mkdir -p $HOME/.config/.foundry/bin
          cp target/debug/forge $HOME/.config/.foundry/bin/
          echo "PATH=$HOME/.config/.foundry/bin:$PATH" >> $GITHUB_ENV
        shell: bash
 
      - name: Show Forge version
        run: forge --version
 
      - name: Make bbOut dir
        run: mkdir bbOut
        shell: bash
 
      - name: Run BB Action Test
        run: forge test
 
      - name: test_ci
        uses: BuildBearLabs/[email protected]
        with:
          network: |
            [
              {
                "chainId": 1
              }
            ]
 
          deploy-command: "make exe"
          buildbear-api-key: "${{secrets.CICD_BUILDBEAR_TOKEN}}"
        env:
          BUILDBEAR_BASE_URL: "https://api.buildbear.io"

Workflow Explanation

This configuration:

  • Checkout the repository code.
  • Install Rust toolchain.
  • Cache the Foundry repository and build artifacts.
  • Clone the Foundry repository if it doesn't exist.
  • Build Foundry from source and set the PATH.
  • Show the Forge version.
  • Create a directory for BuildBear output.
  • Run the BuildBear action to test the CI/CD workflow.

Please note that some of the steps are mandatory for the BuildBear CI/CD workflow to function correctly, such as caching the Foundry repository and build artifacts, and running the BuildBear action. This is where you can add your custom jobs & related steps, to deploy contracts, verify them on-chain, running tests in the sandbox, etc.

      - name: test_ci
        uses: BuildBearLabs/[email protected]
        with:
          network: |
            [
              {
                "chainId": 1
              }
            ]
 
          deploy-command: "make exe"
          buildbear-api-key: "${{secrets.CICD_BUILDBEAR_TOKEN}}"
        env:
          BUILDBEAR_BASE_URL: "https://api.buildbear.io"

Monitoring Workflow Execution

After pushing changes:

  1. View progress in GitHub's Actions tab GitHub Actions Workflow Workflow Details
  2. Monitor individual jobs like the test job Test Job

BuildBear Dashboard Results

The CI/CD dashboard displays comprehensive results after workflow completion: Deployment Results

Key metrics from the sample run:

  • Total Tests: 440
  • Passed: 155
  • Errored: 285
  • Failed: 0
  • Skipped: 0
  • Deployment Status: Success
  • Test Status: Errored

On the CI/CD Dashboard, you’ll see total tests run, passed, errored, failed, and skipped. Scrolling down reveals individual test cases (NodeId, transaction hash, and revert message), helping you pinpoint exactly which assertion or hook failed and why.
dashboard Tests

Each deployment entry corresponds to one sandbox run. You can expand any card to see the chain ID, RPC endpoint, and a list of every contract deployed, along with its on‐chain address and clickable transaction hash, so you can jump straight to block explorers or debug logs. dashboard deployments

Conclusion

In this tutorial, you set up BuildBear’s CI/CD integration to automatically build, deploy, and test your smart contracts in isolated sandbox environments using GitHub Actions. You learned how to:

  • Install and configure the BuildBear GitHub App
  • Add your repository to the CI/CD dashboard and manage API keys
  • Write a buildbear.yml workflow that checks out code, installs dependencies, caches Foundry, and runs your tests inside a sandbox
  • Trigger workflows on push and monitor execution in both GitHub Actions and the BuildBear dashboard
  • Inspect detailed deployment logs and test results with clickable transaction hashes and revert messages

With BuildBear CI/CD, you get end-to-end reproducibility, instant sandbox provisioning, and rich on-chain observability.