Skip to content

Commit

Permalink
feat: Add test status columns
Browse files Browse the repository at this point in the history
  • Loading branch information
Kesin11 committed Jul 18, 2020
1 parent 2c9bc3e commit 528bc59
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/analyzer/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { round } from "lodash"
import { TestSuites } from 'junit2json'

export type Status = 'SUCCESS' | 'FAILURE' | 'ABORTED' | 'OTHER'
export type TestStatus = 'SUCCESS' | 'FAILURE'

export type WorkflowReport = {
service: string
Expand Down Expand Up @@ -58,6 +59,8 @@ export type TestReport = {
buildNumber: number
workflowName: string
testSuites: TestSuites
status: TestStatus // = testSuites.failures > 0: 'FAILURE', else: 'SUCCESS'
successCount: 0 | 1 // = testSuites.failures > 0: 1, else: 1. For create average success rate in dashboard
}

export type WorkflowParams = {
Expand Down
15 changes: 9 additions & 6 deletions src/analyzer/circleci_analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,21 @@ export class CircleciAnalyzer implements Analyzer {

if (testSuiteList.length === 0 ) return []

return [{
workflowId,
workflowRunId,
buildNumber,
workflowName,
testSuites: {
const testSuites = {
name: workflowName,
time: secRound(sumBy(testSuiteList, 'time')),
tests: sumBy(testSuiteList, 'tests'),
failures: sumBy(testSuiteList, 'failures'),
testsuite: testSuiteList,
}
return [{
workflowId,
workflowRunId,
buildNumber,
workflowName,
testSuites,
status: (testSuites.failures > 0) ? 'FAILURE' : 'SUCCESS',
successCount: (testSuites.failures > 0) ? 0 : 1,
}]
}
}
2 changes: 2 additions & 0 deletions src/analyzer/github_analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ export class GithubAnalyzer implements Analyzer {
buildNumber,
workflowName,
testSuites,
status: (testSuites.failures && testSuites.failures > 0) ? 'FAILURE' : 'SUCCESS',
successCount: (testSuites.failures && testSuites.failures > 0) ? 0 : 1,
})
} catch (error) {
console.error(`Error: Could not parse as JUnit XML. ${artifact.path}`)
Expand Down
2 changes: 2 additions & 0 deletions src/analyzer/jenkins_analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ export class JenkinsAnalyzer implements Analyzer {
buildNumber,
workflowName,
testSuites,
status: (testSuites.failures && testSuites.failures > 0) ? 'FAILURE' : 'SUCCESS',
successCount: (testSuites.failures && testSuites.failures > 0) ? 0 : 1,
})
} catch (error) {
console.error(`Error: Could not parse as JUnit XML. ${artifact.path}`)
Expand Down

0 comments on commit 528bc59

Please sign in to comment.