-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Description For this special case of wanting to merge the current state of master into dev-upgrade-18 for the new rc6, we are taking a different approach. Step 1: Checkout new branch (mk/u18-merge) from master Step 2: Merge dev-upgrade-18 into mk/u18-merge Step 3: Manually resolve conflicts (Keep u18 suffixed @agoric/* deps and upgrade name changes to upgrade.go from dev-upgrade-18, rest from master) Step 4: Create a PR from mk/u18-merge to be merged back into dev-upgrade-18
- Loading branch information
Showing
685 changed files
with
57,689 additions
and
9,565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# also ignored in packages/cosmic-proto/.eslintignore, but IDE's pick up the root config | ||
packages/cosmic-proto/dist | ||
packages/cosmic-proto/node_modules/ | ||
packages/cosmic-proto/coverage/ | ||
packages/cosmic-proto/dist/ | ||
packages/cosmic-proto/proto/ | ||
packages/cosmic-proto/src/codegen/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#! /usr/bin/env node | ||
const fs = require('node:fs'); | ||
const process = require('node:process'); | ||
const { sendMetricsToGCP, makeTimeSeries } = require('./gcp-monitoring.cjs'); | ||
|
||
const resultFiles = process.argv.slice(2); | ||
|
||
const tapResultRegex = new RegExp( | ||
`(^(?<status>not )?ok (?<num>[0-9]+) - (?<name>.+?)(?: %ava-dur=(?<duration>[0-9]+)ms)?(?:# (?<comments>.+?))?$(?<output>(\n^#.+?$)*)(?<failure>(\n^(?:(?!(?:not|ok) ))[^\n\r]+?$)*))`, | ||
'gms', | ||
); | ||
let timeSeriesData = []; | ||
|
||
function processTAP(packageName, tapbody) { | ||
let m; | ||
const returnValue = []; | ||
// eslint-disable-next-line no-cond-assign | ||
while ((m = tapResultRegex.exec(tapbody))) { | ||
if (m.groups.name) { | ||
const testCaseName = `${m.groups.name}`.replace(/["<>]/g, '').trim(); | ||
|
||
let skipped = false; | ||
let succeeded = true; | ||
let todo = false; | ||
if (m.groups.status) { | ||
succeeded = false; | ||
} | ||
if (m.groups.comments) { | ||
if (m.groups.comments.match(/SKIP/gi)) { | ||
skipped = true; | ||
} | ||
if (m.groups.comments.match(/TODO/gi)) { | ||
todo = true; | ||
skipped = true; | ||
succeeded = true; | ||
} | ||
} | ||
returnValue.push({ | ||
labels: { | ||
test_name: testCaseName, | ||
package: packageName, | ||
test_status: | ||
succeeded && !(todo || skipped) | ||
? 'succeeded' | ||
: !succeeded | ||
? 'failed' | ||
: 'skipped', | ||
}, | ||
value: Number(succeeded && !(todo || skipped)), | ||
}); | ||
} | ||
} | ||
return returnValue; | ||
} | ||
|
||
for (const file of resultFiles) { | ||
const resultsBody = fs.readFileSync(file, 'utf-8'); | ||
const packageName = file.split('/').at(-2); | ||
|
||
const response = processTAP(packageName, resultsBody); | ||
timeSeriesData.push(...response); | ||
} | ||
|
||
const timeSeries = makeTimeSeries(timeSeriesData); | ||
sendMetricsToGCP(timeSeries); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
const Monitoring = require('@google-cloud/monitoring'); | ||
|
||
const gcpCredentials = JSON.parse(process.env.GCP_CREDENTIALS); | ||
const monitoring = new Monitoring.MetricServiceClient({ | ||
projectId: gcpCredentials.project_id, | ||
credentials: { | ||
client_email: gcpCredentials.client_email, | ||
private_key: gcpCredentials.private_key, | ||
}, | ||
}); | ||
|
||
async function sendMetricsToGCP(metricType, metricValue, labels) { | ||
const projectId = gcpCredentials.project_id; | ||
|
||
const request = { | ||
name: monitoring.projectPath(projectId), | ||
timeSeries: [ | ||
{ | ||
metric: { | ||
type: `custom.googleapis.com/github/${metricType}`, | ||
labels: labels, | ||
}, | ||
resource: { | ||
type: 'global', | ||
labels: { | ||
project_id: projectId, | ||
}, | ||
}, | ||
points: [ | ||
{ | ||
interval: { | ||
endTime: { | ||
seconds: Math.floor(Date.now() / 1000), | ||
}, | ||
}, | ||
value: { | ||
doubleValue: metricValue, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
try { | ||
await monitoring.createTimeSeries(request); | ||
console.log(`Metric ${metricType} sent successfully.`); | ||
} catch (error) { | ||
console.error('Error sending metric:', error); | ||
} | ||
} | ||
|
||
// Function to fetch workflow and job details via GitHub API | ||
async function fetchWorkflowDetails() { | ||
const runId = process.argv[2]; | ||
const repo = process.env.GITHUB_REPOSITORY; | ||
const apiUrl = `https://api.github.com/repos/${repo}/actions/runs/${runId}`; | ||
|
||
try { | ||
const response = await fetch(apiUrl, { | ||
headers: { | ||
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`, | ||
Accept: 'application/vnd.github.v3+json', | ||
}, | ||
}); | ||
|
||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); | ||
const data = await response.json(); | ||
|
||
return { | ||
workflowId: data.id, | ||
workflowName: data.name, | ||
status: data.status, // "completed", "in_progress", etc. | ||
conclusion: data.conclusion, // "success", "failure" | ||
startTime: data.created_at, | ||
endTime: data.updated_at, | ||
trigger: data.event, // "push", "pull_request", etc. | ||
jobs: await fetchJobDetails(repo, data.id), // Fetch individual job details | ||
}; | ||
} catch (error) { | ||
console.error('Error fetching workflow details:', error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
async function fetchJobDetails(repo, runId) { | ||
const apiUrl = `https://api.github.com/repos/${repo}/actions/runs/${runId}/jobs`; | ||
|
||
try { | ||
const response = await fetch(apiUrl, { | ||
headers: { | ||
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`, | ||
Accept: 'application/vnd.github.v3+json', | ||
}, | ||
}); | ||
|
||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); | ||
const data = await response.json(); | ||
return data.jobs; | ||
} catch (error) { | ||
console.error('Error fetching job details:', error); | ||
return []; | ||
} | ||
} | ||
|
||
// Main function to send metrics | ||
(async () => { | ||
try { | ||
const workflowStats = await fetchWorkflowDetails(); | ||
|
||
const workflowLabels = { | ||
workflow_name: workflowStats.workflowName, | ||
workflow_id: workflowStats.workflowId, | ||
trigger: workflowStats.trigger, | ||
}; | ||
|
||
const workflowDuration = | ||
(new Date(workflowStats.endTime) - new Date(workflowStats.startTime)) / | ||
1000; | ||
await sendMetricsToGCP( | ||
'ci_workflow_duration', | ||
workflowDuration, | ||
workflowLabels, | ||
); | ||
|
||
for (const job of workflowStats.jobs) { | ||
const jobLabels = { | ||
workflow_name: workflowStats.workflowName, | ||
job_name: job.name, | ||
runner_name: job.runner_name, | ||
conclusion: job.conclusion, | ||
}; | ||
|
||
const jobExecutionTime = | ||
(new Date(job.completed_at) - new Date(job.started_at)) / 1000; | ||
await sendMetricsToGCP( | ||
'ci_job_execution_time', | ||
jobExecutionTime, | ||
jobLabels, | ||
); | ||
|
||
// Send job status (1 for success, 0 for failure) | ||
const jobStatus = job.conclusion === 'success' ? 1 : 0; | ||
await sendMetricsToGCP('ci_job_status', jobStatus, jobLabels); | ||
|
||
// Capture step-level metrics for step details per job | ||
for (const step of job.steps) { | ||
const stepExecutionTime = | ||
(new Date(step.completed_at) - new Date(step.started_at)) / 1000; | ||
const stepLabels = { | ||
workflow_name: workflowStats.workflowName, | ||
job_name: job.name, | ||
step_name: step.name, | ||
runner_name: job.runner_name, | ||
}; | ||
|
||
await sendMetricsToGCP( | ||
'ci_step_execution_time', | ||
stepExecutionTime, | ||
stepLabels, | ||
); | ||
} | ||
} | ||
} catch (error) { | ||
console.error('Error in main function:', error); | ||
process.exit(1); | ||
} | ||
|
||
process.exit(0); | ||
})(); |
Oops, something went wrong.