Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make ci βœ… with πŸ’š and πŸ₯‘s #371

Merged
merged 20 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
170 changes: 0 additions & 170 deletions .github/workflows/ci.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/echidna.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "Echidna"

env:
FOUNDRY_PROFILE: "ci"

on:
workflow_dispatch:
pull_request:
branches:
bowd marked this conversation as resolved.
Show resolved Hide resolved
- "main"
- "feature/**"
- "feat/**"
- "develop"
push:
branches:
- "main"
- "develop"

jobs:
get_echidna_test_names:
name: Get Echidna test names
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Generate matrix with all test names from the test/echidna directory
id: set-matrix
run: |
echo "::set-output name=matrix::$(ls test/echidna | sed 's/.sol//' | jq -R -s -c 'split("\n")[:-1]')"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

run_echidna_tests:
needs: get_echidna_test_names
name: Run echidna tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
contract: ${{ fromJson(needs.get_echidna_test_names.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: "nightly-d369d2486f85576eec4ca41d277391dfdae21ba7"
bowd marked this conversation as resolved.
Show resolved Hide resolved
- name: "Build for echidna"
run: yarn forge:build:slither

- name: "Run Echidna"
uses: crytic/echidna-action@v2
with:
files: .
solc-version: 0.5.17
contract: ${{ matrix.contract }}
config: echidna.yaml
test-mode: assertion
64 changes: 64 additions & 0 deletions .github/workflows/lint_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "CI"

env:
FOUNDRY_PROFILE: "ci"

on:
workflow_dispatch:
pull_request:
branches:
- "main"
- "feature/**"
- "feat/**"
- "develop"
push:
branches:
- "main"
- "develop"

jobs:
lint_and_test:
name: Lint & Test
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
with:
submodules: "recursive"

- name: "Install Foundry"
uses: "onbjerg/foundry-toolchain@v1"
with:
version: "nightly-d369d2486f85576eec4ca41d277391dfdae21ba7"
bowd marked this conversation as resolved.
Show resolved Hide resolved

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "yarn"
node-version: "16"
bowd marked this conversation as resolved.
Show resolved Hide resolved

- name: "Install the Node.js dependencies"
run: "yarn install --immutable"

- name: "Lint the contracts"
run: "yarn lint:check"

- name: "Add lint summary"
run: |
echo "## Lint" >> $GITHUB_STEP_SUMMARY
echo "βœ… Passed" >> $GITHUB_STEP_SUMMARY

- name: "Show the Foundry config"
run: "forge config"

- name: "Run the tests"
run: "forge test"

- name: "Build the contracts"
run: |
forge --version
forge build --sizes

- name: "Add test summary"
run: |
echo "## Tests" >> $GITHUB_STEP_SUMMARY
53 changes: 53 additions & 0 deletions .github/workflows/slither.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Slither"

env:
FOUNDRY_PROFILE: "ci"

on:
workflow_dispatch:
pull_request:
branches:
- "main"
- "feature/**"
- "feat/**"
- "develop"
push:
branches:
- "main"
- "develop"

jobs:
slither:
name: Slither
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
with:
submodules: "recursive"
- name: "Install Foundry"
uses: "onbjerg/foundry-toolchain@v1"
with:
version: "nightly-d369d2486f85576eec4ca41d277391dfdae21ba7"
bowd marked this conversation as resolved.
Show resolved Hide resolved
- name: "Build the contracts"
run: |
forge build --skip test --skip script --build-info
bowd marked this conversation as resolved.
Show resolved Hide resolved
- name: Run Slither
uses: crytic/[email protected]
id: slither
with:
sarif: results.sarif
# continue-on-error: true
# -----------------------
# Ideally, we'd like to continue on error to allow uploading the SARIF file here.
# But we're often running into GitHub's API Rate Limit when uploading the SARIF file
# which would lead to lots of failed pipelines even if slither works fine:
# https://github.com/mento-protocol/mento-core/actions/runs/7167865576/job/19514794782
#
# So for now it's better to just let the slither task fail directly so we at least
# know it failed.
# -----------------------
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.slither.outputs.sarif }}
38 changes: 38 additions & 0 deletions .github/workflows/storage-layout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Storage Layout"
on:
workflow_dispatch:
push:
branches:
- "main"
- "develop"

jobs:
check_storage_layout:
name: Check storage layout
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
contract:
- contracts/legacy/ReserveSpenderMultiSig.sol:ReserveSpenderMultiSig
- contracts/legacy/StableToken.sol:StableToken
- contracts/legacy/Exchange.sol:Exchange
- contracts/legacy/GrandaMento.sol:GrandaMento
- contracts/swap/Broker.sol:Broker
- contracts/swap/BiPoolManager.sol:BiPoolManager
- contracts/swap/Reserve.sol:Reserve
- contracts/oracles/BreakerBox.sol:BreakerBox
- contracts/oracles/SortedOracles.sol:SortedOracles
- contracts/tokens/StableTokenV2.sol:StableTokenV2
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: "nightly-d369d2486f85576eec4ca41d277391dfdae21ba7"
bowd marked this conversation as resolved.
Show resolved Hide resolved
- name: Check storage layout
uses: Rubilmax/[email protected]
with:
contract: ${{ matrix.contract }}
Loading
Loading