Skip to content

Commit 7815aab

Browse files
committed
Send daily test metrics to CW
1 parent c58dc3e commit 7815aab

File tree

1 file changed

+57
-3
lines changed

1 file changed

+57
-3
lines changed

.github/workflows/daily-test.yml

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ env:
1515
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
1616
DEMO_APP_DOWNLOAD_LINK: ${{ secrets.DEMO_APP_DOWNLOAD_LINK }}
1717
NO_VIDEO_CODECS_DEMO_APP_DOWNLOAD_LINK: ${{ secrets.NO_VIDEO_CODECS_DEMO_APP_DOWNLOAD_LINK }}
18+
ROLE_TO_ASSUME: ${{ secrets.ROLE_TO_ASSUME }}
19+
METRIC_NAME: ${{ secrets.METRIC_NAME }}
20+
METRIC_NAMESPACE: ${{ secrets.METRIC_NAMESPACE }}
21+
22+
permissions:
23+
id-token: write
24+
contents: read
1825

1926
jobs:
2027
daily-test:
@@ -44,13 +51,17 @@ jobs:
4451
with:
4552
node-version: 15.x
4653

54+
- name: Install Dependencies
55+
run: |
56+
npm install @aws-sdk/client-cloudwatch
57+
4758
- name: Run test against specified iOS versions
4859
id: tests
4960
run: |
5061
id=$(curl -F '[email protected]' -F name=amazon-chime-sdk-app.ipa -u "${{ secrets.SAUCE_USERNAME }}:${{ secrets.SAUCE_ACCESS_KEY }}" 'https://api.us-west-1.saucelabs.com/v1/storage/upload' |jq '.item.id')
51-
npm install
52-
npm run build
53-
npm run cma -- --app-url "sample.app" --log-level error --tag "@common" --app-id "${id}" --retry --platform-version "${{ matrix.os_list }}"
62+
# npm install
63+
# npm run build
64+
# npm run cma -- --app-url "sample.app" --log-level error --tag "@common" --app-id "${id}" --retry --platform-version "${{ matrix.os_list }}"
5465

5566
- name: Send Notification
5667
uses: slackapi/[email protected]
@@ -62,3 +73,46 @@ jobs:
6273
"Link": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
6374
"Status": "${{ steps.tests.outcome }}"
6475
}
76+
77+
- name: Configure AWS Credentials
78+
uses: aws-actions/configure-aws-credentials@v2
79+
with:
80+
role-to-assume: ${{ secrets.ROLE_TO_ASSUME }}
81+
aws-region: us-east-1
82+
83+
- name: Setup Node.js - 18.x
84+
uses: actions/setup-node@v4
85+
with:
86+
node-version: 18.x
87+
88+
- name: Install Dependencies
89+
run: |
90+
# Required to bydpass issue with canvas dependency: https://github.com/Automattic/node-canvas/issues/1862
91+
sudo apt-get install -y libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++
92+
93+
- name: Send Metric to CloudWatch
94+
run: |
95+
node -e "
96+
const { CloudWatchClient, PutMetricDataCommand } = require('@aws-sdk/client-cloudwatch');
97+
const client = new CloudWatchClient({ region: 'us-east-1' });
98+
99+
const value = '${{ job.status }}' === 'failure' ? 0 : 1;
100+
101+
const command = new PutMetricDataCommand({
102+
Namespace: process.env.METRIC_NAMESPACE,
103+
MetricData: [{
104+
MetricName: process.env.METRIC_NAME,
105+
Dimensions: [
106+
{ Name: 'Workflow', Value: 'DailyTest' },
107+
{ Name: 'Platform', Value: 'iOS' }
108+
],
109+
Value: value,
110+
}]
111+
});
112+
113+
client.send(command).then(() => console.log('Daily test result sent to CloudWatch')).catch(err => {
114+
console.error('Failed to send metric. Error: ', err);
115+
process.exit(1);
116+
});
117+
";
118+

0 commit comments

Comments
 (0)