-
Notifications
You must be signed in to change notification settings - Fork 795
276 lines (273 loc) · 10.9 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
name: Build and Test
on:
workflow_dispatch:
inputs:
build_tag:
description: 'Which tag or version will be built'
default: 'master'
required: true
type: string
jobs:
start-runner:
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest
outputs:
label-01: ${{ steps.start-ec2-runner-01.outputs.label }}
ec2-instance-id-01: ${{ steps.start-ec2-runner-01.outputs.ec2-instance-id }}
label-02: ${{ steps.start-ec2-runner-02.outputs.label }}
ec2-instance-id-02: ${{ steps.start-ec2-runner-02.outputs.ec2-instance-id }}
label-03: ${{ steps.start-ec2-runner-03.outputs.label }}
ec2-instance-id-03: ${{ steps.start-ec2-runner-03.outputs.ec2-instance-id }}
label-04: ${{ steps.start-ec2-runner-04.outputs.label }}
ec2-instance-id-04: ${{ steps.start-ec2-runner-04.outputs.ec2-instance-id }}
label-05: ${{ steps.start-ec2-runner-05.outputs.label }}
ec2-instance-id-05: ${{ steps.start-ec2-runner-05.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Start EC2 runner 01
id: start-ec2-runner-01
uses: ety001/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ${{ secrets.AWS_AMI_ID }}
ec2-instance-type: ${{ secrets.AWS_INSTANCE_TYPE }}
subnet-id: ${{ secrets.AWS_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_SG_ID }}
aws-resource-tags: > # optional, requires additional permissions
[
{"Key": "Name", "Value": "ec2-github-runner-01"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
- name: Start EC2 runner 02
id: start-ec2-runner-02
uses: ety001/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ${{ secrets.AWS_AMI_ID }}
ec2-instance-type: ${{ secrets.AWS_INSTANCE_TYPE }}
subnet-id: ${{ secrets.AWS_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_SG_ID }}
aws-resource-tags: > # optional, requires additional permissions
[
{"Key": "Name", "Value": "ec2-github-runner-02"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
- name: Start EC2 runner 03
id: start-ec2-runner-03
uses: ety001/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ${{ secrets.AWS_AMI_ID }}
ec2-instance-type: ${{ secrets.AWS_INSTANCE_TYPE }}
subnet-id: ${{ secrets.AWS_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_SG_ID }}
aws-resource-tags: > # optional, requires additional permissions
[
{"Key": "Name", "Value": "ec2-github-runner-03"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
- name: Start EC2 runner 04
id: start-ec2-runner-04
uses: ety001/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ${{ secrets.AWS_AMI_ID }}
ec2-instance-type: ${{ secrets.AWS_INSTANCE_TYPE }}
subnet-id: ${{ secrets.AWS_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_SG_ID }}
aws-resource-tags: > # optional, requires additional permissions
[
{"Key": "Name", "Value": "ec2-github-runner-04"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
- name: Start EC2 runner 05
id: start-ec2-runner-05
uses: ety001/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ${{ secrets.AWS_AMI_ID }}
ec2-instance-type: ${{ secrets.AWS_INSTANCE_TYPE }}
subnet-id: ${{ secrets.AWS_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_SG_ID }}
aws-resource-tags: > # optional, requires additional permissions
[
{"Key": "Name", "Value": "ec2-github-runner-05"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
build:
needs: start-runner # required to start the main job when the runner is ready
runs-on: self-hosted
strategy:
matrix:
include:
# [unit test] low memory node and mira on (for witness node)
- cmake_build_type: Release
low_memory_mode: 'ON'
clear_votes: 'ON'
skip_by_tx_id: 'ON'
build_steem_testnet: 'OFF'
enable_coverage_testing: 'OFF'
chainbase_check_locking: 'OFF'
unit_test: 'ON'
# [unit test] fullnode and mira on (for api node)
- cmake_build_type: Release
low_memory_mode: 'OFF'
clear_votes: 'OFF'
skip_by_tx_id: 'ON'
build_steem_testnet: 'OFF'
enable_coverage_testing: 'OFF'
chainbase_check_locking: 'OFF'
unit_test: 'ON'
# low memory node and mira on (for witness node)
- cmake_build_type: Release
low_memory_mode: 'ON'
clear_votes: 'ON'
skip_by_tx_id: 'ON'
build_steem_testnet: 'OFF'
enable_coverage_testing: 'OFF'
chainbase_check_locking: 'OFF'
unit_test: 'OFF'
# fullnode and mira on (for api node)
- cmake_build_type: Release
low_memory_mode: 'OFF'
clear_votes: 'OFF'
skip_by_tx_id: 'ON'
build_steem_testnet: 'OFF'
enable_coverage_testing: 'OFF'
chainbase_check_locking: 'OFF'
unit_test: 'OFF'
# testnet node and mira on
- cmake_build_type: Debug
low_memory_mode: 'OFF'
clear_votes: 'ON'
skip_by_tx_id: 'ON'
build_steem_testnet: 'ON'
enable_coverage_testing: 'ON'
chainbase_check_locking: 'OFF'
unit_test: 'OFF'
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Generate Docker Image Name
id: 'docker_image_name'
env:
BUILD_TAG: ${{ github.event.inputs.build_tag }}
MIRA: 'ON'
LOW_MEMORY_MODE: ${{ matrix.low_memory_mode }}
BUILD_STEEM_TESTNET: ${{ matrix.build_steem_testnet }}
run: |
set -x
if [ "${MIRA}" = "ON" ]; then
mira_tag="-mira";
else
mira_tag="-shared-memory";
fi
if [ "${BUILD_STEEM_TESTNET}" = "ON" ]; then
testnet_tag="-testnet";
else
testnet_tag="";
fi
if [ "${LOW_MEMORY_MODE}" = "ON" ]; then
low_memory_tag="";
else
low_memory_tag="-full";
fi
echo "::set-output name=image_name::steemit/steem:${BUILD_TAG}${mira_tag}${low_memory_tag}${testnet_tag}"
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.new
build-args: |
CMAKE_BUILD_TYPE: ${{ matrix.cmake_build_type }}
BUILD_TAG: ${{ github.event.inputs.build_tag }}
STEEM_STATIC_BUILD: 'ON'
ENABLE_MIRA: 'ON'
LOW_MEMORY_MODE: ${{ matrix.low_memory_mode }}
CLEAR_VOTES: ${{ matrix.clear_votes }}
SKIP_BY_TX_ID: ${{ matrix.skip_by_tx_id }}
BUILD_STEEM_TESTNET: ${{ matrix.build_steem_testnet }}
ENABLE_COVERAGE_TESTING: ${{ matrix.enable_coverage_testing }}
CHAINBASE_CHECK_LOCKING: ${{ matrix.chainbase_check_locking }}
UNIT_TEST: ${{ matrix.unit_test }}
DOXYGEN: 'OFF'
push: ${{ matrix.unit_test == 'OFF' }}
tags: ${{ steps.docker_image_name.outputs.image_name }}
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner # required to get output from the start-runner job
- build # required to wait when the main job is done
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Stop EC2 runner 01
uses: ety001/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label-01 }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id-01 }}
- name: Stop EC2 runner 02
uses: ety001/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label-02 }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id-02 }}
- name: Stop EC2 runner 03
uses: ety001/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label-03 }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id-03 }}
- name: Stop EC2 runner 04
uses: ety001/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label-04 }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id-04 }}
- name: Stop EC2 runner 05
uses: ety001/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label-05 }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id-05 }}