Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .github/workflows/release-IPA-metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
console.error(error.message);
process.exit(1)
})
if (!shouldRunRelease) {
console.log('Skipping release')
}
return shouldRunRelease

release-IPA-metrics:
Expand All @@ -61,16 +64,16 @@ jobs:
- name: Install npm dependencies
run: npm install

- name: Download openapi-foas
uses: actions/download-artifact@v4
with:
name: openapi-foas-${{ inputs.env }}
github-token: ${{ secrets.api_bot_pat }}
run-id: ${{ github.run_id }}
# - name: Download openapi-foas
# uses: actions/download-artifact@v4
# with:
# name: openapi-foas-${{ inputs.env }}
# github-token: ${{ secrets.api_bot_pat }}
# run-id: ${{ github.run_id }}

- name: Run Metric Collection Job
working-directory: ./tools/spectral/ipa/metrics/scripts
run: node runMetricCollection.js ../../../../../openapi-foas.json
run: node runMetricCollection.js ../../../../../openapi/v2.json

- name: Dump Metric Collection Job Data to S3
env:
Expand Down
3 changes: 2 additions & 1 deletion tools/spectral/ipa/metrics/metricS3Upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@

try {
console.log('Creating S3 Client...');
const client = getS3Client();

Check failure on line 26 in tools/spectral/ipa/metrics/metricS3Upload.js

View workflow job for this annotation

GitHub Actions / lint

'client' is assigned a value but never used

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

const command = new PutObjectCommand({

Check failure on line 32 in tools/spectral/ipa/metrics/metricS3Upload.js

View workflow job for this annotation

GitHub Actions / lint

'command' is assigned a value but never used
Bucket: s3fileProps.bucketName,
Key: path.join(s3fileProps.key, formattedDate, 'metric-collection-results.parquet'),
Body: tableToIPC(table, 'stream'),
});

console.log('Dumping data to S3...');
return await client.send(command);
//return await client.send(command);
return 'testing';
} catch (caught) {
if (caught instanceof S3ServiceException && caught.name === 'EntityTooLarge') {
console.error(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,65 @@
// Used in .github/workflows/release-IPA-metrics.yml
// Checks if workflow failed or if job 'Release IPA Validation Metrics' didn't run today

const releaseJobName = 'Release IPA Validation Metrics';

export default async function getShouldRunMetricsRelease({ github, context }) {
const response = await github.rest.actions.listWorkflowRuns({
// Get last workflow run
const workflowRuns = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'release-IPA-metrics.yml',
per_page: 2,
page: 1,
});

if (!response || !response.data) {
if (!workflowRuns || !workflowRuns.data) {
throw Error('listWorkFlowRuns response is empty');
}

const { workflow_runs: runs } = response.data;
const { workflow_runs: runs } = workflowRuns.data;

if (!runs || runs.length === 0) {
throw Error('workflowRuns is empty');
}

const previousWorkflowRun = runs[1];

// Check if job 'Release IPA Validation Metrics' already ran today
const runJobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runs[1].id,
per_page: 2,
page: 1,
});

if (!runJobs || !runJobs.data) {
throw Error('listJobsForWorkflowRun response is empty');
}

const { jobs } = runJobs.data;

if (runs === undefined || runs.length === 0) {
throw Error('response.data.workflow_runs is empty');
if (!jobs || jobs.length === 0) {
throw Error('Jobs for workflow is empty');
}

const previousResult = runs[1].conclusion;
const previousReleaseJob = jobs.find((job) => job.name === releaseJobName);

const lastRunDate = new Date(runs[1].created_at);
if (!previousReleaseJob) {
throw Error('Could not find previous release job with name' + releaseJobName);
}

const lastRunDate = new Date(previousReleaseJob.completed_at);
const today = new Date();

return previousResult === 'failure' || today.toDateString() !== lastRunDate.toDateString();
//Remove
console.log('Previous workflow run created at', new Date(previousWorkflowRun.created_at));
console.log('Previous workflow run updated', new Date(previousWorkflowRun.updated_at));
console.log('Previous workflow run started at', new Date(previousWorkflowRun.run_started_at));

console.log('Last workflow run status was', previousWorkflowRun.conclusion);
console.log('Last release job run was', lastRunDate.toDateString(), 'with status', previousReleaseJob.conclusion);

return previousWorkflowRun.conclusion === 'failure' || today.toDateString() !== lastRunDate.toDateString();
}
Loading