-
Notifications
You must be signed in to change notification settings - Fork 2
312 lines (278 loc) · 13.8 KB
/
prepare-vs-install.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
name: Prepare Streaming Cluster [Install]
on:
schedule:
- cron: '40 1 * * *'
workflow_dispatch:
inputs:
cloud_provider:
default: aws-cn
required: true
type: string
region:
default: cn-northwest-1
required: true
type: string
uninstall:
default: false
required: true
type: boolean
execute_benchmark:
default: false
required: true
type: boolean
jobs:
prepare_automq_env:
environment: ${{ inputs.cloud_provider || 'aws-cn' }}
name: Prepare AutoMQ Environment
runs-on: ubuntu-latest
env:
STREAMING_PROVIDER: automq
CLOUD_PROVIDER: ${{ inputs.cloud_provider || 'aws-cn' }}
REGION: ${{ inputs.region || 'cn-northwest-1' }}
outputs:
benchmark_result_json_automq: ${{ steps.shared-automq.outputs.benchmark_result_json_automq }}
extracted_data_automq: ${{ steps.shared-automq.outputs.extracted_data_automq }}
baseline_cost_automq: ${{ steps.shared-automq.outputs.baseline_cost_automq }}
usage_cost_automq: ${{ steps.shared-automq.outputs.usage_cost_automq }}
total_cost_automq: ${{ steps.shared-automq.outputs.total_cost_automq }}
steps:
- name: Hello World
run: echo "Hello World"
- name: Checkout Benchmark Code
uses: actions/checkout@v3
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Composition action can't access secrets input, so we inline related step here
- name: Fetch Latest Data
shell: bash
run: |
git pull origin main
- name: Build Benchmark Code
shell: bash
run: |
mvn clean package -Dlicense.skip=true -Dcheckstyle.skip -DskipTests -Dspotless.check.skip
- name: Apply Variables and Secrets for Shared Files
shell: bash
run: |
echo "current path is: $(pwd)"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-nats/deploy/provision-nats-aws.tf"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-pravega/deploy/provision-pravega-aws.tf"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-shared/deploy/${{ env.CLOUD_PROVIDER }}/provision-kafka-aws.tf"
- name: Apply Variables and Secrets for Streaming Provider
working-directory: driver-shared/deploy/${{ env.CLOUD_PROVIDER }}
## Set AK/SK and terraform s3 backend info
shell: bash
run: |
echo "current path is: $(pwd)"
sed -i "s/\${TF_BACKEND_BUCKET}/$TF_BACKEND_BUCKET/g" "provision-kafka-aws.tf"
sed -i "s/\${TF_BACKEND_KEY}/$TF_BACKEND_KEY-${{ env.CLOUD_PROVIDER }}-${{ env.STREAMING_PROVIDER }}/g" "provision-kafka-aws.tf"
sed -i "s/\${TF_BACKEND_REGION}/$REGION/g" "provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_ACCESS_KEY}/${{ secrets.AUTOMQ_ACCESS_KEY }}/g" "provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_SECRET_KEY}/${{ secrets.AUTOMQ_SECRET_KEY }}/g" "provision-kafka-aws.tf"
env:
## sed match only support ENV rather than expression like ${{ secrets.TF_BACKEND_BUCKET }}
TF_BACKEND_BUCKET: ${{ secrets.TF_BACKEND_BUCKET }}
TF_BACKEND_KEY: ${{ secrets.TF_BACKEND_KEY }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AUTOMQ_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AUTOMQ_SECRET_KEY }}
aws-region: ${{ inputs.region || 'cn-northwest-1' }}
- name: Setup SSH key
shell: bash
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/${{ env.STREAMING_PROVIDER }}_${{ env.CLOUD_PROVIDER }}
echo "${{ secrets.SSH_PUBLIC_KEY }}" > ~/.ssh/${{ env.STREAMING_PROVIDER }}_${{ env.CLOUD_PROVIDER }}.pub
chmod 600 ~/.ssh/${{ env.STREAMING_PROVIDER }}_${{ env.CLOUD_PROVIDER }}
chmod 644 ~/.ssh/${{ env.STREAMING_PROVIDER }}_${{ env.CLOUD_PROVIDER }}.pub
- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Setup Infra Cost
shell: bash
run: |
# Downloads the CLI based on your OS/arch and puts it in /usr/local/bin
curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh
infracost --version
infracost configure set api_key ${{ secrets.INFRA_COST_API_KEY }}
- name: AWS Cost Estimate
shell: bash
run: |
echo "[INFO] Provider is AutoMQ"
cd driver-shared/deploy/${{ env.CLOUD_PROVIDER }}
infracost breakdown --path . --usage-file infracost/${{ env.CLOUD_PROVIDER }}-medium-500m-6t.yml >> /tmp/aws-cost.txt
COST_DETAIL_FILE=/tmp/aws-cost.txt
cat $COST_DETAIL_FILE
- name: Execute Shared Steps
id: shared-automq
uses: ./.github/actions/prepare-vs-shared
with:
streaming_provider: automq
automq_access_key: ${{ secrets.AUTOMQ_ACCESS_KEY }}
automq_secret_key: ${{ secrets.AUTOMQ_SECRET_KEY }}
tf_backend_bucket: ${{ secrets.TF_BACKEND_BUCKET }}
tf_backend_key: ${{ secrets.TF_BACKEND_KEY }}-${{ inputs.cloud_provider || 'aws-cn' }}
region: ${{ inputs.region || 'cn-northwest-1' }}
cloud_provider: ${{ inputs.cloud_provider || 'aws-cn' }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
infra_cost_api_key: ${{ secrets.INFRA_COST_API_KEY }}
uninstall: ${{ inputs.uninstall || false }}
execute_benchmark: ${{ inputs.execute_benchmark || false }}
prepare_kafka_env:
environment: ${{ inputs.cloud_provider || 'aws-cn' }}
name: Prepare Kafka Environment
runs-on: ubuntu-latest
env:
STREAMING_PROVIDER: kafka
CLOUD_PROVIDER: ${{ inputs.cloud_provider || 'aws-cn' }}
REGION: ${{ inputs.region || 'cn-northwest-1' }}
outputs:
benchmark_result_json_kafka: ${{ steps.shared-kafka.outputs.benchmark_result_json_kafka }}
extracted_data_kafka: ${{ steps.shared-kafka.outputs.extracted_data_kafka }}
baseline_cost_kafka: ${{ steps.shared-kafka.outputs.baseline_cost_kafka }}
usage_cost_kafka: ${{ steps.shared-kafka.outputs.usage_cost_kafka }}
total_cost_kafka: ${{ steps.shared-kafka.outputs.total_cost_kafka }}
steps:
- name: Hello World
run: echo "Hello World"
- name: Checkout Benchmark Code
uses: actions/checkout@v3
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Composition action can't access secrets input, so we inline related step here
- name: Fetch Latest Data
shell: bash
run: |
git pull origin main
- name: Build Benchmark Code
shell: bash
run: |
mvn clean package -Dlicense.skip=true -Dcheckstyle.skip -DskipTests -Dspotless.check.skip
- name: Apply Variables and Secrets for Shared Files
shell: bash
run: |
echo "current path is: $(pwd)"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-nats/deploy/provision-nats-aws.tf"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-pravega/deploy/provision-pravega-aws.tf"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-shared/deploy/${{ env.CLOUD_PROVIDER }}/provision-kafka-aws.tf"
- name: Apply Variables and Secrets for Streaming Provider
working-directory: driver-shared/deploy/${{ env.CLOUD_PROVIDER }}
## Set AK/SK and terraform s3 backend info
shell: bash
run: |
echo "current path is: $(pwd)"
sed -i "s/\${TF_BACKEND_BUCKET}/$TF_BACKEND_BUCKET/g" "provision-kafka-aws.tf"
sed -i "s/\${TF_BACKEND_KEY}/$TF_BACKEND_KEY-${{ env.CLOUD_PROVIDER }}-${{ env.STREAMING_PROVIDER }}/g" "provision-kafka-aws.tf"
sed -i "s/\${TF_BACKEND_REGION}/$REGION/g" "provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_ACCESS_KEY}/${{ secrets.AUTOMQ_ACCESS_KEY }}/g" "provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_SECRET_KEY}/${{ secrets.AUTOMQ_SECRET_KEY }}/g" "provision-kafka-aws.tf"
env:
## sed match only support ENV rather than expression like ${{ secrets.TF_BACKEND_BUCKET }}
TF_BACKEND_BUCKET: ${{ secrets.TF_BACKEND_BUCKET }}
TF_BACKEND_KEY: ${{ secrets.TF_BACKEND_KEY }}
REGION: ${{ inputs.region || 'cn-northwest-1' }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AUTOMQ_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AUTOMQ_SECRET_KEY }}
aws-region: ${{ inputs.region || 'cn-northwest-1' }}
- name: Setup SSH key
shell: bash
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/${{ env.STREAMING_PROVIDER }}_${{ env.CLOUD_PROVIDER }}
echo "${{ secrets.SSH_PUBLIC_KEY }}" > ~/.ssh/${{ env.STREAMING_PROVIDER }}_${{ env.CLOUD_PROVIDER }}.pub
chmod 600 ~/.ssh/${{ env.STREAMING_PROVIDER }}_${{ env.CLOUD_PROVIDER }}
chmod 644 ~/.ssh/${{ env.STREAMING_PROVIDER }}_${{ env.CLOUD_PROVIDER }}.pub
- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Setup Infra Cost
shell: bash
run: |
# Downloads the CLI based on your OS/arch and puts it in /usr/local/bin
curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh
infracost --version
infracost configure set api_key ${{ secrets.INFRA_COST_API_KEY }}
- name: AWS Cost Estimate
shell: bash
run: |
echo "[INFO] Provider is AutoMQ"
cd driver-shared/deploy/${{ env.CLOUD_PROVIDER }}
infracost breakdown --path . --usage-file infracost/${{ env.CLOUD_PROVIDER }}-medium-500m-6t.yml >> /tmp/aws-cost.txt
COST_DETAIL_FILE=/tmp/aws-cost.txt
cat $COST_DETAIL_FILE
- name: Execute Shared Steps
id: shared-kafka
uses: ./.github/actions/prepare-vs-shared
with:
streaming_provider: kafka
automq_access_key: ${{ secrets.AUTOMQ_ACCESS_KEY }}
automq_secret_key: ${{ secrets.AUTOMQ_SECRET_KEY }}
tf_backend_bucket: ${{ secrets.TF_BACKEND_BUCKET }}
tf_backend_key: ${{ secrets.TF_BACKEND_KEY }}-${{ inputs.cloud_provider || 'aws-cn' }}
region: ${{ inputs.region || 'cn-northwest-1' }}
cloud_provider: ${{ inputs.cloud_provider || 'aws-cn' }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
infra_cost_api_key: ${{ secrets.INFRA_COST_API_KEY }}
uninstall: ${{ inputs.uninstall || false }}
execute_benchmark: ${{ inputs.execute_benchmark || false }}
generate_report:
name: Generate Report
runs-on: ubuntu-latest
needs: [ prepare_automq_env, prepare_kafka_env ]
steps:
- name: Checkout Benchmark Code
uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '20.12.2'
- name: Install dependencies
run: |
cd $GITHUB_WORKSPACE/workflow_scripts/js
npm install
##ref: https://stackoverflow.com/questions/77181212/use-composite-action-output-as-step-output
- name: Generate Report in Issue
if: ${{ inputs.execute_benchmark || false }}
env:
BASELINE_COST_AUTOMQ: ${{ needs.prepare_automq_env.outputs.baseline_cost_automq }}
USAGE_COST_AUTOMQ: ${{ needs.prepare_automq_env.outputs.usage_cost_automq }}
TOTAL_COST_AUTOMQ: ${{ needs.prepare_automq_env.outputs.total_cost_automq }}
BASELINE_COST_KAFKA: ${{ needs.prepare_kafka_env.outputs.baseline_cost_kafka }}
USAGE_COST_KAFKA: ${{ needs.prepare_kafka_env.outputs.usage_cost_kafka }}
TOTAL_COST_KAFKA: ${{ needs.prepare_kafka_env.outputs.total_cost_kafka }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY_NAME: ${{ github.repository }}
run: |
echo '${{ needs.prepare_automq_env.outputs.benchmark_result_json_automq }}' > $GITHUB_WORKSPACE/workflow_scripts/js/BENCHMARK_RESULT_AUTOMQ.info
echo '${{ needs.prepare_kafka_env.outputs.benchmark_result_json_kafka }}' > $GITHUB_WORKSPACE/workflow_scripts/js/BENCHMARK_RESULT_KAFKA.info
echo '${{ needs.prepare_automq_env.outputs.extracted_data_automq }}' > $GITHUB_WORKSPACE/workflow_scripts/js/EXTRACTED_DATA_AUTOMQ.info
echo '${{ needs.prepare_kafka_env.outputs.extracted_data_kafka }}' > $GITHUB_WORKSPACE/workflow_scripts/js/EXTRACTED_DATA_KAFKA.info
export WORKSPACE_HOME=$GITHUB_WORKSPACE
echo "BASELINE_COST_AUTOMQ: $BASELINE_COST_AUTOMQ"
echo "USAGE_COST_AUTOMQ: $USAGE_COST_AUTOMQ"
echo "TOTAL_COST_AUTOMQ: $TOTAL_COST_AUTOMQ"
echo "BASELINE_COST_KAFKA: $BASELINE_COST_KAFKA"
echo "USAGE_COST_KAFKA: $USAGE_COST_KAFKA"
echo "TOTAL_COST_KAFKA: $TOTAL_COST_KAFKA"
echo "GITHUB_TOKEN: [REDACTED]"
echo "GITHUB_REPOSITORY_NAME: $GITHUB_REPOSITORY_NAME"
cd $GITHUB_WORKSPACE/workflow_scripts/js
node $GITHUB_WORKSPACE/workflow_scripts/js/generate_report.js