-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmagefile.go
115 lines (97 loc) · 2.96 KB
/
magefile.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
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
// Copyright (c) 2021 BlockDev AG
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
//go:build mage
// +build mage
package main
import (
"path"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"github.com/mysteriumnetwork/discovery/ci/e2e"
"github.com/mysteriumnetwork/discovery/ci/local"
"github.com/mysteriumnetwork/discovery/ci/swagger"
"github.com/mysteriumnetwork/go-ci/commands"
)
// Swag generates swagger JSON.
func Swag() error {
return swagger.Swag()
}
// Test runs the tests.
func Test() error {
return sh.RunV("go", "test", "-race", "-cover", "-short", "./...")
}
// Check checks that the source is compliant with all of the checks.
func Check() error {
return commands.CheckD(".")
}
func Copyright() error {
return commands.CopyrightD(".")
}
// Build builds the app binary.
//
//goland:noinspection GoUnusedExportedFunction
func Build() error {
mg.Deps(Swag)
return sh.Run("go", "build", "-o", path.Join("build", "discovery"), path.Join("cmd", "main.go"))
}
// Build builds the app binary for e2e.
//
//goland:noinspection GoUnusedExportedFunction
func BuildE2e() error {
return sh.Run("go", "build", "-o", path.Join("build", "discovery"), path.Join("cmd", "main.go"))
}
// BuildPricer builds the pricer binary.
//
//goland:noinspection GoUnusedExportedFunction
func BuildPricer() error {
mg.Deps(Swag)
return sh.Run("go", "build", "-o", path.Join("build", "pricer"), path.Join("cmd", "pricer", "main.go"))
}
// BuildPricer builds the pricer binary.
//
//goland:noinspection GoUnusedExportedFunction
func BuildPricerE2e() error {
return sh.Run("go", "build", "-o", path.Join("build", "pricer"), path.Join("cmd", "pricer", "main.go"))
}
// Build builds the sidecar binary.
//
//goland:noinspection GoUnusedExportedFunction
func BuildSidecar() error {
return sh.Run("go", "build", "-o", path.Join("build", "sidecar"), path.Join("sidecar", "cmd", "main.go"))
}
// Run runs the app (without the DB).
//
//goland:noinspection GoUnusedExportedFunction
func Run() error {
envs := map[string]string{
"QUALITY_ORACLE_URL": "https://quality.mysterium.network",
"QUALITY_CACHE_TTL": "20s",
"BROKER_URL": "nats://broker.mysterium.network",
"COINRANKING_TOKEN": "",
"UNIVERSE_JWT_SECRET": "",
"REDIS_ADDRESS": "localhost:6379",
"LOCATION_ADDRESS": "https://location.mysterium.network/api/v1/location",
"SENTINEL_URL": "https://sentinel.mysterium.network",
}
return sh.RunWithV(envs, "go", "run", "./cmd/main.go")
}
// Up runs the discovery stack (app and DB) locally.
//
//goland:noinspection GoUnusedExportedFunction
func Up() {
mg.Deps(Swag)
local.Up()
}
// E2EDev spins up local NATS and seeded DB for e2e test development.
//
//goland:noinspection GoUnusedExportedFunction
func E2EDev() {
e2e.UpDevDependencies()
}
// E2E runs e2e tests on locally running instance
//
//goland:noinspection GoUnusedExportedFunction
func E2E() error {
return e2e.Run()
}