-
Notifications
You must be signed in to change notification settings - Fork 6
166 lines (148 loc) · 5.59 KB
/
main.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
164
165
166
name: main
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
deps:
runs-on: ubuntu-latest
outputs:
cache-path: ${{ steps.cache-env.outputs.cache-path }}
cache-key: ${{ steps.cache-env.outputs.cache-key }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Get yarn cache directory path
id: cache-env
run: |
echo "cache-path=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
echo "cache-key=${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: cache
with:
path: ${{ steps.cache-env.outputs.cache-path }}
key: ${{ steps.cache-env.outputs.cache-key }}
restore-keys: ${{ runner.os }}-yarn-
- if: steps.cache.outputs.cache-hit != 'true'
run: yarn
get-changed-files:
runs-on: ubuntu-latest
outputs:
any_changed: ${{ steps.changed-files.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: packages/**/*.{sol,json,ts}
compile:
if: ${{ needs.get-changed-files.outputs.any_changed }}
needs: [get-changed-files, deps]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- uses: actions/cache/restore@v4
with:
path: ${{ needs.deps.outputs.cache-path }}
key: ${{ needs.deps.outputs.cache-key }}
- run: yarn compile
- name: Upload compilation results
uses: actions/upload-artifact@v4
with:
name: all-artifacts
path: packages/**/artifacts/**
style:
needs: deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- uses: actions/cache/restore@v4
with:
path: ${{ needs.deps.outputs.cache-path }}
key: ${{ needs.deps.outputs.cache-key }}
- run: yarn format
tests:
if: ${{ needs.get-changed-files.outputs.any_changed }}
needs: compile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- uses: actions/cache/restore@v4
with:
path: ${{ needs.deps.outputs.cache-path }}
key: ${{ needs.deps.outputs.cache-key }}
- uses: actions/download-artifact@v4
with:
name: all-artifacts
path: packages/
- run: yarn test
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
set-slither-matrix:
needs: get-changed-files
if: ${{ needs.get-changed-files.outputs.any_changed == 'true' }}
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Set matrix
id: set-matrix
run: |
matrix=$(ls -1 packages | jq -Rsc 'split("\n") | map(select(length > 0))')
echo "matrix=$matrix" >> $GITHUB_OUTPUT
slither:
if: ${{ needs.get-changed-files.outputs.any_changed }}
needs: [set-slither-matrix, compile]
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
strategy:
matrix:
dir: ${{ fromJson(needs.set-slither-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Run slither
uses: crytic/slither-action@v0.4.0
id: slither
with:
ignore-compile: true
fail-on: none
sarif: results.sarif
slither-args: --filter-paths "test" --exclude-dependencies --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/
target: packages/${{ matrix.dir }}
- name: Upload SARIF files
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.slither.outputs.sarif }}
- name: Create/update checklist as PR comment
uses: actions/github-script@v7
if: github.even_name == 'pull_request'
env:
REPORT: ${{ steps.slither.stdout }}
with:
script: |
const script = require('.github/scripts/slither-comment')
const header = '# Slither report'
const body = process.env.REPORT
await script({ github, context, header, body })