Skip to content

Commit

Permalink
Add SHA property
Browse files Browse the repository at this point in the history
Implements NasAmin#191
  • Loading branch information
flcdrg committed Aug 12, 2021
1 parent cc601b1 commit 5fd3b5f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ branding:
color: 'green'
inputs:
TRX_PATH:
description: 'Path to the directory cntaining trx files'
description: 'Path to the directory containing trx files'
required: true
REPO_TOKEN:
description: 'Pass in the repository token. This should be generally be secrets.GITHUB_TOKEN. This is used for GitHub checks api'
Expand All @@ -15,6 +15,9 @@ inputs:
description: 'Set to true if you want test failures not to block the pull requests. The check status will be set to neutral'
required: false
default: 'false'
SHA:
description: 'SHA value to use. If not set then will be calculated based on context'
required: false
outputs:
test-outcome:
description: 'Test outcome Failed/Passed'
Expand Down
9 changes: 7 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.

8 changes: 7 additions & 1 deletion src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {getMarkupForTrx} from './markup'
export async function createCheckRun(
repoToken: string,
ignoreTestFailures: boolean,
reportData: TrxDataWrapper
reportData: TrxDataWrapper,
sha?: string
): Promise<void> {
try {
core.info(`Creating PR check for ${reportData.ReportMetaData.ReportTitle}`)
Expand All @@ -28,6 +29,11 @@ export async function createCheckRun(
)
}

if (sha) {
git_sha = sha
core.info(`Creating status check for user-provided GitSha: ${git_sha}`)
}

const markupData = getMarkupForTrx(reportData)
const checkTime = new Date().toUTCString()
core.info(`Check time is: ${checkTime}`)
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export async function run(): Promise<void> {
const trxPath = core.getInput('TRX_PATH')
const ignoreTestFailures: boolean =
core.getInput('IGNORE_FAILURE', {required: false}) === 'true'
const sha = core.getInput('SHA')
core.info(`Finding Trx files in: ${trxPath}`)
const trxFiles = await getTrxFiles(trxPath)

Expand All @@ -22,7 +23,7 @@ export async function run(): Promise<void> {
const failingTestsFound = areThereAnyFailingTests(trxToJson)

for (const data of trxToJson) {
await createCheckRun(token, ignoreTestFailures, data)
await createCheckRun(token, ignoreTestFailures, data, sha)
}

if (failingTestsFound) {
Expand Down

0 comments on commit 5fd3b5f

Please sign in to comment.