-
Notifications
You must be signed in to change notification settings - Fork 266
329 lines (287 loc) · 9.64 KB
/
build_and_test.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
name: Build and Test
on:
push:
branches:
- "master"
- "*-rc"
pull_request:
types: [opened, reopened, synchronize]
branches:
- "**"
jobs:
build:
runs-on: ubuntu-latest
container:
image: openjdk:8-jdk
steps:
- uses: actions/checkout@v4
- name: Setup System Tools
run: |
apt update -y
apt install -y gnupg2 curl
- name: Verify files
run: |
curl -sSL https://secchannel.rsk.co/SUPPORT.asc | gpg2 --import -
gpg2 --verify SHA256SUMS.asc && sha256sum --check SHA256SUMS.asc
- uses: actions/cache@v4
name: Cache Gradle
id: cache-gradle
with:
path: |
.gradle/caches
gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Get gradle wrapper and build dependencies
if: steps.cache-gradle.outputs.cache-hit != 'true'
run: |
./configure.sh
./gradlew --no-daemon dependencies
- name: Build
run: |
./gradlew --no-daemon --stacktrace build -x test
- name: Archive build artifacts
uses: actions/upload-artifact@v4
with:
name: build-files
path: |
rskj-core/build
smell-test:
needs: unit-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: actions/cache@v4
name: Restore Gradle cache
id: cache-gradle
with:
path: |
.gradle/caches
gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Get gradle wrapper and build dependencies
run: |
if [ ! -f gradle/wrapper/gradle-wrapper.jar ]; then
./configure.sh
./gradlew --no-daemon dependencies
fi
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-files
path: |
rskj-core/build
- name: Download test results
uses: actions/download-artifact@v4
with:
name: test-results
path: |
rskj-core/build/test-results/
- name: Download test reports
uses: actions/download-artifact@v4
with:
name: test-reports
path: |
rskj-core/build/reports/
- name: Run SonarQube analysis
env:
GH_EVENT: ${{ github.event_name }}
GH_PR_NUMBER: ${{ github.event.pull_request.number }}
GH_PR_BASE_REF: ${{ github.base_ref }}
GH_PR_HEAD_REF: ${{ github.head_ref }}
GH_REF: ${{ github.ref }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
if [ "$GH_EVENT" = pull_request ]; then
./gradlew sonarqube --no-daemon -x build -x test \
-Dsonar.pullrequest.base="$GH_PR_BASE_REF" \
-Dsonar.pullrequest.branch="$GH_PR_HEAD_REF" \
-Dsonar.pullrequest.key="$GH_PR_NUMBER" \
-Dsonar.organization=rsksmart \
-Dsonar.projectKey=rskj \
-Dsonar.host.url="https://sonarcloud.io" \
-Dsonar.junit.reportPaths=rskj-core/build/test-results/ \
-Dsonar.coverage.jacoco.xmlReportPaths=rskj-core/build/reports/jacoco/test/jacocoTestReport.xml \
-Dsonar.token="$SONAR_TOKEN"
else
./gradlew sonarqube --no-daemon -x build -x test \
-Dsonar.branch.name="$GH_REF" \
-Dsonar.organization=rsksmart \
-Dsonar.projectKey=rskj \
-Dsonar.host.url="https://sonarcloud.io" \
-Dsonar.junit.reportPaths=rskj-core/build/test-results/ \
-Dsonar.coverage.jacoco.xmlReportPaths=rskj-core/build/reports/jacoco/test/jacocoTestReport.xml \
-Dsonar.token="$SONAR_TOKEN"
fi
mining-tests:
needs: build
runs-on: ubuntu-latest
services:
bitcoind1:
image: ghcr.io/rsksmart/rskj/mit_bitcoind1:latest
ports:
- 8331:8331
- 31591:31591
- 32591:32591
options: --name bitcoind1
bitcoind2:
image: ghcr.io/rsksmart/rskj/mit_bitcoind2:latest
ports:
- 8332:8332
- 31592:31592
- 32592:32592
options: --name bitcoind2
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '12.x'
- name: Check Node.js version
run: node --version
- name: Checkout Mining Integration Tests Repository
uses: actions/checkout@v4
with:
repository: rsksmart/mining-integration-tests
ref: ${{ secrets.MINING_INTEGRATION_TESTS_REF }}
token: ${{ secrets.GITHUB_TOKEN }}
path: mining-integration-tests
- name: Install Mining Integration Tests dependencies
working-directory: mining-integration-tests
run: |
npm ci
- name: Change mining-integration-tests bitcoind url in config.json to localhost
working-directory: mining-integration-tests
run: |
jq 'if .bitcoind.url? then .bitcoind.url = "localhost" else error(".bitcoind.url not found") end' config.json > config.json.tmp && mv config.json.tmp config.json
- name: Generate BTC blocks
working-directory: mining-integration-tests
run: |
node --unhandled-rejections=strict generateBtcBlocks.js
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: actions/cache@v4
name: Cache Gradle
id: cache-gradle
with:
path: |
.gradle/caches
gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Get gradle wrapper and build dependencies
if: steps.cache-gradle.outputs.cache-hit != 'true'
run: |
./configure.sh
./gradlew --no-daemon dependencies
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-files
path: |
rskj-core/build
- name: Start RSKj and Run Tests
working-directory: mining-integration-tests
run: |
version=$(tr -d "'\"" < ../rskj-core/src/main/resources/version.properties \
| cut -d = -f 2- | paste -sd - -)
echo "Using RskJ version $version at ../rskj-core/build/libs/rskj-core-$version-all.jar"
java -Drsk.conf.file=./rsk-integration-test.conf -cp ../rskj-core/build/libs/rskj-core-"$version"-all.jar co.rsk.Start --regtest & rskpid=$!
tries=0
MAX_TRIES=10
while [ $tries -lt $MAX_TRIES ]; do
nc -z 127.0.0.1 4444 && break
echo "Waiting for RskJ..."
tries=$((tries+1))
sleep 1
done
if [ $tries -eq $MAX_TRIES ]; then
echo "RskJ unreachable after $MAX_TRIES attempts. Aborting." >&2
exit 1
fi
npm test
kill $rskpid
unit-tests:
needs: build
runs-on: ubuntu-latest
container:
image: openjdk:8-jdk
steps:
- uses: actions/checkout@v4
- name: Setup System Tools
run: |
apt update -y
apt install -y curl
- uses: actions/cache@v4
name: Cache Gradle
id: cache-gradle
with:
path: |
.gradle/caches
gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Get gradle wrapper and build dependencies
if: steps.cache-gradle.outputs.cache-hit != 'true'
run: |
./configure.sh
./gradlew --no-daemon dependencies
- name: Run tests
run: |
./gradlew --no-daemon --stacktrace test
- name: Persist test results for sonar
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
rskj-core/build/test-results/
- name: Persist test reports for sonar
uses: actions/upload-artifact@v4
with:
name: test-reports
path: |
rskj-core/build/reports/
integration-tests:
runs-on: ubuntu-latest
container:
image: openjdk:8-jdk
steps:
- uses: actions/checkout@v4
- name: Setup System Tools
run: |
apt update -y
apt install -y curl
- uses: actions/cache@v4
name: Cache Gradle
id: cache-gradle
with:
path: |
.gradle/caches
gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Get gradle wrapper and build dependencies
if: steps.cache-gradle.outputs.cache-hit != 'true'
run: |
./configure.sh
./gradlew --no-daemon dependencies
- name: Run tests
run: |
./gradlew --no-daemon --stacktrace integrationTest