-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
appveyor-tests.service.js
110 lines (102 loc) · 2.39 KB
/
appveyor-tests.service.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import {
testResultQueryParamSchema,
testResultOpenApiQueryParams,
renderTestResultBadge,
documentation as description,
} from '../test-results.js'
import { pathParams } from '../index.js'
import AppVeyorBase from './appveyor-base.js'
export default class AppVeyorTests extends AppVeyorBase {
static category = 'test-results'
static route = {
...this.buildRoute('appveyor/tests'),
queryParamSchema: testResultQueryParamSchema,
}
static openApi = {
'/appveyor/tests/{user}/{repo}': {
get: {
summary: 'AppVeyor tests',
description,
parameters: [
...pathParams(
{ name: 'user', example: 'NZSmartie' },
{ name: 'repo', example: 'coap-net-iu0to' },
),
...testResultOpenApiQueryParams,
],
},
},
'/appveyor/tests/{user}/{repo}/{branch}': {
get: {
summary: 'AppVeyor tests (with branch)',
description,
parameters: [
...pathParams(
{ name: 'user', example: 'NZSmartie' },
{ name: 'repo', example: 'coap-net-iu0to' },
{ name: 'branch', example: 'master' },
),
...testResultOpenApiQueryParams,
],
},
},
}
static defaultBadgeData = {
label: 'tests',
}
static render({
passed,
failed,
skipped,
total,
passedLabel,
failedLabel,
skippedLabel,
isCompact,
}) {
return renderTestResultBadge({
passed,
failed,
skipped,
total,
passedLabel,
failedLabel,
skippedLabel,
isCompact,
})
}
async handle(
{ user, repo, branch },
{
compact_message: compactMessage,
passed_label: passedLabel,
failed_label: failedLabel,
skipped_label: skippedLabel,
},
) {
const isCompact = compactMessage !== undefined
const data = await this.fetch({ user, repo, branch })
if (!('build' in data)) {
return { message: 'no builds found' }
}
let total = 0
let passed = 0
let failed = 0
data.build.jobs.forEach(job => {
total += job.testsCount
passed += job.passedTestsCount
failed += job.failedTestsCount
})
const skipped = total - passed - failed
return this.constructor.render({
passed,
failed,
skipped,
total,
passedLabel,
failedLabel,
skippedLabel,
isCompact,
})
}
}