-
Notifications
You must be signed in to change notification settings - Fork 83
/
regressed.go
66 lines (56 loc) · 1.71 KB
/
regressed.go
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
// Copyright 2018 The WPT Dashboard Project. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package summaries
import (
"github.com/google/go-github/v47/github"
"github.com/web-platform-tests/wpt.fyi/shared"
)
// BeforeAndAfter summarizes counts for pass/total before and after, across a
// particular path (could be a folder, could be a test).
type BeforeAndAfter map[string]TestBeforeAndAfter
// Add the given before/after counts to the totals.
func (bna BeforeAndAfter) Add(p string, before, after shared.TestSummary) {
sum := TestBeforeAndAfter{} // nolint:exhaustruct // TODO: Fix exhaustruct lint error
if existing, ok := bna[p]; ok {
sum = existing
}
if before != nil {
sum.PassingBefore += before[0]
sum.TotalBefore += before[1]
}
if after != nil {
sum.PassingAfter += after[0]
sum.TotalAfter += after[1]
}
bna[p] = sum
}
// TestBeforeAndAfter is a struct summarizing pass rates before and after in a diff.
type TestBeforeAndAfter struct {
PassingBefore int
PassingAfter int
TotalBefore int
TotalAfter int
}
// Regressed is the struct for regressed.md.
type Regressed struct {
CheckState
ResultsComparison
Regressions BeforeAndAfter
More int
}
// GetCheckState returns the info needed to update a check.
func (r Regressed) GetCheckState() CheckState {
return r.CheckState
}
// GetSummary executes the template for the data.
func (r Regressed) GetSummary() (string, error) {
return compile(&r, "regressed.md")
}
// GetActions returns the actions that can be taken by the user.
func (r Regressed) GetActions() []*github.CheckRunAction {
return []*github.CheckRunAction{
RecomputeAction(),
IgnoreAction(),
}
}