Skip to content

Commit

Permalink
add makefile, fix foundry.toml and ci (#10)
Browse files Browse the repository at this point in the history
* add makefile, fix foundry.toml and ci

* Upgrade solc_version
  • Loading branch information
nik-suri authored May 29, 2024
1 parent 8e79168 commit c4361e7
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 7 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: test
name: EVM CI

on: workflow_dispatch
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

env:
FOUNDRY_PROFILE: ci
Expand All @@ -10,7 +15,7 @@ jobs:
strategy:
fail-fast: true

name: Foundry project
name: forge test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -24,11 +29,15 @@ jobs:

- name: Run Forge build
run: |
forge --version
forge build --sizes
make test-push0
id: build

- name: Run Forge tests
run: |
forge test -vvv
make test-evm
id: test

- name: Run Forge fmt
run: |
make check-format
id: check
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ghcr.io/foundry-rs/foundry@sha256:8b843eb65cc7b155303b316f65d27173c862b37719dc095ef3a2ef27ce8d3c00 as builder

WORKDIR /app
COPY foundry.toml foundry.toml
COPY lib lib
COPY src src

RUN FOUNDRY_PROFILE=prod forge build

FROM scratch AS foundry-export

COPY --from=builder /app/out .
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
all: build

#######################
## BUILD

.PHONY: build
build:
forge build

.PHONY: clean
clean:
forge clean

.PHONY: build-prod
build-prod: clean
docker build --target foundry-export -f Dockerfile -o out .

#######################
## TESTS

.PHONY: check-format
check-format:
forge fmt --check

.PHONY: fix-format
fix-format:
forge fmt

.PHONY: test
test:
forge test -vvv

# Verify that the contracts do not include PUSH0 opcodes
test-push0:
forge build --extra-output evm.bytecode.opcodes
@if grep -qr --include \*.json PUSH0 ./evm/out; then echo "Contract uses PUSH0 instruction" 1>&2; exit 1; else echo "PUSH0 Verification Succeeded"; fi
17 changes: 16 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
[profile.default]
solc_version = "0.8.23"
optimizer = true
optimizer_runs = 200
via_ir = false
evm_version = "london"
src = "src"
out = "out"
libs = ["lib"]
fs_permissions = [{ access = "read", path = "./test/payloads"}]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
[profile.prod]
via_ir = true
fs_permissions = [{access = "read", path = "./cfg/"}]

[fmt]
line_length = 100
multiline_func_header = "params_first"
# wrap_comments = true

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

0 comments on commit c4361e7

Please sign in to comment.