Skip to content

Commit e35631b

Browse files
CLOUDP-290416: Refactor and clean up
1 parent 026a012 commit e35631b

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

.github/workflows/release-IPA-metrics.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ jobs:
4343
github-token: ${{ secrets.api_bot_pat }}
4444
script: |
4545
const { default: getShouldRunMetricsRelease } = await import('${{ github.workspace }}/tools/spectral/ipa/metrics/scripts/getShouldRunMetricsRelease.js')
46-
const shouldRunRelease = await getShouldRunMetricsRelease({github, context})
46+
const shouldRunRelease = await getShouldRunMetricsRelease({github, context}).catch((error) => {
47+
console.error(error.message);
48+
process.exit(1)
49+
})
4750
return shouldRunRelease
4851
4952
release-IPA-metrics:

tools/spectral/ipa/metrics/metricS3Upload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export async function uploadMetricCollectionDataToS3(filePath = config.defaultMe
2424
try {
2525
console.log('Creating S3 Client...');
2626
const client = getS3Client();
27-
const formattedDate = new Date().toISOString().split('T')[0];
2827

2928
console.log('Getting S3 file path...');
3029
const s3fileProps = getS3FilePath();
30+
const formattedDate = new Date().toISOString().split('T')[0];
3131

3232
const command = new PutObjectCommand({
3333
Bucket: s3fileProps.bucketName,

tools/spectral/ipa/metrics/scripts/getShouldRunMetricsRelease.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,16 @@ export default async function getShouldRunMetricsRelease({ github, context }) {
88
page: 1,
99
});
1010

11-
if (response === undefined || response.data === undefined) {
12-
return true;
11+
if (!response || !response.data) {
12+
throw Error('listWorkFlowRuns response is empty');
1313
}
1414

1515
const { workflow_runs: runs } = response.data;
1616

17-
console.log('Runs:', runs);
18-
1917
if (runs === undefined || runs.length === 0) {
20-
return true;
18+
throw Error('response.data.workflow_runs is empty');
2119
}
2220

23-
console.log('Last run:', runs[1]);
24-
2521
const previousResult = runs[1].conclusion;
2622

2723
const lastRunDate = new Date(runs[1].created_at);

0 commit comments

Comments
 (0)