-
Notifications
You must be signed in to change notification settings - Fork 267
363 lines (355 loc) · 11.5 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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
name: Build and Test
on:
push:
branches:
- '**'
pull_request:
types: [opened, reopened, ready_for_review]
branches:
- '**'
jobs:
# build:
# runs-on: ubuntu-latest
# container:
# image: openjdk:8-jdk
# env:
# _JAVA_OPTIONS: "-Xmx3G -Xms2G"
# defaults:
# run:
# working-directory: .
# steps:
# - uses: actions/checkout@v2
# - name: Setup System Tools
# run: |
# apt update -y
# apt install -y gnupg2 curl
# - name: Install Node.js
# run: |
# curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
# apt-get install -y nodejs
# - name: Check Node.js version
# run: node --version
# - 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
# with:
# path: |
# .gradle/caches
# gradle/wrapper
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
# restore-keys: |
# ${{ runner.os }}-gradle-
#
# - uses: actions/cache@v4
# name: Cache build
# with:
# path: |
# build
# key: ${{ runner.os }}-build-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
# restore-keys: |
# ${{ runner.os }}-build-
#
# - name: Build
# run: |
# ./configure.sh
# ./gradlew --no-daemon dependencies
# ./gradlew --no-daemon --stacktrace build -x test
# ls -la ./gradle/wrapper/gradle-wrapper.jar
#
# sonarqube:
# needs: build
# runs-on: ubuntu-latest
# container:
# image: eclipse-temurin:17-jdk
# defaults:
# run:
# working-directory: .
# steps:
# - uses: actions/checkout@v2
# - name: Run SonarQube analysis
# run: |
# echo "Installing git"
# apt-get update && apt-get install -yqq git
# extra_flags=""
# echo "Get GH event type"
# event_name="${{ github.event_name }}"
# if [ "$event_name" = "pull_request" ]; then
# echo "Setting up PR analysis"
# echo "switch to master"
# git branch -f master origin/master
# pr_number=${{ github.event.pull_request.number }}
# echo "PR number: $pr_number"
# extra_flags="-Dsonar.pullrequest.base=master -Dsonar.pullrequest.branch=${{ github.head_ref }} -Dsonar.pullrequest.key=$pr_number"
# echo "PR analysis flags: $extra_flags"
# else
# echo "Setting up branch analysis"
# extra_flags="-Dsonar.branch.name=master"
# echo "Branch analysis flags: $extra_flags"
# fi
#
# sonar_url=${{ secrets.SONAR_URL }}
# sonar_token=${{ secrets.SONAR_TOKEN }}
# echo "Event name: $event_name"
# echo "Sonar URL: $sonar_url"
#
# echo "Running SonarQube analysis"
# ./configure.sh
# ./gradlew sonarqube --no-daemon -x build -x test $extra_flags \
# -Dsonar.organization=rsksmart -Dsonar.host.url="$sonar_url" -Dsonar.login="$sonar_token"
#
# tests:
# needs: build
# runs-on: ubuntu-latest
# container:
# image: openjdk:8-jdk
# defaults:
# run:
# working-directory: .
# steps:
# - uses: actions/checkout@v2
#
# - name: Setup System Tools
# run: |
# apt update -y
# apt install -y curl
# - name: Install Node.js
# run: |
# curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
# apt-get install -y nodejs
# - name: Check Node.js version
# run: node --version
#
# - uses: actions/cache@v4
# name: Restore gradle cache
# with:
# path: |
# .gradle/caches
# gradle/wrapper
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
# restore-keys: |
# ${{ runner.os }}-gradle-
#
# - name: Get Gradle jar
# run: |
# ./configure.sh
#
# - name: Unit tests
# run: |
# chmod +x ./gradlew
# ./gradlew --no-daemon --stacktrace test
# - name: Integration tests
# run: |
# chmod +x ./gradlew
# ./gradlew --no-daemon --stacktrace test
#
# - name: Save test results
# run: |
# mkdir -p ~/junit/
# find rskj-core/build/test-results -type f -name "*.xml" -exec cp {} ~/junit/ \;
# if: always()
mining-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: .
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup System Tools
run: |
sudo apt update -y
sudo apt install -y curl jq lsof
- name: Start bitcoin containers
run: |
sudo docker compose --file docker-compose.yml up -d
- name: Wait for Bitcoin nodes to initialize
run: |
while ! curl -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://localhost:32591; do
echo "Waiting for bitcoind1 to start..."
sleep 5
done
# mining-tests:
## needs: build
# runs-on: ubuntu-latest
## container:
## image: openjdk:8-jdk
# defaults:
# run:
# working-directory: .
#
# steps:
# - name: Checkout
# uses: actions/checkout@v2
#
## - name: Setup System Tools
## run: |
## sudo apt-get update -y
## sudo apt-get install -y jq lsof
#
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '21.x'
# - name: Check Node.js version
# run: node --version
#
# - name: Checkout Mining Integration Tests Repository
# uses: actions/checkout@v2
# with:
# repository: jurajpiar/mining-integration-tests
## ref: ${{ secrets.MINING_INTEGRATION_TESTS_REF }}
## token: ${{ secrets.GITHUB_TOKEN }}
# path: mining-integration-tests
#
# - name: Start bitcoin containers
# run: |
# sudo docker compose --file mining-integration-tests/docker-compose.yml up -d
#
# - name: Wait for Bitcoin nodes to initialize
# run: |
# while ! curl -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://localhost:32591; do
# echo "Waiting for bitcoind1 to start..."
# sleep 5
# done
#
# - name: Check bitcoin nodes
# uses: docker://docker
# with:
# args: |
# docker ps -a
# - name: Check bitcoind1 logs
# uses: docker://docker
# with:
# args: |
# docker logs bitcoind1
# - name: Check bitcoind2 logs
# uses: docker://docker
# with:
# args: |
# docker logs bitcoind2
#
# - name: Test bitcoin node 1 as localhost
# if: always()
# run: |
# echo Test bitcoin node 1
# curl -v -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://localhost:32591
# - name: Test bitcoin nodes as bitcoind1
# if: always()
# run: |
# echo Test bitcoin node 1
# curl -v -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://bitcoind1:32591
#
# - name: Test bitcoin node 2 as localhost
# if: always()
# run: |
# echo Test bitcoin node 2
# curl -v -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://localhost:32592
#
# - name: Test bitcoin nodes as bitcoind2
# if: always()
# run: |
# echo Test bitcoin node 2
# curl -v -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://bitcoind2:32592
#
## - uses: actions/cache@v2
## with:
## path: |
## node_modules
## key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
## restore-keys: |
## ${{ runner.os }}-node-
#
# - name: "Modify test suite config"
# run: |
# ls -al mining-integration-tests
# cat mining-integration-tests/config.json
# echo "bitcoind url before"
# jq -r '.bitcoind.url' "mining-integration-tests/config.json"
# jq --arg new_url "localhost" '.bitcoind.url = $new_url' "mining-integration-tests/config.json" > temp.json && mv temp.json "mining-integration-tests/config.json"
# echo "bitcoind url after"
# jq -r '.bitcoind.url' "mining-integration-tests/config.json"
#
# - name: Install Mining Integration Tests dependencies
# working-directory: mining-integration-tests
# run: |
# npm install
#
# - 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'
#
# - name: Verify Java installation
# run: java -version
#
## - uses: actions/cache@v4
## name: Restore gradle cache
## with:
## path: |
## .gradle/caches
## gradle/wrapper
## key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
## restore-keys: |
## ${{ runner.os }}-gradle-
##
# - name: Get Gradle jar
# run: |
# ./configure.sh
#
## - uses: actions/cache@v4
## name: Restore build
## with:
## path: |
## rsk-core/build
## key: ${{ runner.os }}-build-${{ hashFiles('build') }}
## restore-keys: |
## ${{ runner.os }}-build-
#
# - name: Build
# run: |
# ./configure.sh
# ./gradlew --no-daemon dependencies
# ./gradlew --no-daemon --stacktrace build -x test
# ls -la ./gradle/wrapper/gradle-wrapper.jar
#
# - name: Start RSKj
# run: |
# version=$(tr -d "'\"" < rskj-core/src/main/resources/version.properties \
# | cut -d = -f 2- | paste -sd - -)
# ls -la 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
#
#
## - name: Run Mining Integration Tests
## run: |
## chmod +x mining-test/run.sh
## ./mining-test/run.sh
#
# - name: Run Mining Integration Tests
# working-directory: mining-integration-tests
# run: |
# npm test
#
# - name: Review test results
# working-directory: mining-integration-tests
# if: always()
# run: |
# cat ./Results/mocha/Test-Results.xml
#
# - name: Stop and Remove Docker Containers
# uses: docker://docker
# if: always()
# with:
# args: |
# docker stop bitcoind1 bitcoind2
# docker rm bitcoind1 bitcoind2