Skip to content

Commit

Permalink
Improve CI/CD with lint, build, test steps
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSparksCode committed Nov 14, 2023
1 parent 335e548 commit be0974b
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 40 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: CI

env:
FOUNDRY_PROFILE: "ci"

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

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

- name: Check formatting
run: forge fmt --check

- name: "Add lint summary"
run: |
echo "## Lint result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

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

- name: Install dependencies
run: forge install

- name: Compile contracts
run: forge build

- name: Check contract sizes
run: |
forge build --sizes && \
for file in out/*.sol/*.json; do
if [[ "$file" == *".t.sol"* || "$file" == *".s.sol"* ]]; then
continue
fi
size=$(cat "$file" | jq '.deployedBytecode.object' | wc -c | awk '{print int(($1-2)/2)}')
if [ $size -gt 24576 ]; then
echo "Contract in $file exceeds max size of 24576 bytes (Size: $size bytes)"
exit 1
fi
done
- name: "Add build summary"
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
tests:
needs: ["lint", "build"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

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

- name: Install dependencies
run: forge install

- name: Compile contracts
run: forge build

- name: Run tests
run: forge test

- name: Add test summary
run: |
echo "## Tests result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
32 changes: 0 additions & 32 deletions .github/workflows/tests.yml

This file was deleted.

20 changes: 12 additions & 8 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
[profile.default]
bytecode_hash = "none"
optimizer_runs = 20
timeout = 30000
block_gas_limit = 300000000
gas_limit = 3000000000
gas_price = 1500000000
bytecode_hash = "none"
optimizer_runs = 20
timeout = 30000
block_gas_limit = 300000000
gas_limit = 3000000000
gas_price = 1500000000

solc_version = "0.8.21"
evm_version = 'paris'
solc_version = "0.8.21"
evm_version = 'paris'

[profile.ci]
fuzz = { runs = 10_000 }
verbosity = 4

fs_permissions = [{ access = "read-write", path = "./"}]

0 comments on commit be0974b

Please sign in to comment.