|
| 1 | +name: Cannon Tests |
| 2 | + |
| 3 | +env: |
| 4 | + FOUNDRY_PROFILE: ci |
| 5 | + OP_E2E_CANNON_ENABLED: "false" |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [celestia-develop] |
| 10 | + pull_request: |
| 11 | + branches: [celestia-develop] |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + contracts-build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + # Debug step to check directory structure |
| 21 | + - name: Debug directory structure |
| 22 | + run: | |
| 23 | + echo "Current directory: $(pwd)" |
| 24 | + echo "Directory contents:" |
| 25 | + ls -la |
| 26 | + echo "Checking for packages directory:" |
| 27 | + ls -la packages || echo "No packages directory" |
| 28 | +
|
| 29 | + # Install just command |
| 30 | + - name: Install just |
| 31 | + run: | |
| 32 | + curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to "$HOME/.local/bin" |
| 33 | + echo "$HOME/.local/bin" >> "$GITHUB_PATH" |
| 34 | +
|
| 35 | + # Install Node.js without npm cache initially |
| 36 | + - name: Setup Node.js |
| 37 | + uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version: "18" |
| 40 | + |
| 41 | + - name: Install npm dependencies |
| 42 | + run: | |
| 43 | + if [ ! -d "packages/contracts-bedrock" ]; then |
| 44 | + echo "contracts-bedrock directory not found. Creating it..." |
| 45 | + mkdir -p packages/contracts-bedrock |
| 46 | + fi |
| 47 | + cd packages/contracts-bedrock |
| 48 | +
|
| 49 | + # Initialize package.json if it doesn't exist |
| 50 | + if [ ! -f "package.json" ]; then |
| 51 | + echo "Creating package.json..." |
| 52 | + echo '{ |
| 53 | + "name": "contracts-bedrock", |
| 54 | + "version": "1.0.0", |
| 55 | + "private": true, |
| 56 | + "description": "Optimism Bedrock smart contracts", |
| 57 | + "scripts": { |
| 58 | + "test": "echo \"Error: no test specified\" && exit 1" |
| 59 | + } |
| 60 | + }' > package.json |
| 61 | + fi |
| 62 | +
|
| 63 | + # List contents after setup |
| 64 | + echo "Directory contents after setup:" |
| 65 | + ls -la |
| 66 | +
|
| 67 | + npm install |
| 68 | +
|
| 69 | + - name: Install Foundry |
| 70 | + uses: foundry-rs/foundry-toolchain@v1 |
| 71 | + |
| 72 | + - name: Install contract dependencies |
| 73 | + working-directory: packages/contracts-bedrock |
| 74 | + run: just install |
| 75 | + |
| 76 | + - name: Pull artifacts |
| 77 | + working-directory: packages/contracts-bedrock |
| 78 | + run: bash scripts/ops/pull-artifacts.sh |
| 79 | + |
| 80 | + - name: Build contracts |
| 81 | + working-directory: packages/contracts-bedrock |
| 82 | + run: forge build --deny-warnings |
| 83 | + |
| 84 | + - name: Upload contract artifacts |
| 85 | + uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: contract-artifacts |
| 88 | + path: | |
| 89 | + packages/contracts-bedrock/artifacts |
| 90 | + packages/contracts-bedrock/forge-artifacts |
| 91 | + packages/contracts-bedrock/cache |
| 92 | +
|
| 93 | + cannon-prestate: |
| 94 | + needs: [contracts-build] |
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v4 |
| 98 | + |
| 99 | + - name: Create contract artifact directories |
| 100 | + run: | |
| 101 | + mkdir -p packages/contracts-bedrock/{artifacts,forge-artifacts,cache} |
| 102 | +
|
| 103 | + - name: Download contract artifacts |
| 104 | + uses: actions/download-artifact@v4 |
| 105 | + with: |
| 106 | + name: contract-artifacts |
| 107 | + path: packages/contracts-bedrock |
| 108 | + |
| 109 | + - name: Build cannon |
| 110 | + run: make cannon |
| 111 | + |
| 112 | + - name: Build op-program |
| 113 | + run: make op-program |
| 114 | + |
| 115 | + - name: Create prestate directories |
| 116 | + run: mkdir -p op-program/bin |
| 117 | + |
| 118 | + - name: Cache cannon prestate |
| 119 | + id: cache-prestate |
| 120 | + uses: actions/cache@v4 |
| 121 | + with: |
| 122 | + path: | |
| 123 | + op-program/bin/prestate.bin.gz |
| 124 | + op-program/bin/meta.json |
| 125 | + op-program/bin/prestate-proof.json |
| 126 | + key: cannon-prestate-${{ hashFiles('cannon/bin/cannon') }}-${{ hashFiles('op-program/bin/op-program-client.elf') }} |
| 127 | + |
| 128 | + - name: Sanitize op-program guest |
| 129 | + run: make -f cannon/Makefile sanitize-program GUEST_PROGRAM=op-program/bin/op-program-client.elf |
| 130 | + |
| 131 | + - name: Generate cannon prestate |
| 132 | + if: steps.cache-prestate.outputs.cache-hit != 'true' |
| 133 | + run: make cannon-prestate |
| 134 | + |
| 135 | + - name: Generate cannon-mt prestate |
| 136 | + run: make cannon-prestate-mt |
| 137 | + |
| 138 | + - name: Upload prestate artifacts |
| 139 | + uses: actions/upload-artifact@v4 |
| 140 | + with: |
| 141 | + name: prestate-artifacts |
| 142 | + path: | |
| 143 | + op-program/bin/prestate.bin.gz |
| 144 | + op-program/bin/meta.json |
| 145 | + op-program/bin/prestate-proof.json |
| 146 | +
|
| 147 | + cannon-go-test: |
| 148 | + needs: [contracts-build] |
| 149 | + runs-on: ubuntu-latest |
| 150 | + steps: |
| 151 | + - uses: actions/checkout@v4 |
| 152 | + |
| 153 | + - name: Create contract artifact directories |
| 154 | + run: | |
| 155 | + mkdir -p packages/contracts-bedrock/{artifacts,forge-artifacts,cache} |
| 156 | +
|
| 157 | + - name: Download contract artifacts |
| 158 | + uses: actions/download-artifact@v4 |
| 159 | + with: |
| 160 | + name: contract-artifacts |
| 161 | + path: packages/contracts-bedrock |
| 162 | + |
| 163 | + - name: Set up Go |
| 164 | + uses: actions/setup-go@v5 |
| 165 | + with: |
| 166 | + go-version: "1.21" |
| 167 | + |
| 168 | + - name: Build example binaries |
| 169 | + working-directory: cannon/testdata/example |
| 170 | + run: make elf |
| 171 | + |
| 172 | + - name: Run Go lint |
| 173 | + working-directory: cannon |
| 174 | + run: make lint |
| 175 | + |
| 176 | + - name: Create test results directory |
| 177 | + run: | |
| 178 | + mkdir -p tmp/test-results |
| 179 | + mkdir -p tmp/testlogs |
| 180 | +
|
| 181 | + - name: Run tests |
| 182 | + working-directory: cannon |
| 183 | + run: | |
| 184 | + go install gotest.tools/gotestsum@latest |
| 185 | + gotestsum --format=testname --junitfile=../tmp/test-results/cannon.xml --jsonfile=../tmp/testlogs/log.json \ |
| 186 | + -- -parallel="$(nproc)" -coverpkg=github.com/ethereum-optimism/optimism/cannon/... -coverprofile=coverage.out ./... |
| 187 | +
|
| 188 | + - name: Upload coverage |
| 189 | + uses: codecov/codecov-action@v4 |
| 190 | + with: |
| 191 | + files: ./cannon/coverage.out |
| 192 | + flags: cannon-go-tests |
| 193 | + |
| 194 | + - name: Upload test results |
| 195 | + uses: actions/upload-artifact@v4 |
| 196 | + with: |
| 197 | + name: test-results |
| 198 | + path: | |
| 199 | + tmp/test-results |
| 200 | + tmp/testlogs |
| 201 | +
|
| 202 | + # op-e2e-cannon-tests: |
| 203 | + # needs: [contracts-build, cannon-prestate] |
| 204 | + # runs-on: ubuntu-latest |
| 205 | + # steps: |
| 206 | + # - uses: actions/checkout@v4 |
| 207 | + |
| 208 | + # - name: Install Foundry |
| 209 | + # uses: foundry-rs/foundry-toolchain@v1 |
| 210 | + |
| 211 | + # - name: Create directories |
| 212 | + # run: | |
| 213 | + # mkdir -p packages/contracts-bedrock/{artifacts,forge-artifacts,cache} |
| 214 | + # mkdir -p op-program/bin |
| 215 | + |
| 216 | + # - name: Download contract artifacts |
| 217 | + # uses: actions/download-artifact@v4 |
| 218 | + # with: |
| 219 | + # name: contract-artifacts |
| 220 | + # path: packages/contracts-bedrock |
| 221 | + |
| 222 | + # - name: Download prestate artifacts |
| 223 | + # uses: actions/download-artifact@v4 |
| 224 | + # with: |
| 225 | + # name: prestate-artifacts |
| 226 | + # path: op-program/bin |
| 227 | + |
| 228 | + # # Add Go installation since op-e2e tests are in Go |
| 229 | + # - name: Set up Go |
| 230 | + # uses: actions/setup-go@v5 |
| 231 | + # with: |
| 232 | + # go-version: "1.21" |
| 233 | + |
| 234 | + # # Install any required Go dependencies |
| 235 | + # - name: Install Go dependencies |
| 236 | + # run: | |
| 237 | + # go mod download |
| 238 | + |
| 239 | + # # Debug step to verify forge installation and environment |
| 240 | + # - name: Debug environment |
| 241 | + # run: | |
| 242 | + # echo "Foundry version:" |
| 243 | + # forge --version |
| 244 | + # echo "Go version:" |
| 245 | + # go version |
| 246 | + # echo "Directory structure:" |
| 247 | + # ls -R packages/contracts-bedrock/ |
| 248 | + # ls -R op-program/bin/ |
| 249 | + |
| 250 | + # - name: Run cannon tests |
| 251 | + # working-directory: op-e2e |
| 252 | + # run: | |
| 253 | + # make test-cannon |
0 commit comments