-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathmain.go
More file actions
115 lines (102 loc) · 2.98 KB
/
Copy pathmain.go
File metadata and controls
115 lines (102 loc) · 2.98 KB
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
111
112
113
114
115
package main
import (
"fmt"
"os"
"strings"
"gopkg.in/yaml.v3"
)
// integrationTestCfg describes single workflow config from './integration-test-cfg.yaml'.
type integrationTestCfg struct {
ScyllaVersion string `yaml:"scylla-version"`
IPFamily string `yaml:"ip-family"`
Tablets string `yaml:"tablets"`
SSLEnabled string `yaml:"ssl-enabled,omitempty"`
BackupMethod string `yaml:"backup-method,omitempty"`
RestoreMethod string `yaml:"restore-method,omitempty"`
BackupProvider string `yaml:"backup-provider,omitempty"`
}
func (cfg integrationTestCfg) name() string {
parts := []string{
"integration",
"tests",
cfg.scyllaVersion(),
cfg.IPFamily,
}
if cfg.Tablets == "enabled" {
parts = append(parts, "tablets")
}
if cfg.SSLEnabled == "false" {
parts = append(parts, "nossl")
}
if cfg.BackupMethod != "" {
parts = append(parts, cfg.BackupMethod)
}
if cfg.RestoreMethod != "" {
parts = append(parts, cfg.RestoreMethod)
}
if cfg.BackupProvider != "" {
parts = append(parts, cfg.BackupProvider)
}
return strings.Join(parts, "-")
}
func (cfg integrationTestCfg) scyllaVersion() string {
return strings.Split(cfg.ScyllaVersion, ":")[1]
}
// This is a simple script used to generate workflow files by applying
// each config from './integration-test-cfg.yaml' onto './integration-test-core.yaml'.
// It also prints github badges syntax that can be pasted into the README.md file.
// It has to be run from the same dir with 'go run main.go' command.
func main() {
f, err := os.ReadFile("./integration-test-cfg.yaml")
if err != nil {
panic(err)
}
configs := make([]integrationTestCfg, 0)
if err := yaml.Unmarshal(f, &configs); err != nil {
panic(err)
}
f, err = os.ReadFile("./integration-test-core.yaml")
if err != nil {
panic(err)
}
core := make(map[any]any)
if err := yaml.Unmarshal(f, &core); err != nil {
panic(err)
}
// Remove previous integration-test workflows
entries, err := os.ReadDir("../workflows")
if err != nil {
panic(err)
}
for _, e := range entries {
if strings.HasPrefix(e.Name(), "integration-test") {
if err := os.Remove("../workflows/" + e.Name()); err != nil {
panic(err)
}
}
}
fmt.Println("Reference links to badges")
versionBadges := make(map[string][]string)
for _, cfg := range configs {
name := cfg.name()
v := cfg.scyllaVersion()
core["name"] = name
core["env"] = cfg
b, err := yaml.Marshal(&core)
if err != nil {
panic(err)
}
if err := os.WriteFile("../workflows/"+name+".yaml", b, 0644); err != nil {
panic(err)
}
versionBadges[v] = append(versionBadges[v], "!["+name+"]")
fmt.Printf("[%s]: https://github.com/scylladb/scylla-manager/actions/workflows/%s.yaml/badge.svg?branch=master\n",
name, name)
}
fmt.Println("Badges formatted as table")
fmt.Println("| ScyllaDB version | Workflows | Limitations |")
fmt.Println("| ---------------- | --------- | ----------- |")
for v, badges := range versionBadges {
fmt.Printf("| **%s** | %s | |\n", v, strings.Join(badges, "<br/>"))
}
}