forked from sccn/lsl_archived
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_console.html
213 lines (204 loc) · 6.81 KB
/
ci_console.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Start CI builds</title>
<style type="text/css">
body {
margin: 40px auto;
max-width: 30em;
line-height: 1.6;
color: #444;
padding: 0 10px;
}
div {
border: 1px solid gray;
white-space: pre-wrap;
}
form label {
width: 10em;
display: inline-block;
}
input[type="text"],
input[type="button"],
textarea {
width: 25em;
display: inline-block;
}
</style>
<script>
function $(id) { return document.getElementById(id); }
function formval(formid) { return $(formid).value; }
function updateEnvBox(box) {
envdata = JSON.parse(formval(box));
envdata.CMakeArgs = formval('cmakeargs');
$(box).value = JSON.stringify(envdata, null, 2);
return envdata;
}
function savesettings() {
if (window.location.protocol !== 'file:') {
alert('Credentials are only saved on local (file://C:/foo.html) files');
return;
}
for (inp of document.getElementsByTagName('input')) {
window.localStorage.setItem(inp.id, inp.value);
}
}
function xhr(url, headers, data, cb) {
var req = new XMLHttpRequest();
req.open('POST', url);
headers['Content-Type'] = 'application/json';
for (let key in headers) req.setRequestHeader(key, headers[key]);
req.onload = () => {
$('result').textContent = req.response;
console.log(req);
try {
cb(JSON.parse(req.response));
} catch (err) { alert(err); }
}
let datastr = JSON.stringify(data, null, 2);
$('request').textContent = datastr;
req.send(datastr);
}
function buildtravis() {
let data = { 'request': {'config':{'env':updateEnvBox('travisenv')}} };
if (branch = formval('branch')) { data.request.branch = branch; }
let reponame = formval('accountName') + '%2F' + formval('projectSlug');
let url = 'https://api.travis-ci.org/repo/' + reponame + '/requests';
let headers = { 'Travis-API-Version': 3, 'Authorization': 'token ' + formval('trtoken') };
xhr(url, headers, data, (resp) => { });
};
// Useful presets for AppVeyor
// Keys: `env` contains environment settings, `CMakeArgs` (optional) arguments to CMake
let appveyorcompilers = {
'Default': {},
'VS2015 x64 new image': { 'VCVER': '14.0', 'ARCH': 'amd64', 'QTCOMPILER': 'msvc2017_64', 'APPVEYOR_BUILD_WORKER_IMAGE': 'Visual Studio 2017' },
'VS2015 x64': { 'VCVER': '14.0', 'ARCH': 'amd64', 'QTCOMPILER': 'msvc2015_64' },
'VS2008 x86': { 'VCVER': '9.0', 'ARCH': 'x86', 'QTCOMPILER': 'not supported' }
}
function buildappveyor() {
try {
let data = {
'accountName': formval('accountName'),
'projectSlug': formval('projectSlug'),
'environmentVariables': updateEnvBox('appveyorenv'),
};
if (branch = formval('branch')) data.branch = branch;
let headers = { 'Authorization': 'Bearer ' + formval('avtoken') };
let cb = (resp) => {
let link = document.createElement('a');
link.href = 'https://ci.appveyor.com/project/' + formval('accountName') + '/' + formval('projectSlug') + '/build/' + resp.version;
link.textContent = 'Build log';
$('result').appendChild(link);
}
xhr('https://ci.appveyor.com/api/builds', headers, data, cb);
}
catch (err) {
alert('Invalid JSON in AppVeyor environment settings' + err);
}
}
document.addEventListener("DOMContentLoaded", () => {
for (inp of document.getElementsByTagName('input')) {
if (inp.type == 'button') continue;
let savedval = window.localStorage.getItem(inp.id);
if (savedval !== null) inp.value = savedval;
}
for (key in appveyorcompilers) {
var option = document.createElement('option');
option.textContent = option.value = key;
$('avcompiler').appendChild(option);
}
$('avcompiler').onchange = (ev) => {
$('appveyorenv').value = JSON.stringify(appveyorcompilers[formval('avcompiler')], null, 2);
updateEnvBox('appveyorenv');
};
$('cmakeargs').addEventListener('change', (e) => {
updateEnvBox('travisenv');
updateEnvBox('appveyorenv');
});
});
</script>
</head>
<body>
<form action="#">
<datalist id="accountNameList">
<option value="labstreaminglayer" />
</datalist>
<datalist id="projectSlugList">
<option value="liblsl" />
<option value="App-LabRecorder" />
</datalist>
<datalist id="cmakeargsList">
<option value="-DLSL_LSLBOOST_PATH=external" />
<option value="-DLSL_LSLBOOST_PATH=lslboost -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=1 -DCMAKE_POLICY_DEFAULT_CMP0069=NEW"
/>
</datalist>
<h1>CI build console</h1>
<h2>What's this for?</h2>
<span>LSL supports a large range of systems, from tiny Raspberry Pis and Android/iOS Phones to large PCs with Windows, Linux
and OS X. Before proposing changes, it's therefore a good idea to test if your code compiles and runs on these platforms.
You can register with your GitHub Account at
<a href="https://appveyor.com">AppVeyor</a>
and
<a href="https://travis-ci.com">Travis CI</a> and compile your code on most supported systems. To do this, request your API tokens (see links below) and
fill out the forms below to start a CI build and see if everything works.
</span>
<fieldset>
<legend>Account / Repo settings</legend>
<label>Account Name:
<input id="accountName" type="text" list="accountNameList" />
</label>
<br>
<label>Repo Name:
<input id="projectSlug" type="text" list="projectSlugList" />
</label>
<br>
<label>
<a href="https://ci.appveyor.com/api-token">AppVeyor-Token:</a>
<input id="avtoken" value="" />
</label>
<br>
<label>
<a href="https://docs.travis-ci.com/user/triggering-builds/">Travis-Token:</a>
<input id="trtoken" value="" />
</label>
<br>
<input type="button" value="Save settings locally" onclick="savesettings()">
</fieldset>
<fieldset>
<legend>Build settings</legend>
<label>Branch (optional):
<input id="branch" type="text" />
</label>
<br>
<label>CMake args:
<input id="cmakeargs" type="text" list="cmakeargsList" />
</label>
<br>
</fieldset>
<!--Travis-Repo-ID: <input id="travisrepoid" value="14417672"></br>-->
<fieldset>
<legend>AppVeyor Settings</legend>
<select id="avcompiler">
<!-- Filled automatically on page load-->
</select>
<br>
<label>Env:
<textarea id="appveyorenv" cols="100" rows="15">{}</textarea>
</label>
<input id="buildbtnAV" type="button" value="Build on AppVeyor" onclick="buildappveyor()">
</fieldset>
<fieldset>
<legend>
<a href="https://docs.travis-ci.com/user/triggering-builds/">Travis settings</a>
</legend>
<input id="buildbtnTravis" type="button" value="Build on Travis" onclick="buildtravis()">
<label>Env:
<textarea id="travisenv" cols="100" rows="15">{}</textarea>
</label>
</fieldset>
</form>
<div id="request">(Request data appears here)</div>
<div id="result">(Request results appear here)</div>
</body>
</html>