1
0
Fork 0
mirror of https://github.com/dorny/test-reporter.git synced 2026-03-21 23:52:12 +01:00

Refactor code for changes in @actions/github v9

This commit is contained in:
Jozef Izso 2026-03-02 15:44:41 +01:00
parent 419ef42f63
commit 66bccdca48
Failed to extract signature
3 changed files with 15 additions and 6 deletions

View file

@ -1,6 +1,6 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as github from '@actions/github' import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils.js' import {GitHub} from '@actions/github/lib/utils'
import Zip from 'adm-zip' import Zip from 'adm-zip'
import picomatch from 'picomatch' import picomatch from 'picomatch'
@ -8,6 +8,11 @@ import picomatch from 'picomatch'
import {FileContent, InputProvider, ReportInput} from './input-provider.js' import {FileContent, InputProvider, ReportInput} from './input-provider.js'
import {downloadArtifact, listFiles} from '../utils/github-utils.js' import {downloadArtifact, listFiles} from '../utils/github-utils.js'
type WorkflowRunArtifact = {
id: number
name: string
}
export class ArtifactProvider implements InputProvider { export class ArtifactProvider implements InputProvider {
private readonly artifactNameMatch: (name: string) => boolean private readonly artifactNameMatch: (name: string) => boolean
private readonly fileNameMatch: (name: string) => boolean private readonly fileNameMatch: (name: string) => boolean
@ -50,10 +55,10 @@ export class ArtifactProvider implements InputProvider {
async load(): Promise<ReportInput> { async load(): Promise<ReportInput> {
const result: ReportInput = {} const result: ReportInput = {}
const allArtifacts = await this.octokit.paginate(this.octokit.rest.actions.listWorkflowRunArtifacts, { const allArtifacts = (await this.octokit.paginate(this.octokit.rest.actions.listWorkflowRunArtifacts, {
...github.context.repo, ...github.context.repo,
run_id: this.runId run_id: this.runId
}) })) as WorkflowRunArtifact[]
if (allArtifacts.length === 0) { if (allArtifacts.length === 0) {
core.warning(`No artifacts found in run ${this.runId}`) core.warning(`No artifacts found in run ${this.runId}`)

View file

@ -1,6 +1,6 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as github from '@actions/github' import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils.js' import {GitHub} from '@actions/github/lib/utils'
import {ArtifactProvider} from './input-providers/artifact-provider.js' import {ArtifactProvider} from './input-providers/artifact-provider.js'
import {LocalFileProvider} from './input-providers/local-file-provider.js' import {LocalFileProvider} from './input-providers/local-file-provider.js'

View file

@ -3,7 +3,7 @@ import {pipeline} from 'stream/promises'
import {Readable, Transform} from 'stream' import {Readable, Transform} from 'stream'
import * as core from '@actions/core' import * as core from '@actions/core'
import * as github from '@actions/github' import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils.js' import {GitHub} from '@actions/github/lib/utils'
import type {PullRequest, WorkflowRunEvent} from '@octokit/webhooks-types' import type {PullRequest, WorkflowRunEvent} from '@octokit/webhooks-types'
export function getCheckRunContext(): {sha: string; runId: number} { export function getCheckRunContext(): {sha: string; runId: number} {
@ -125,7 +125,11 @@ async function listGitTree(octokit: InstanceType<typeof GitHub>, sha: string, pa
if (tr.type === 'blob') { if (tr.type === 'blob') {
result.push(file) result.push(file)
} else if (tr.type === 'tree' && truncated) { } else if (tr.type === 'tree' && truncated) {
const files = await listGitTree(octokit, tr.sha as string, `${file}/`) if (!tr.sha) {
core.warning(`Skipping tree ${file}: missing SHA`)
continue
}
const files = await listGitTree(octokit, tr.sha, `${file}/`)
result.push(...files) result.push(...files)
} }
} }