-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (136 loc) · 3.68 KB
/
check-source-code.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
167
name: Check source code
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
run-pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pre-commit binaries
run: |
pip install pre-commit
- name: Run pre-commit
run: |
make install-pre-commit
make pre-commit
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install commitizen
run: pip install commitizen
- name: Check the branch commits
run: |
cz check --rev-range origin/HEAD..HEAD
code-format:
name: Code format
strategy:
matrix:
go: ["1.23"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Install abigen
run: make install-abigen
- name: Generate contract bindings
run: make generate
- name: Instal gofumpt
run: make install-gofumpt
- name: Check code format
run: |
if [[ ! -z $(make format) ]];
then
echo "Code is not formatted. Please run 'make format' and commit changes"
exit 1
fi
shell: bash
- name: Install staticcheck
run: make install-staticcheck
- name: Run staticcheck
run: make staticcheck
build:
name: Build
needs: code-format
strategy:
matrix:
go: ["1.23"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: Install abigen
run: make install-abigen
- name: Generate contract bindings
run: make generate
- name: Check go mod status
run: |
make gomod_tidy
if [[ ! -z $(git status -s | grep 'go.mod') ]] || [[ ! -z $(git status -s | grep 'go.sum') ]];
then
echo "Changes on go.mod or go.sum files - state is not clean:"
git status -s
git diff "$GITHUB_SHA"
exit 1
fi
shell: bash
- name: Check build
run: make build
test:
name: Run tests
needs: build
strategy:
matrix:
go: ["1.23"]
os: [ubuntu-latest]
codecov: [false]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: Install deps
run: make install-deps
- name: Run tests
if: matrix.codecov == false
run: make test
- name: Run codecov tests
if: matrix.codecov == true
run: make codecov-test
- name: Upload coverage to Codecov
if: matrix.codecov == true
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
files: ./coverage.out
flags: unittests
name: codecov-umbrella
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}