forked from BitGo/BitGoJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.drone.jsonnet
252 lines (232 loc) · 5.42 KB
/
.drone.jsonnet
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
local branches() = [
"master",
"rel/*",
"prod/production",
];
local BuildInfo(version) = {
name: "build information",
image: "node:" + version,
commands: [
"node --version",
"npm --version",
"yarn --version",
"git --version",
],
};
local Install(version, allow_failure=false) = {
name: "install",
image: "node:" + version,
[if allow_failure then "failure"]: "ignore",
commands: [
"git fetch origin +refs/heads/$DRONE_REPO_BRANCH:$DRONE_REPO_BRANCH || true",
"yarn install",
],
};
local Command(command, version="lts", allow_failure=false) = {
name: command,
image: "node:" + version,
[if allow_failure then "failure"]: "ignore",
commands: [
"yarn run " + command,
],
};
local CommandWithSecrets(command, version, allow_failure=false) =
Command(command, version, allow_failure) + {
environment: {
BITGOJS_TEST_PASSWORD: { from_secret: "password" },
},
};
local WithExtraAptPackages(step, packages) = step + {
commands: [
"apt-get update",
"apt-get install -y " + std.join(" ", packages),
] + super.commands,
};
local IncludeBranches(pipeline, included_branches=branches()) = pipeline + {
trigger: {
branch: {
include: included_branches,
},
},
};
local ExcludeBranches(pipeline, excluded_branches=branches()) = pipeline + {
trigger: {
branch: {
exclude: excluded_branches
},
},
};
local LernaPublish(version) = {
name: "lerna publish",
image: "node:" + version,
environment: {
NPM_CONFIG_TOKEN: { from_secret: "npm_config_token" },
},
commands: [
"npm config set unsafe-perm true",
"yarn run internal-publish",
],
};
local GenerateDocs(version) = {
name: "generate docs",
image: "bitgosdk/upload-tools:latest",
commands: [
"yarn run gen-docs",
],
when: {
status: ["success"],
event: ["tag"],
}
};
local UploadDocs(version) = {
name: "upload docs",
image: "bitgosdk/upload-tools:latest",
environment: {
reports_s3_akid: { from_secret: "reports_s3_akid" },
reports_s3_sak: { from_secret: "reports_s3_sak" },
},
commands: [
"yarn run upload-docs",
],
when: {
status: ["success"],
event: ["tag"],
}
};
local UploadArtifacts(version, tag="untagged", only_changed=false, allow_failure=false) = {
name: "upload artifacts",
image: "bitgosdk/upload-tools:latest",
[if allow_failure then "failure"]: "ignore",
environment: {
CODECOV_TOKEN: { from_secret: "codecov" },
CODECOV_FLAG: tag,
reports_s3_akid: { from_secret: "reports_s3_akid" },
reports_s3_sak: { from_secret: "reports_s3_sak" },
},
commands: [
"yarn run artifacts",
"yarn run gen-coverage" + (if only_changed then "-changed" else ""),
"yarn run coverage",
],
when: {
status: ["success", "failure"]
}
};
local UnitTest(version, allow_failure=false) = {
kind: "pipeline",
name: "unit tests (node:" + version + ")",
steps: [
BuildInfo(version),
Install(version, allow_failure),
CommandWithSecrets("unit-test-changed", version, allow_failure),
UploadArtifacts(version, "unit", true, allow_failure),
],
};
local IntegrationTest(version) = {
kind: "pipeline",
name: "integration tests (node:" + version + ")",
steps: [
BuildInfo(version),
Install(version),
CommandWithSecrets("integration-test", version),
UploadArtifacts(version, "integration"),
],
};
local BrowserTestAptPackages = [
"gconf-service",
"libasound2",
"libatk1.0-0",
"libatk-bridge2.0-0",
"libc6",
"libcairo2",
"libcups2",
"libdbus-1-3",
"libexpat1",
"libfontconfig1",
"libgcc1",
"libgconf-2-4",
"libgdk-pixbuf2.0-0",
"libglib2.0-0",
"libgtk-3-0",
"libnspr4",
"libpango-1.0-0",
"libpangocairo-1.0-0",
"libstdc++6",
"libx11-6",
"libx11-xcb1",
"libxcb1",
"libxcomposite1",
"libxcursor1",
"libxdamage1",
"libxext6",
"libxfixes3",
"libxi6",
"libxrandr2",
"libxrender1",
"libxss1",
"libxtst6",
"ca-certificates",
"fonts-liberation",
"libappindicator1",
"libnss3",
"lsb-release",
"xdg-utils",
"wget",
];
local BrowserTest(version) = {
kind: "pipeline",
name: "Browser Tests",
steps: [
BuildInfo(version),
Install(version),
WithExtraAptPackages(CommandWithSecrets("browser-tests", version), BrowserTestAptPackages),
UploadArtifacts(version, "unit", true),
],
};
local MeasureSizeAndTiming(version) = {
kind: "pipeline",
name: "size and timing (node:" + version + ")",
steps: [
{
name: "slow-deps",
image: "node:" + version,
commands: [
"npm install -g slow-deps",
"slow-deps"
],
},
],
};
local CheckPreconditions(version) = {
kind: "pipeline",
name: "check preconditions (node:" + version + ")",
steps: [
BuildInfo(version),
Install(version),
Command("check-commits", version),
Command("audit", version),
Command("lint", version),
Command("check-fmt", version),
GenerateDocs(version),
UploadDocs(version),
]
};
local UnitVersions = ["10", "12", "14"];
local OptionalUnitVersions = ["15"];
local IntegrationVersions = ["10"];
[
CheckPreconditions("10"),
IncludeBranches(MeasureSizeAndTiming("10")),
] + [
UnitTest(version)
for version in UnitVersions
] + [
UnitTest(version, true)
for version in OptionalUnitVersions
# BG-23925 - reenable integration tests when testnet is stable
# ] + [
# IncludeBranches(IntegrationTest(version))
# for version in IntegrationVersions
] + [
IncludeBranches(BrowserTest("10"))
]