-
Notifications
You must be signed in to change notification settings - Fork 2
/
agent.go
79 lines (63 loc) · 1.65 KB
/
agent.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
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"github.com/tuvistavie/securerandom"
"os"
"strings"
)
var WorkerUUID string
var WorkerUUIDShort string
func main() {
logger := Logger{"Main", os.Stdout}
printLogo(logger)
if err := setWorkerUuid(); err != nil {
logger.Log(err.Error())
os.Exit(1)
}
// Check if env vars are set, use defaults if not (or exit if needed)
// and initialize oauth token.
if err := SetupClientData(); err != nil {
logger.Log(err.Error())
os.Exit(1)
}
if err := EnsureGit(logger); err != nil {
logger.Log(err.Error())
os.Exit(1)
}
project, err := NewProject(logger)
if err != nil {
logger.Log(err.Error())
os.Exit(1)
}
if err := project.Init(logger); err != nil {
logger.Log(err.Error())
os.Exit(1)
}
jobsChannel := make(chan *TestJob)
reportsChannel := make(chan *TestJob)
cancelledTestRunIdsChan := make(chan []int)
manager := NewManager(jobsChannel, cancelledTestRunIdsChan)
worker := NewWorker(jobsChannel, reportsChannel, manager.workerIdlingChannel, project)
reporter := NewReporter(reportsChannel, cancelledTestRunIdsChan)
go worker.Start()
go reporter.Start()
manager.Start()
}
// Because we can
func printLogo(logger Logger) {
logger.Log(`
_______________________ _______ __ ____________ ___
/_ __/ __/ __/_ __/ _ \/ _/ _ )/ / / /_ __/ __ \/ _ \
/ / / _/_\ \ / / / , _// // _ / /_/ / / / / /_/ / , _/
/_/ /___/___/ /_/ /_/|_/___/____/\____/ /_/ \____/_/|_|
https://www.testributor.com
`)
}
func setWorkerUuid() error {
var err error
WorkerUUID, err = securerandom.Uuid()
if err != nil {
return err
}
WorkerUUIDShort = strings.Split(WorkerUUID, "-")[0]
return nil
}