File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { GitHubContext } from '../types'
22import { Report } from 'ctrf'
3+ import * as core from '@actions/core'
34
45/**
56 * Enriches the current CTRF report with details from the GitHub Actions context.
@@ -38,6 +39,32 @@ export function enrichCurrentReportWithRunDetails(
3839 return extendedReport
3940}
4041
42+ /**
43+ * Enriches a CTRF report with details from a GitHub Actions workflow run.
44+ *
45+ * @param report - The CTRF report to enrich.
46+ * @param run - The GitHub Actions workflow run details.
47+ * @returns The updated CTRF report with enriched run details.
48+ */
49+ export function enrichPreviousReportWithRunDetails (
50+ report : Report ,
51+ run : import ( '@octokit/openapi-types' ) . components [ 'schemas' ] [ 'workflow-run' ]
52+ ) : Report {
53+ const extendedReport = report
54+
55+ core . debug ( `enriching ${ run . id } / ${ run . html_url } ` )
56+
57+ extendedReport . results . environment = extendedReport . results . environment ?? { }
58+
59+ extendedReport . results . environment . buildId = run . id . toString ( )
60+ extendedReport . results . environment . buildNumber = run . run_number . toString ( )
61+ extendedReport . results . environment . buildUrl = run . html_url
62+ extendedReport . results . environment . buildName =
63+ run . name == null ? undefined : run . name
64+
65+ return extendedReport
66+ }
67+
4168/**
4269 * Removes the test.extra.durations property from each test if it exists.
4370 *
Original file line number Diff line number Diff line change 77} from '../client/github'
88import { isMatchingWorkflowRun } from '../github'
99import { Inputs , GitHubContext } from '../types'
10+ import { enrichPreviousReportWithRunDetails } from './enrichers'
1011import { enrichReportWithInsights } from 'ctrf'
1112import type { Report } from 'ctrf'
1213import { storePreviousResults } from './previous-results'
@@ -100,10 +101,9 @@ export async function processPreviousResultsAndMetrics(
100101 if ( isMatching ) {
101102 core . debug ( `Attempting to process artifacts for run ${ run . id } ` )
102103 try {
103- const artifacts = await processArtifactsFromRun (
104- run ,
105- inputs . artifactName
106- )
104+ const artifacts = (
105+ await processArtifactsFromRun ( run , inputs . artifactName )
106+ ) . map ( artifact => enrichPreviousReportWithRunDetails ( artifact , run ) )
107107 core . debug (
108108 `Retrieved ${ artifacts . length } artifacts from run ${ run . id } `
109109 )
You can’t perform that action at this time.
0 commit comments