Skip to content

Commit 2283bc7

Browse files
committed
Send Daily Test Data to Cloudwatch Metrics
1 parent 351978c commit 2283bc7

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

.github/workflows/browser-compatibility-test-previous-major-version.yml

+27
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ env:
1414
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}}
1515
MESSAGING_USER_ARN: ${{secrets.MESSAGING_USER_ARN}}
1616
PRE_RUN_SCRIPT_URL: ${{secrets.PRE_RUN_SCRIPT_URL}}
17+
METRIC_NAME: ${{ secrets.METRIC_NAME }}
18+
METRIC_NAMESPACE: ${{ secrets.METRIC_NAMESPACE }}
1719

1820
permissions:
1921
id-token: write # This is required for requesting the JWT
@@ -309,3 +311,28 @@ jobs:
309311
run: npm install axios
310312
- name: Send Slack Message
311313
run: node .github/script/send-test-report.js ${{ secrets.SLACK_JS_SDK_DEV_CORE_PREV_VER_WEBHOOK }} ${{ env.WORKFLOW_URL}} ${{ env.WORKFLOW_JOBS_STATUS }}
314+
- name: Send Metric to CloudWatch
315+
if: always()
316+
run: |
317+
node -e "
318+
const { CloudWatchClient, PutMetricDataCommand } = require('@aws-sdk/client-cloudwatch');
319+
const client = new CloudWatchClient({ region: process.env.REGION });
320+
321+
const value = '${{ env.WORKFLOW_JOBS_STATUS }}' === 'failure' ? 0 : 1;
322+
323+
const command = new PutMetricDataCommand({
324+
Namespace: process.env.METRIC_NAMESPACE,
325+
MetricData: [{
326+
MetricName: process.env.METRIC_NAME,
327+
Dimensions: [
328+
{ Name: 'Platform', Value: 'JS SDK Daily PMV Compatibility' }
329+
],
330+
Value: value,
331+
}]
332+
});
333+
334+
client.send(command).then(() => console.log('Daily test result sent to CloudWatch')).catch(err => {
335+
console.error('Failed to send metric. Error: ', err);
336+
process.exit(1);
337+
});
338+
";

.github/workflows/browser-compatibility-test.yml

+27
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ env:
1515
MESSAGING_USER_ARN: ${{secrets.MESSAGING_USER_ARN}}
1616
SLACK_JS_SDK_DEV_CORE_WEBHOOK: ${{secrets.SLACK_JS_SDK_DEV_CORE_WEBHOOK}}
1717
PRE_RUN_SCRIPT_URL: ${{secrets.PRE_RUN_SCRIPT_URL}}
18+
METRIC_NAME: ${{ secrets.METRIC_NAME }}
19+
METRIC_NAMESPACE: ${{ secrets.METRIC_NAMESPACE }}
1820

1921
permissions:
2022
id-token: write # This is required for requesting the JWT
@@ -282,3 +284,28 @@ jobs:
282284
run: npm install axios
283285
- name: Send Slack Message
284286
run: node .github/script/send-test-report.js ${{ secrets.SLACK_JS_SDK_DEV_CORE_WEBHOOK }} ${{ env.WORKFLOW_URL}} ${{ env.WORKFLOW_JOBS_STATUS }}
287+
- name: Send Metric to CloudWatch
288+
if: always()
289+
run: |
290+
node -e "
291+
const { CloudWatchClient, PutMetricDataCommand } = require('@aws-sdk/client-cloudwatch');
292+
const client = new CloudWatchClient({ region: process.env.REGION });
293+
294+
const value = '${{ env.WORKFLOW_JOBS_STATUS }}' === 'failure' ? 0 : 1;
295+
296+
const command = new PutMetricDataCommand({
297+
Namespace: process.env.METRIC_NAMESPACE,
298+
MetricData: [{
299+
MetricName: process.env.METRIC_NAME,
300+
Dimensions: [
301+
{ Name: 'Platform', Value: 'JS SDK Daily Compatibility' }
302+
],
303+
Value: value,
304+
}]
305+
});
306+
307+
client.send(command).then(() => console.log('Daily test result sent to CloudWatch')).catch(err => {
308+
console.error('Failed to send metric. Error: ', err);
309+
process.exit(1);
310+
});
311+
";

0 commit comments

Comments
 (0)