-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathchannels.go
57 lines (49 loc) · 1.48 KB
/
channels.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
package main
import (
"strings"
"cloud.google.com/go/datastore"
"github.com/web-platform-tests/data-migration/processor"
"github.com/web-platform-tests/wpt.fyi/shared"
)
var channels = []string{"stable", "release", "beta", "dev", "canary", "nightly", "preview"}
// channelLabeller fixes channel labels based on the browser version metadata.
type channelLabeller struct{}
func (e channelLabeller) ShouldProcessRun(run *shared.TestRun) bool {
if !shared.IsBrowserName(run.BrowserName) {
return false
}
labels := run.LabelsSet()
for _, c := range channels {
if labels.Contains(c) {
return false
}
}
return true
}
func (e channelLabeller) ProcessRun(tx *datastore.Transaction, key *datastore.Key, run *shared.TestRun) error {
switch run.BrowserName {
case "chrome":
if strings.HasSuffix(run.BrowserVersion, " dev") {
run.Labels = append(run.Labels, "dev")
} else if strings.HasSuffix(run.BrowserVersion, " beta") {
run.Labels = append(run.Labels, "beta")
}
case "firefox":
if strings.HasSuffix(run.BrowserVersion, "a1") {
run.Labels = append(run.Labels, "nightly")
} else if strings.HasSuffix(run.BrowserVersion, "b1") {
run.Labels = append(run.Labels, "beta")
}
case "safari":
if strings.Contains(run.BrowserVersion, "preview") || strings.Contains(run.BrowserVersion, "Preview") {
run.Labels = append(run.Labels, "preview")
}
default:
return nil
}
_, err := tx.Put(key, run)
return err
}
func main() {
processor.MigrateData(channelLabeller{})
}