-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathstable.go
47 lines (40 loc) · 1.15 KB
/
stable.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
package main
import (
"strings"
"cloud.google.com/go/datastore"
mapset "github.com/deckarep/golang-set"
"github.com/web-platform-tests/data-migration/processor"
"github.com/web-platform-tests/wpt.fyi/shared"
)
// stableLabeller ensures that stable runs are labelled 'stable' (and not
// 'experimental'), based on the browser name and version.
type stableLabeller struct{}
func (e stableLabeller) ShouldProcessRun(run *shared.TestRun) bool {
if !shared.IsBrowserName(run.BrowserName) {
return false
}
if strings.HasSuffix(run.BrowserName, "-experimental") {
return false
}
if strings.HasSuffix(run.BrowserVersion, " dev") || strings.HasSuffix(run.BrowserVersion, "a1") {
return false
}
return true
}
func (e stableLabeller) ProcessRun(tx *datastore.Transaction, key *datastore.Key, run *shared.TestRun) error {
labels := mapset.NewSet()
for _, label := range run.Labels {
labels.Add(label)
}
labels.Remove("experimental")
labels.Add("stable")
run.Labels = nil
for label := range labels.Iter() {
run.Labels = append(run.Labels, label.(string))
}
_, err := tx.Put(key, run)
return err
}
func main() {
processor.MigrateData(stableLabeller{})
}