Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 253 additions & 0 deletions .github/workflows/cannon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
name: Cannon Tests

env:
FOUNDRY_PROFILE: ci
OP_E2E_CANNON_ENABLED: "false"

on:
push:
branches: [celestia-develop]
pull_request:
branches: [celestia-develop]
workflow_dispatch:

jobs:
contracts-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Debug step to check directory structure
- name: Debug directory structure
run: |
echo "Current directory: $(pwd)"
echo "Directory contents:"
ls -la
echo "Checking for packages directory:"
ls -la packages || echo "No packages directory"

# Install just command
- name: Install just
run: |
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to "$HOME/.local/bin"
echo "$HOME/.local/bin" >> "$GITHUB_PATH"

# Install Node.js without npm cache initially
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"

- name: Install npm dependencies
run: |
if [ ! -d "packages/contracts-bedrock" ]; then
echo "contracts-bedrock directory not found. Creating it..."
mkdir -p packages/contracts-bedrock
fi
cd packages/contracts-bedrock

# Initialize package.json if it doesn't exist
if [ ! -f "package.json" ]; then
echo "Creating package.json..."
echo '{
"name": "contracts-bedrock",
"version": "1.0.0",
"private": true,
"description": "Optimism Bedrock smart contracts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}' > package.json
fi

# List contents after setup
echo "Directory contents after setup:"
ls -la

npm install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install contract dependencies
working-directory: packages/contracts-bedrock
run: just install

- name: Pull artifacts
working-directory: packages/contracts-bedrock
run: bash scripts/ops/pull-artifacts.sh

- name: Build contracts
working-directory: packages/contracts-bedrock
run: forge build --deny-warnings

- name: Upload contract artifacts
uses: actions/upload-artifact@v4
with:
name: contract-artifacts
path: |
packages/contracts-bedrock/artifacts
packages/contracts-bedrock/forge-artifacts
packages/contracts-bedrock/cache

