-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (162 loc) · 5.81 KB
/
ci.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: CI
on:
push:
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build contracts
id: build
run: npm run compile
- name: 'Add build summary'
if: ${{ success() || failure() }}
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
- name: 'Add build result (success)'
if: ${{ success() && steps.build.outcome == 'success' }}
run: |
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: 'Add build result (failed)'
if: ${{ failure() && steps.build.outcome == 'failure' }}
run: |
echo "❌ Failed" >> $GITHUB_STEP_SUMMARY
test:
name: Test
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Test contracts
id: run_tests
run: |
(npm run --silent test >> /tmp/TEST_OUTPUT) || FAILED=1
{
echo "test_output<<RANDOM_DELIMITER_THAT_MOST_DEFINITELY_WONT_APPEAR_IN_TEXT"
cat /tmp/TEST_OUTPUT
echo "RANDOM_DELIMITER_THAT_MOST_DEFINITELY_WONT_APPEAR_IN_TEXT"
} >> "$GITHUB_OUTPUT"
cat /tmp/TEST_OUTPUT
if [ ${FAILED:-0} -eq 1 ]
then
exit 1
fi
- name: 'Add test summary'
if: ${{ success() || failure() }}
run: |
echo "## Tests result" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "${{steps.run_tests.outputs.test_output}}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
- name: 'Add test result (success)'
if: ${{ success() && steps.run_tests.outcome == 'success' }}
run: |
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: 'Add test result (failed)'
if: ${{ failure() && steps.run_tests.outcome == 'failure' }}
run: |
echo "❌ Failed" >> $GITHUB_STEP_SUMMARY
eslint:
name: ESLint
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run ESLint
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-check
filter_mode: nofilter
level: info
prettier:
name: Prettier
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- uses: EPMatt/reviewdog-action-prettier@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
filter_mode: nofilter
prettier_flags: '**/*.{js,sol,ts,json,jsx,tsx}'
level: info
solhint:
name: Solhint
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Setup reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Run solhint
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx solhint -f sarif 'contracts/**/*.sol' | reviewdog -f=sarif -reporter=github-check -level=info -fail-level=none -filter-mode=nofilter -name=solhint
slither:
name: Slither
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Slither
uses: crytic/[email protected]
id: slither
with:
node-version: 20
sarif: 'results.sarif'
fail-on: none
slither-args: --filter-paths node_modules/
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.slither.outputs.sarif }}