Skip to content
Open
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
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 56 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/ctrf/enrichers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GitHubContext } from '../types'
import { Report } from 'ctrf'
import * as core from '@actions/core'

/**
* Enriches the current CTRF report with details from the GitHub Actions context.
Expand Down Expand Up @@ -38,6 +39,32 @@ export function enrichCurrentReportWithRunDetails(
return extendedReport
}

/**
* Enriches a CTRF report with details from a GitHub Actions workflow run.
*
* @param report - The CTRF report to enrich.
* @param run - The GitHub Actions workflow run details.
* @returns The updated CTRF report with enriched run details.
*/
export function enrichPreviousReportWithRunDetails(
report: Report,
run: import('@octokit/openapi-types').components['schemas']['workflow-run']
): Report {
const extendedReport = report

core.debug(`enriching ${run.id} / ${run.html_url}`)

extendedReport.results.environment = extendedReport.results.environment ?? {}

extendedReport.results.environment.buildId = run.id.toString()
extendedReport.results.environment.buildNumber = run.run_number.toString()
extendedReport.results.environment.buildUrl = run.html_url
extendedReport.results.environment.buildName =
run.name == null ? undefined : run.name

return extendedReport
}

/**
* Removes the test.extra.durations property from each test if it exists.
*
Expand Down
8 changes: 4 additions & 4 deletions src/ctrf/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '../client/github'
import { isMatchingWorkflowRun } from '../github'
import { Inputs, GitHubContext } from '../types'
import { enrichPreviousReportWithRunDetails } from './enrichers'
import { enrichReportWithInsights } from 'ctrf'
import type { Report } from 'ctrf'
import { storePreviousResults } from './previous-results'
Expand Down Expand Up @@ -100,10 +101,9 @@ export async function processPreviousResultsAndMetrics(
if (isMatching) {
core.debug(`Attempting to process artifacts for run ${run.id}`)
try {
const artifacts = await processArtifactsFromRun(
run,
inputs.artifactName
)
const artifacts = (
await processArtifactsFromRun(run, inputs.artifactName)
).map(artifact => enrichPreviousReportWithRunDetails(artifact, run))
core.debug(
`Retrieved ${artifacts.length} artifacts from run ${run.id}`
)
Expand Down
Loading