cannon-prestate:
needs: [contracts-build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Create contract artifact directories
run: |
mkdir -p packages/contracts-bedrock/{artifacts,forge-artifacts,cache}

- name: Download contract artifacts
uses: actions/download-artifact@v4
with:
name: contract-artifacts
path: packages/contracts-bedrock

- name: Build cannon
run: make cannon

- name: Build op-program
run: make op-program

- name: Create prestate directories
run: mkdir -p op-program/bin

- name: Cache cannon prestate
id: cache-prestate
uses: actions/cache@v4
with:
path: |
op-program/bin/prestate.bin.gz
op-program/bin/meta.json
op-program/bin/prestate-proof.json
key: cannon-prestate-${{ hashFiles('cannon/bin/cannon') }}-${{ hashFiles('op-program/bin/op-program-client.elf') }}

- name: Sanitize op-program guest
run: make -f cannon/Makefile sanitize-program GUEST_PROGRAM=op-program/bin/op-program-client.elf

- name: Generate cannon prestate
if: steps.cache-prestate.outputs.cache-hit != 'true'
run: make cannon-prestate

- name: Generate cannon-mt prestate
run: make cannon-prestate-mt

- name: Upload prestate artifacts
uses: actions/upload-artifact@v4
with:
name: prestate-artifacts
path: |
op-program/bin/prestate.bin.gz
op-program/bin/meta.json
op-program/bin/prestate-proof.json

cannon-go-test:
needs: [contracts-build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Create contract artifact directories
run: |
mkdir -p packages/contracts-bedrock/{artifacts,forge-artifacts,cache}

- name: Download contract artifacts
uses: actions/download-artifact@v4
with:
name: contract-artifacts
path: packages/contracts-bedrock

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"

- name: Build example binaries
working-directory: cannon/testdata/example
run: make elf

- name: Run Go lint
working-directory: cannon
run: make lint

- name: Create test results directory
run: |
mkdir -p tmp/test-results
mkdir -p tmp/testlogs

- name: Run tests
working-directory: cannon
run: |
go install gotest.tools/gotestsum@latest
gotestsum --format=testname --junitfile=../tmp/test-results/cannon.xml --jsonfile=../tmp/testlogs/log.json \
-- -parallel="$(nproc)" -coverpkg=github.com/ethereum-optimism/optimism/cannon/... -coverprofile=coverage.out ./...

- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: ./cannon/coverage.out
flags: cannon-go-tests

- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
tmp/test-results
tmp/testlogs

# op-e2e-cannon-tests:
# needs: [contracts-build, cannon-prestate]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4

# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1

# - name: Create directories
# run: |
# mkdir -p packages/contracts-bedrock/{artifacts,forge-artifacts,cache}
# mkdir -p op-program/bin

# - name: Download contract artifacts
# uses: actions/download-artifact@v4
# with:
# name: contract-artifacts
# path: packages/contracts-bedrock

# - name: Download prestate artifacts
# uses: actions/download-artifact@v4
# with:
# name: prestate-artifacts
# path: op-program/bin

# # Add Go installation since op-e2e tests are in Go
# - name: Set up Go
# uses: actions/setup-go@v5
# with:
# go-version: "1.21"

# # Install any required Go dependencies
# - name: Install Go dependencies
# run: |
# go mod download

# # Debug step to verify forge installation and environment
# - name: Debug environment
# run: |
# echo "Foundry version:"
# forge --version
# echo "Go version:"
# go version
# echo "Directory structure:"
# ls -R packages/contracts-bedrock/
# ls -R op-program/bin/

# - name: Run cannon tests
# working-directory: op-e2e
# run: |
# make test-cannon
106 changes: 106 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: CI

env:
FOUNDRY_PROFILE: ci
DOCKER_BUILDKIT: 1
REGISTRY: ghcr.io
REPO: ${{ github.repository_owner }}

on:
push:
branches:
- celestia-develop
- test/github-actions
pull_request:
branches:
- celestia-develop
types: [opened, synchronize, reopened]
workflow_dispatch:

jobs:
docker-build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
docker_name:
- op-node
- op-batcher
- op-program
- op-proposer
- op-challenger
- proofs-tools
- op-dispute-mon
- op-conductor
- da-server
- op-supervisor
- cannon
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate clean branch name
id: clean_branch
run: |
# Replace invalid characters with dash
CLEAN_BRANCH="$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9.]/-/g')"
echo "name=${CLEAN_BRANCH}" >> "$GITHUB_OUTPUT"

- name: Set build environment
run: |
{
echo "REGISTRY=${{ env.REGISTRY }}"
echo "REPOSITORY=${{ env.REPO }}"
echo "GIT_COMMIT=$(git rev-parse HEAD)"
echo "GIT_DATE=$(git show -s --format='%ct')"
echo "GIT_VERSION=untagged"
echo "IMAGE_TAGS=${{ github.sha }},${{ steps.clean_branch.outputs.name }}"
echo "PLATFORMS=linux/amd64"
} >> "$GITHUB_ENV"

- name: Build Docker image
run: |
# Create buildx builder
docker buildx create --driver=docker-container --name=buildx-build --bootstrap --use

# For PRs, use --load to make the image available locally
# For pushes, use --push to publish to registry
OUTPUT_ARG=""
if [ "${{ github.event_name }}" = "pull_request" ]; then
OUTPUT_ARG="--load"
else
OUTPUT_ARG="--push"
fi

# Build using docker-bake.hcl
docker buildx bake \
--progress plain \
--builder=buildx-build \
-f docker-bake.hcl \
"${OUTPUT_ARG}" \
"${{ matrix.docker_name }}"

- name: Save Docker image
if: github.event_name == 'pull_request'
run: |
CLEAN_TAG="${{ steps.clean_branch.outputs.name }}"
IMAGE_NAME="${{ env.REGISTRY }}/${{ env.REPO }}/${{ matrix.docker_name }}:${CLEAN_TAG}"
docker save "${IMAGE_NAME}" > "/tmp/${{ matrix.docker_name }}.tar"

- name: Upload Docker image
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: docker-${{ matrix.docker_name }}
path: /tmp/${{ matrix.docker_name }}.tar
Loading
Loading