Skip to content

Commit c4361e7

Browse files
authored
add makefile, fix foundry.toml and ci (#10)
* add makefile, fix foundry.toml and ci * Upgrade solc_version
1 parent 8e79168 commit c4361e7

File tree

4 files changed

+79
-7
lines changed

4 files changed

+79
-7
lines changed

.github/workflows/test.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
name: test
1+
name: EVM CI
22

3-
on: workflow_dispatch
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
49

510
env:
611
FOUNDRY_PROFILE: ci
@@ -10,7 +15,7 @@ jobs:
1015
strategy:
1116
fail-fast: true
1217

13-
name: Foundry project
18+
name: forge test
1419
runs-on: ubuntu-latest
1520
steps:
1621
- uses: actions/checkout@v4
@@ -24,11 +29,15 @@ jobs:
2429

2530
- name: Run Forge build
2631
run: |
27-
forge --version
28-
forge build --sizes
32+
make test-push0
2933
id: build
3034

3135
- name: Run Forge tests
3236
run: |
33-
forge test -vvv
37+
make test-evm
3438
id: test
39+
40+
- name: Run Forge fmt
41+
run: |
42+
make check-format
43+
id: check

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM ghcr.io/foundry-rs/foundry@sha256:8b843eb65cc7b155303b316f65d27173c862b37719dc095ef3a2ef27ce8d3c00 as builder
2+
3+
WORKDIR /app
4+
COPY foundry.toml foundry.toml
5+
COPY lib lib
6+
COPY src src
7+
8+
RUN FOUNDRY_PROFILE=prod forge build
9+
10+
FROM scratch AS foundry-export
11+
12+
COPY --from=builder /app/out .

Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
all: build
2+
3+
#######################
4+
## BUILD
5+
6+
.PHONY: build
7+
build:
8+
forge build
9+
10+
.PHONY: clean
11+
clean:
12+
forge clean
13+
14+
.PHONY: build-prod
15+
build-prod: clean
16+
docker build --target foundry-export -f Dockerfile -o out .
17+
18+
#######################
19+
## TESTS
20+
21+
.PHONY: check-format
22+
check-format:
23+
forge fmt --check
24+
25+
.PHONY: fix-format
26+
fix-format:
27+
forge fmt
28+
29+
.PHONY: test
30+
test:
31+
forge test -vvv
32+
33+
# Verify that the contracts do not include PUSH0 opcodes
34+
test-push0:
35+
forge build --extra-output evm.bytecode.opcodes
36+
@if grep -qr --include \*.json PUSH0 ./evm/out; then echo "Contract uses PUSH0 instruction" 1>&2; exit 1; else echo "PUSH0 Verification Succeeded"; fi

foundry.toml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
[profile.default]
2+
solc_version = "0.8.23"
3+
optimizer = true
4+
optimizer_runs = 200
5+
via_ir = false
6+
evm_version = "london"
27
src = "src"
38
out = "out"
49
libs = ["lib"]
10+
fs_permissions = [{ access = "read", path = "./test/payloads"}]
511

6-
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
12+
[profile.prod]
13+
via_ir = true
14+
fs_permissions = [{access = "read", path = "./cfg/"}]
15+
16+
[fmt]
17+
line_length = 100
18+
multiline_func_header = "params_first"
19+
# wrap_comments = true
20+
21+
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

0 commit comments

Comments
 (0)