Skip to content

Commit 848b358

Browse files
committed
add ci
1 parent 2bff63c commit 848b358

File tree

6 files changed

+149
-50
lines changed

6 files changed

+149
-50
lines changed

.github/workflows/contracts.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: Contracts
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- '**'
9+
- '.github/workflows/contracts.yaml'
10+
pull_request:
11+
types:
12+
- opened
13+
- reopened
14+
- synchronize
15+
- ready_for_review
16+
paths:
17+
- '**'
18+
- '.github/workflows/contracts.yaml'
19+
20+
defaults:
21+
run:
22+
working-directory: '.'
23+
24+
jobs:
25+
foundry:
26+
if: github.event.pull_request.draft == false
27+
runs-on: ubuntu-latest
28+
permissions: {}
29+
30+
steps:
31+
- name: Checkout sources
32+
uses: actions/checkout@v4
33+
with:
34+
submodules: recursive
35+
persist-credentials: false
36+
37+
- name: Install Foundry
38+
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1.4.0
39+
with:
40+
version: nightly
41+
42+
- name: Setup LCOV
43+
uses: hrishikesh-kadam/setup-lcov@6c1aa0cc9e1c02f9f58f01ac599f1064ccc83470 # v1
44+
45+
- name: Install Node.js 18
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version: '18'
49+
50+
- name: Get yarn cache directory path
51+
id: yarn-cache-dir-path
52+
run: echo "::set-output name=dir::$(yarn cache dir)"
53+
54+
- name: Cache yarn dependencies
55+
uses: actions/cache@v4
56+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
57+
with:
58+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
59+
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
60+
restore-keys: |
61+
${{ runner.os }}-yarn-
62+
63+
- name: Cache node_modules
64+
id: npm_cache
65+
uses: actions/cache@v4
66+
with:
67+
path: node_modules
68+
key: node_modules-${{ hashFiles('yarn.lock') }}
69+
70+
- name: yarn install
71+
# if: steps.npm_cache.outputs.cache-hit != 'true'
72+
run: yarn install
73+
74+
- name: Compile with foundry
75+
run: forge build --evm-version cancun
76+
77+
- name: Run foundry tests
78+
run: forge test --evm-version cancun -vvv
79+
80+
- name: Run foundry coverage
81+
run : forge coverage --evm-version cancun --report lcov
82+
83+
- name : Prune coverage
84+
run : lcov --rc branch_coverage=1 --remove ./lcov.info -o ./lcov.info.pruned 'src/mocks/*' 'test/*' 'script/*' 'node_modules/*' 'lib/*' --ignore-errors unused,unused
85+
86+
- name: Upload coverage reports to Codecov
87+
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
88+
env:
89+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
90+
with:
91+
files: lcov.info.pruned
92+
flags: contracts
93+
94+
slither:
95+
if: github.event.pull_request.draft == false
96+
needs: foundry
97+
runs-on: ubuntu-latest
98+
permissions:
99+
statuses: write
100+
security-events: write
101+
102+
steps:
103+
- uses: actions/checkout@v4
104+
with:
105+
submodules: recursive
106+
persist-credentials: false
107+
108+
- uses: actions/setup-node@v4
109+
with:
110+
node-version: '18'
111+
112+
- run: yarn install --frozen-lockfile
113+
114+
- uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1.4.0
115+
with:
116+
version: nightly
117+
118+
- name: Build contracts
119+
run: forge build --build-info --out out --evm-version cancun
120+
121+
- uses: actions/setup-python@v5
122+
with:
123+
python-version: '3.11'
124+
125+
- run: |
126+
python -m pip install --upgrade pip
127+
pip install slither-analyzer==0.11.3
128+
129+
- name: Run Slither (High severity gate)
130+
run: |
131+
slither . \
132+
--filter-paths "src/test/*|src/mocks/*|scripts/*|node_modules" \
133+
--foundry-out-directory out \
134+
--exclude-dependencies \
135+
--exclude-medium \
136+
--exclude-low \
137+
--exclude-informational \
138+
--fail-high \
139+
--json slither-report.json \
140+
--markdown-root slither-report.md
141+
142+
- uses: actions/upload-artifact@v4
143+
with:
144+
name: slither-static-analysis
145+
path: |
146+
slither-report.json
147+
slither-report.md

.github/workflows/test.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/facets/AssetManagerAllocatorFacet.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {TreasuryStorage} from "../TreasuryStorage.sol";
55
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
66
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
77
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
8-
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
98

109
import {IAssetManager} from "../interfaces/IAssetManager.sol";
1110

src/facets/RewardDistributorFacet.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
pragma solidity 0.8.30;
33

44
import {TreasuryStorage} from "../TreasuryStorage.sol";
5-
import {AssetManagerAllocatorFacet} from "./AssetManagerAllocatorFacet.sol";
65
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
76
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
87

@@ -51,9 +50,9 @@ contract RewardDistributorFacet is TreasuryStorage, ReentrancyGuardUpgradeable {
5150
);
5251
}
5352

54-
/*=========================== Asset Manager Functions =========================*/
53+
/*=========================== Reporter Functions =========================*/
5554

56-
/// @notice Asset Manager reports rewards
55+
/// @notice Reports and distributes rewards
5756
/// @param rewards The rewards to report
5857
function reportRewards(uint256 rewards) public onlyReporter nonReentrant {
5958
// Handle rewards

test/StakedUSX.t.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
pragma solidity ^0.8.0;
33

44
import {LocalDeployTestSetup} from "./LocalDeployTestSetup.sol";
5-
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
65
import {StakedUSX} from "../src/StakedUSX.sol";
76
import {USX} from "../src/USX.sol";
87

test/facets/RewardDistributorFacet.t.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5-
64
import {RewardDistributorFacet} from "../../src/facets/RewardDistributorFacet.sol";
75
import {TreasuryDiamond} from "../../src/TreasuryDiamond.sol";
86
import {TreasuryStorage} from "../../src/TreasuryStorage.sol";

0 commit comments

Comments
 (0)