mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 06:17:10 +01:00
Merge pull request #604 from dorny/feature/603_improve_code_quality
This commit is contained in:
commit
5456de96b0
2 changed files with 10 additions and 9 deletions
6
dist/index.js
generated
vendored
6
dist/index.js
generated
vendored
|
|
@ -2439,11 +2439,11 @@ async function downloadArtifact(octokit, artifactId, fileName, token) {
|
||||||
};
|
};
|
||||||
const downloadStream = got_1.default.stream(req.url, { headers });
|
const downloadStream = got_1.default.stream(req.url, { headers });
|
||||||
const fileWriterStream = (0, fs_1.createWriteStream)(fileName);
|
const fileWriterStream = (0, fs_1.createWriteStream)(fileName);
|
||||||
downloadStream.on('redirect', response => {
|
downloadStream.on('redirect', (response) => {
|
||||||
core.info(`Downloading ${response.headers.location}`);
|
core.info(`Downloading ${response.headers.location}`);
|
||||||
});
|
});
|
||||||
downloadStream.on('downloadProgress', ({ transferred }) => {
|
downloadStream.on('downloadProgress', (progress) => {
|
||||||
core.info(`Progress: ${transferred} B`);
|
core.info(`Progress: ${progress.transferred} B`);
|
||||||
});
|
});
|
||||||
await asyncStream(downloadStream, fileWriterStream);
|
await asyncStream(downloadStream, fileWriterStream);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,17 @@ import {createWriteStream} from 'fs'
|
||||||
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'
|
import {GitHub} from '@actions/github/lib/utils'
|
||||||
import type {PullRequest} from '@octokit/webhooks-types'
|
import type {PullRequest, WorkflowRunEvent} from '@octokit/webhooks-types'
|
||||||
|
import {IncomingMessage} from 'http'
|
||||||
import * as stream from 'stream'
|
import * as stream from 'stream'
|
||||||
import {promisify} from 'util'
|
import {promisify} from 'util'
|
||||||
import got from 'got'
|
import got, {Progress} from 'got'
|
||||||
const asyncStream = promisify(stream.pipeline)
|
const asyncStream = promisify(stream.pipeline)
|
||||||
|
|
||||||
export function getCheckRunContext(): {sha: string; runId: number} {
|
export function getCheckRunContext(): {sha: string; runId: number} {
|
||||||
if (github.context.eventName === 'workflow_run') {
|
if (github.context.eventName === 'workflow_run') {
|
||||||
core.info('Action was triggered by workflow_run: using SHA and RUN_ID from triggering workflow')
|
core.info('Action was triggered by workflow_run: using SHA and RUN_ID from triggering workflow')
|
||||||
const event = github.context.payload
|
const event = github.context.payload as WorkflowRunEvent
|
||||||
if (!event.workflow_run) {
|
if (!event.workflow_run) {
|
||||||
throw new Error("Event of type 'workflow_run' is missing 'workflow_run' field")
|
throw new Error("Event of type 'workflow_run' is missing 'workflow_run' field")
|
||||||
}
|
}
|
||||||
|
|
@ -54,11 +55,11 @@ export async function downloadArtifact(
|
||||||
const downloadStream = got.stream(req.url, {headers})
|
const downloadStream = got.stream(req.url, {headers})
|
||||||
const fileWriterStream = createWriteStream(fileName)
|
const fileWriterStream = createWriteStream(fileName)
|
||||||
|
|
||||||
downloadStream.on('redirect', response => {
|
downloadStream.on('redirect', (response: IncomingMessage) => {
|
||||||
core.info(`Downloading ${response.headers.location}`)
|
core.info(`Downloading ${response.headers.location}`)
|
||||||
})
|
})
|
||||||
downloadStream.on('downloadProgress', ({transferred}) => {
|
downloadStream.on('downloadProgress', (progress: Progress) => {
|
||||||
core.info(`Progress: ${transferred} B`)
|
core.info(`Progress: ${progress.transferred} B`)
|
||||||
})
|
})
|
||||||
|
|
||||||
await asyncStream(downloadStream, fileWriterStream)
|
await asyncStream(downloadStream, fileWriterStream)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue