1+ name : CI/CD
2+
3+ on :
4+ push :
5+ branches : [ main, master, develop ]
6+ pull_request :
7+ branches : [ main, master, develop ]
8+
9+ env :
10+ NODE_ENV : test
11+
12+ jobs :
13+ lint :
14+ name : Code Quality & Linting
15+ runs-on : ubuntu-latest
16+
17+ steps :
18+ - name : Checkout code
19+ uses : actions/checkout@v4
20+
21+ - name : Setup Node.js
22+ uses : actions/setup-node@v4
23+ with :
24+ node-version : ' 20'
25+ cache : ' npm'
26+
27+ - name : Install dependencies
28+ run : npm ci
29+
30+ - name : Run Solidity Linter
31+ run : npm run lint:sol
32+
33+ - name : Run ESLint
34+ run : npm run lint
35+
36+ - name : Check Prettier formatting
37+ run : npx prettier '**/*.{json,sol,md,ts,js}' --check
38+
39+ compile :
40+ name : Compile Contracts
41+ runs-on : ubuntu-latest
42+
43+ steps :
44+ - name : Checkout code
45+ uses : actions/checkout@v4
46+
47+ - name : Setup Node.js
48+ uses : actions/setup-node@v4
49+ with :
50+ node-version : ' 20'
51+ cache : ' npm'
52+
53+ - name : Install dependencies
54+ run : npm ci
55+
56+ - name : Compile Solidity contracts
57+ run : npm run compile
58+
59+ - name : Upload artifacts
60+ uses : actions/upload-artifact@v4
61+ with :
62+ name : contract-artifacts
63+ path : |
64+ artifacts/
65+ src/contracts/
66+ retention-days : 1
67+
68+ test :
69+ name : Test (Node ${{ matrix.node-version }})
70+ runs-on : ubuntu-latest
71+ needs : [compile]
72+ strategy :
73+ matrix :
74+ node-version : [18, 20]
75+
76+ steps :
77+ - name : Checkout code
78+ uses : actions/checkout@v4
79+
80+ - name : Setup Node.js ${{ matrix.node-version }}
81+ uses : actions/setup-node@v4
82+ with :
83+ node-version : ${{ matrix.node-version }}
84+ cache : ' npm'
85+
86+ - name : Install dependencies
87+ run : npm ci
88+
89+ - name : Download artifacts
90+ uses : actions/download-artifact@v4
91+ with :
92+ name : contract-artifacts
93+ path : ./
94+
95+ - name : Run tests
96+ run : npm run test
97+
98+ - name : Generate coverage report
99+ if : matrix.node-version == '20'
100+ run : npm run coverage
101+ continue-on-error : true
102+
103+ - name : Upload coverage reports
104+ if : matrix.node-version == '20'
105+ uses : actions/upload-artifact@v4
106+ with :
107+ name : coverage-report
108+ path : coverage/
109+ retention-days : 7
110+
111+ - name : Upload coverage to Codecov
112+ uses : codecov/codecov-action@v4
113+ if : matrix.node-version == '20'
114+ with :
115+ file : ./coverage/lcov.info
116+ fail_ci_if_error : false
117+
118+ build :
119+ name : Build Package
120+ runs-on : ubuntu-latest
121+ needs : [lint, compile, test]
122+
123+ steps :
124+ - name : Checkout code
125+ uses : actions/checkout@v4
126+
127+ - name : Setup Node.js
128+ uses : actions/setup-node@v4
129+ with :
130+ node-version : ' 20'
131+ cache : ' npm'
132+
133+ - name : Install dependencies
134+ run : npm ci
135+
136+ - name : Download artifacts
137+ uses : actions/download-artifact@v4
138+ with :
139+ name : contract-artifacts
140+ path : ./
141+
142+ - name : Build TypeScript
143+ run : npm run build
144+
145+ - name : Upload build artifacts
146+ uses : actions/upload-artifact@v4
147+ with :
148+ name : build-artifacts
149+ path : |
150+ dist/
151+ artifacts/
152+ retention-days : 7
153+
154+ security :
155+ name : Security Audit
156+ runs-on : ubuntu-latest
157+ needs : [compile]
158+
159+ steps :
160+ - name : Checkout code
161+ uses : actions/checkout@v4
162+
163+ - name : Setup Node.js
164+ uses : actions/setup-node@v4
165+ with :
166+ node-version : ' 20'
167+ cache : ' npm'
168+
169+ - name : Run npm audit
170+ run : npm audit --audit-level=high
171+ continue-on-error : true
172+
173+ - name : Install dependencies
174+ run : npm ci
175+
176+ - name : Download artifacts
177+ uses : actions/download-artifact@v4
178+ with :
179+ name : contract-artifacts
180+ path : ./
181+
182+ - name : Run Slither Analysis
183+ uses : crytic/slither-action@v0.3.0
184+ id : slither
185+ with :
186+ target : ' contracts/'
187+ slither-config : .slither.conf.json
188+ continue-on-error : true
0 commit comments