-
Notifications
You must be signed in to change notification settings - Fork 35
230 lines (221 loc) · 6.82 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ '*' ]
env:
MIX_ENV: test
RUST_WORKSPACES: |
native/snappy -> target
native/ssz_nif -> target
permissions:
contents: read
jobs:
compile-native:
name: Build native libraries
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Elixir
# NOTE: this is needed for the NIF header files
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
- name: Set up Go
# NOTE: this action comes with caching by default
uses: actions/setup-go@v4
with:
go-version: "1.21"
cache-dependency-path: |
native/libp2p_nif/go.sum
native/libp2p_port/go.sum
- name: Cache output artifacts
id: output-cache
uses: actions/cache@v3
with:
path: priv/native/*
key: ${{ runner.os }}-native-${{ hashFiles('native/**') }}
- name: Install dependencies
if: steps.output-cache.outputs.cache-hit != 'true'
run: |
sudo apt-get install -y protobuf-compiler
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
protoc --go_out=./native/libp2p_port proto/libp2p.proto
- name: Compile native code
if: steps.output-cache.outputs.cache-hit != 'true'
run: make compile-port compile-native
build:
name: Build project
needs: compile-native
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
- name: Fetch native libraries
id: output-cache
uses: actions/cache/restore@v3
with:
path: priv/native/*
key: ${{ runner.os }}-native-${{ hashFiles('native/**') }}
fail-on-cache-miss: true
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: |
sudo apt-get install -y protobuf-compiler
echo $(protoc --version)
mix escript.install --force hex protobuf
protoc --elixir_out=./lib proto/libp2p.proto
mix deps.get
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ env.RUST_WORKSPACES }}
- name: Compile Elixir (Warnings as errors)
run: mix compile --warnings-as-errors
- name: Retrieve PLT Cache
uses: actions/cache@v1
id: plt-cache
with:
path: priv/plts
key: ${{ runner.os }}-plts-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
- name: Create PLTs
if: steps.plt-cache.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix dialyzer --plt
- name: Run dialyzer
run: mix dialyzer --no-check
test:
name: Test
needs: compile-native
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
- name: Fetch native libraries
id: output-cache
uses: actions/cache/restore@v3
with:
path: priv/native/*
key: ${{ runner.os }}-native-${{ hashFiles('native/**') }}
fail-on-cache-miss: true
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ env.RUST_WORKSPACES }}
- name: Install dependencies
run: |
sudo apt-get install -y protobuf-compiler
mix escript.install --force hex protobuf
protoc --elixir_out=./lib proto/libp2p.proto
mix deps.get
- name: Run tests
run: mix test --no-start --trace --exclude spectest
lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- name: Check format
run: |
make fmt
git diff --exit-code
- name: Run credo
run: mix credo --strict
download-spectests:
name: Download spectests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Cache compressed spectests
id: output-cache
uses: actions/cache@v3
with:
path: ./*.tar.gz
key: ${{ runner.os }}-spectest-${{ hashFiles('.spectest_version') }}
lookup-only: true
- name: Download spectests
if: steps.output-cache.outputs.cache-hit != 'true'
run: make download-vectors
spectests:
name: Run spec-tests
needs: [compile-native, download-spectests]
strategy:
matrix:
config: ["minimal", "general", "mainnet"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
- name: Fetch native libraries
uses: actions/cache/restore@v3
with:
path: priv/native/*
key: ${{ runner.os }}-native-${{ hashFiles('native/**') }}
fail-on-cache-miss: true
- name: Fetch spectest vectors
uses: actions/cache/restore@v3
with:
path: ./*.tar.gz
key: ${{ runner.os }}-spectest-${{ hashFiles('.spectest_version') }}
fail-on-cache-miss: true
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ env.RUST_WORKSPACES }}
- name: Install dependencies
run: |
sudo apt-get install -y protobuf-compiler
mix escript.install --force hex protobuf
protoc --elixir_out=./lib proto/libp2p.proto
mix deps.get
- name: Uncompress vectors
run: make test/spec/vectors/tests/${{ matrix.config }}
- name: Generate tests
run: make gen-spec
- name: Run tests
run: mix test --no-start test/generated/${{ matrix.config }}/*/*