Skip to content

Commit c415402

Browse files
committed
Switch to localtunnel; increased timeout
1 parent 04f829f commit c415402

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- test log formatted in html
88
- coverage checks ignored for branches named 'documentation'
9+
- switch from Serveo to localtunnel
10+
- increased timeout from 5 to 8 minutes
911

1012
## [2.1.0]
1113
### Added

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Requires MATLAB 2017a or later, Node.js and Git Bash. The following Node.js mod
1212

1313
```
1414
npm install --save express dotenv @octokit/app @octokit/request ...
15-
github-webhook-handler xml2js
15+
github-webhook-handler xml2js localtunnel
1616
```
1717

1818
### Installing
@@ -33,6 +33,8 @@ GITHUB_APP_IDENTIFIER=1234
3333
GITHUB_WEBHOOK_SECRET=
3434
WEBHOOK_PROXY_URL=
3535
RIGBOX_REPO_PATH=C:\Path\To\Code\Repo
36+
TUNNEL_HOST=
37+
TUNNEL_SUBDOMAIN=
3638
```
3739

3840
To run at startup create a batch file with the following command:
@@ -45,7 +47,7 @@ Create a shortcut in your startup folder ([Windows-logo] + [R] in Windows-10 and
4547

4648
## Built With
4749

48-
* [Serveo](serveo.net) - SSH tunneling service
50+
* [LocalTunnel](https://localtunnel.me) - A secure tunneling service
4951
* [Shields.io](shields.io) - Display shields
5052

5153
## Contributing

index.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @requires module:"@octokit/app"
77
* @requires module:"@octokit/request"
88
* @requires module:express
9+
* @requires module:localtunnel
910
* @requires module:github-webhook-handler
1011
*/
1112
const fs = require('fs');
@@ -16,18 +17,22 @@ const queue = new (require('./queue.js'))()
1617
const Coverage = require('./coverage');
1718
const { App } = require('@octokit/app');
1819
const { request } = require("@octokit/request");
20+
const localtunnel = require('localtunnel');
1921

2022
const id = process.env.GITHUB_APP_IDENTIFIER;
2123
const secret = process.env.GITHUB_WEBHOOK_SECRET;
2224

23-
// Configure ssh tunnel
24-
const cmd = 'ssh -tt -R gladius:80:localhost:3000 serveo.net';
25-
const sh = String(cp.execFileSync('where', ['git'])).replace(/cmd\\git.exe\s*/gi, 'bin\\sh.exe');
26-
const tunnel = () => {
27-
let ssh = cp.spawn(sh, ['-c', cmd])
28-
ssh.stdout.on('data', (data) => { console.log(`stdout: ${data}`); });
29-
ssh.on('exit', () => { console.log('Reconnecting to Serveo'); tunnel(); });
30-
ssh.on('error', (e) => { console.error(e) });
25+
// Configure a secure tunnel
26+
const openTunnel = async () => {
27+
let args = {
28+
port: 3000,
29+
subdomain: process.env.TUNNEL_SUBDOMAIN,
30+
host: process.env.TUNNEL_HOST
31+
};
32+
const tunnel = await localtunnel(args);
33+
console.log(`Tunnel open on: ${tunnel.url}`);
34+
tunnel.on('close', () => {console.log('Reconnecting'); openTunnel(); });
35+
tunnel.on('error', (e) => { console.error(e) });
3136
}
3237

3338
// Create handler to verify posts signed with webhook secret. Content type must be application/json
@@ -288,9 +293,9 @@ queue.process(async (job, done) => {
288293
const timer = setTimeout(function() {
289294
console.log('Max test time exceeded')
290295
job.data['status'] = 'error';
291-
job.data['context'] = 'Tests stalled after ~2 min';
296+
job.data['context'] = 'Tests stalled after ~8 min';
292297
runTests.kill();
293-
done(new Error('Job stalled')) }, 5*60000);
298+
done(new Error('Job stalled')) }, 8*60000);
294299
let args = ['-r', `runAllTests (""${job.data.sha}"",""${job.data.repo}"")`,
295300
'-wait', '-log', '-nosplash', '-logfile', `.\\src\\matlab_tests-${job.data.sha}.log`];
296301
runTests = cp.execFile('matlab', args, (error, stdout, stderr) => {
@@ -467,8 +472,9 @@ var server = srv.listen(3000, function () {
467472

468473
console.log("Handler listening at http://%s:%s", host, port)
469474
});
475+
470476
// Start tunnel
471-
tunnel();
477+
openTunnel();
472478

473479
// Log any unhandled errors
474480
process.on('unhandledRejection', (reason, p) => {

runAllTests.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,6 @@ function runAllTests(id, repo)
9999
catch ex
100100
fprintf('Error in ''%s'' line %i: %s: %s\n', ...
101101
ex.stack(1).name, ex.stack(1).line, ex.identifier, ex.message)
102-
exit(1)
102+
disp(getReport(ex)) % Display details for debugging
103+
if ~isempty(id), exit(1), end
103104
end

0 commit comments

Comments
 (0)