-
Notifications
You must be signed in to change notification settings - Fork 10
108 lines (87 loc) · 3.29 KB
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: cd
on: [push, pull_request]
env:
SOLC_VERSION: ${{ secrets.SOLC_VERSION }}
SOLIDITY_OPTIMIZER: ${{ secrets.SOLIDITY_OPTIMIZER }}
jobs:
cd:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: [20.x]
python: [3.9.x]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Changed sol files check
uses: tj-actions/changed-files@v45
id: changed-sol-files
with:
files: contracts/*.sol
- name: Setup Python
if: steps.changed-sol-files.outputs.any_changed == 'true'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Get pip cache directory path
id: pip-cache-dir-path
run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache pip
if: steps.changed-sol-files.outputs.any_changed == 'true'
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python }}-slither0-10-4-id-1
- name: Cache pip (Mythril)
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-pip-mythril-${{ matrix.python }}-v0-24-8-id-1
- name: Install Analyzer tools
if: steps.changed-sol-files.outputs.any_changed == 'true'
run: |
python -m pip install --upgrade pip
pip install -U wheel setuptools
pip install slither-analyzer==0.10.4
python -m venv venv_mythril
source venv_mythril/bin/activate
python -m pip install --upgrade pip
pip install -U wheel setuptools
pip install mythril==0.24.8
deactivate
- name: Setup Solc
if: steps.changed-sol-files.outputs.any_changed == 'true'
uses: pontem-network/get-solc@f67593db4487ac96b4bf8031123a6deefc399b2e
with:
version: v${{ env.SOLC_VERSION }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache yarn
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-id-1
- name: Install dependencies
run: yarn install --production=false --ignore-scripts --frozen-lockfile --prefer-offline
- name: Tests
run: yarn run hardhat test &
- name: Format and lint
run: yarn tsc --noEmit && yarn prettier '**/{*,''}.{json,js,ts,sol}' --check && yarn eslint '**/{*,''}.{json,js,ts}' && yarn solhint 'contracts/*.sol' &
- name: Analyze contracts with Slither
if: steps.changed-sol-files.outputs.any_changed == 'true'
run: slither contracts/ &
- name: Analyze contracts with Mythril
if: steps.changed-sol-files.outputs.any_changed == 'true'
run: |
source venv_mythril/bin/activate
for file in contracts/*.sol; do
myth analyze --solc-json mythril.config.json "$file" &
done
wait
deactivate