Add artifact input to action.yml + improve logging

This commit is contained in:
Michal Dorner 2021-02-15 15:54:15 +01:00
parent 3510d9ac27
commit 075144b122
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
5 changed files with 30 additions and 3 deletions

View file

@ -3,6 +3,9 @@ description: |
Displays test results directly in GitHub. Supports .NET (xUnit, NUnit, MSTest), Dart, Flutter and JavaScript (JEST).
author: Michal Dorner <dorner.michal@gmail.com>
inputs:
artifact:
description: Name or regex of artifact containing test results
required: false
name:
description: Name of the check run
required: true

13
dist/index.js generated vendored
View file

@ -31,6 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ArtifactProvider = void 0;
const core = __importStar(__nccwpck_require__(2186));
const github = __importStar(__nccwpck_require__(5438));
const adm_zip_1 = __importDefault(__nccwpck_require__(6761));
const picomatch_1 = __importDefault(__nccwpck_require__(8569));
@ -70,7 +71,15 @@ class ArtifactProvider {
...github.context.repo,
run_id: this.runId
});
if (resp.data.artifacts.length === 0) {
core.warning(`No artifacts found in run ${this.runId}`);
return {};
}
const artifacts = resp.data.artifacts.filter(a => this.artifactNameMatch(a.name));
if (artifacts.length === 0) {
core.warning(`No artifact matches ${this.artifact}`);
return {};
}
for (const art of artifacts) {
await github_utils_1.downloadArtifact(this.octokit, art.id, art.name);
const reportName = this.getReportName(art.name);
@ -1388,7 +1397,9 @@ async function listFiles(octokit, sha) {
commit_sha: sha,
...github.context.repo
});
return await listGitTree(octokit, commit.data.tree.sha, '');
const files = await listGitTree(octokit, commit.data.tree.sha, '');
core.info(`Found ${files.length} files tracked by GitHub in commit ${sha}`);
return files;
}
exports.listFiles = listFiles;
async function listGitTree(octokit, sha, path) {

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,4 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils'
@ -50,7 +51,17 @@ export class ArtifactProvider implements InputProvider {
run_id: this.runId
})
if (resp.data.artifacts.length === 0) {
core.warning(`No artifacts found in run ${this.runId}`)
return {}
}
const artifacts = resp.data.artifacts.filter(a => this.artifactNameMatch(a.name))
if (artifacts.length === 0) {
core.warning(`No artifact matches ${this.artifact}`)
return {}
}
for (const art of artifacts) {
await downloadArtifact(this.octokit, art.id, art.name)
const reportName = this.getReportName(art.name)

View file

@ -68,7 +68,9 @@ export async function listFiles(octokit: InstanceType<typeof GitHub>, sha: strin
commit_sha: sha,
...github.context.repo
})
return await listGitTree(octokit, commit.data.tree.sha, '')
const files = await listGitTree(octokit, commit.data.tree.sha, '')
core.info(`Found ${files.length} files tracked by GitHub in commit ${sha}`)
return files
}
async function listGitTree(octokit: InstanceType<typeof GitHub>, sha: string, path: string): Promise<string[]> {