Skip to content

Commit

Permalink
Add artifact input to action.yml + improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Feb 15, 2021
1 parent 3510d9a commit 075144b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion 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.

11 changes: 11 additions & 0 deletions src/input-providers/artifact-provider.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils'

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/utils/github-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]> {
Expand Down

0 comments on commit 075144b

Please sign in to comment.