forked from gomods/athens
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.ps1
142 lines (111 loc) · 2.39 KB
/
init.ps1
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
[CmdletBinding()]
Param(
[Parameter(Mandatory=$false)]
[switch]$build,
[Parameter(Mandatory=$false)]
[switch]$run,
[Parameter(Mandatory=$false)]
[switch]$docs,
[Parameter(Mandatory=$false)]
[Alias("setup-dev-env")]
[switch]$setup_dev_env,
[Parameter(Mandatory=$false)]
[switch]$verify,
[Parameter(Mandatory=$false)]
[switch]$test,
[Parameter(Mandatory=$false)]
[Alias("test-unit")]
[switch]$test_unit,
[Parameter(Mandatory=$false)]
[Alias("test-e2e")]
[switch]$test_e2e,
[Parameter(Mandatory=$false)]
[switch]$docker,
[Parameter(Mandatory=$false)]
[Alias("proxy-docker")]
[switch]$proxy_docker,
[Parameter(Mandatory=$false)]
[switch]$bench,
[Parameter(Mandatory=$false)]
[switch]$alldeps,
[Parameter(Mandatory=$false)]
[switch]$dev,
[Parameter(Mandatory=$false)]
[switch]$down
)
function execScript($name) {
$scriptsDir = "$(Join-Path scripts ps)"
& "$(Join-Path $scriptsDir $name)"
}
if ($setup_dev_env.IsPresent) {
execScript "get_dev_tools.ps1"
& docker-compose -p athensdev up -d mongo
& docker-compose -p athensdev up -d redis
}
if ($build.IsPresent) {
try {
Push-Location $(Join-Path cmd proxy)
& buffalo build
}
finally {
Pop-Location
}
finally {
Pop-Location
}
}
if ($run.IsPresent) {
Set-Location $(Join-Path cmd proxy)
& buffalo dev
}
if ($docs.IsPresent) {
Set-Location docs
& hugo
}
if ($verify.IsPresent) {
execScript "check_gofmt.ps1"
execScript "check_golint.ps1"
execScript "check_deps.ps1"
}
if ($alldeps.IsPresent) {
& docker-compose -p athensdev up -d mongo
& docker-compose -p athensdev up -d redis
& docker-compose -p athensdev up -d minio
& docker-compose -p athensdev up -d jaeger
Write-Host "sleeping for a bit to wait for the DB to come up"
Start-Sleep 5
}
if ($dev.IsPresent) {
& docker-compose -p athensdev up -d mongo
& docker-compose -p athensdev up -d redis
}
if ($test.IsPresent) {
try {
Push-Location $(Join-Path cmd proxy)
& buffalo test
}
finally {
Pop-Location
}
finally {
Pop-Location
}
}
if ($test_unit.IsPresent) {
execScript "test_unit.ps1"
}
if ($test_e2e.IsPresent) {
execScript "test_e2e.ps1"
}
if ($docker.IsPresent) {
& docker build -t gomods/proxy -f cmd/proxy/Dockerfile .
}
if ($proxy_docker.IsPresent) {
& docker build -t gomods/proxy -f cmd/proxy/Dockerfile .
}
if ($bench.IsPresent) {
execScript "benchmark.ps1"
}
if ($down.IsPresent) {
& docker-compose -p athensdev down -v
}