Skip to content

Commit e2dd725

Browse files
authored
ci: less verbose e2e startup (#3483)
This hides a number of error messages that are really indications that we need to continue waiting.
1 parent bb27cf5 commit e2dd725

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

src/SIL.XForge.Scripture/ClientApp/e2e/await-application-startup.mts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,37 @@
33
// This script polls to check whether the application has started at localhost:5000, and exits when it has started up,
44
// or exits with a failure if it hasn't started in 5 minutes.
55

6+
const programName = 'await-application-startup';
67
const pollUrl = 'http://localhost:5000/projects';
78
const pollInterval = 1000;
89
const timeout = 5 * 60_000;
910

11+
const startTime = Date.now();
12+
let lastError: string | null = null;
13+
14+
function output(message: string) {
15+
console.log(`${programName}: ${message}`);
16+
}
17+
18+
function outputWithoutNewline(message: string) {
19+
Deno.stdout.writeSync(new TextEncoder().encode(`${programName}: ${message}`));
20+
}
21+
1022
setTimeout(() => {
11-
console.log('Failed to start in ', timeout, ' milliseconds. Exiting.');
23+
console.log(); // New line after dots
24+
if (lastError != null) {
25+
output(`Error: ${lastError}`);
26+
}
27+
output(`Failed to start in ${timeout} milliseconds. Exiting.`);
1228
Deno.exit(1);
1329
}, timeout);
1430

15-
const startTime = Date.now();
1631
function elapsedTime() {
17-
const currentTIme = Date.now();
18-
const elapsed = currentTIme - startTime;
32+
const currentTime = Date.now();
33+
const elapsed = currentTime - startTime;
1934
const minutes = Math.floor(elapsed / 60_000);
2035
const seconds = Math.floor((elapsed % 60_000) / 1000);
21-
return `${minutes}:${seconds < 10 ? '0' + seconds : seconds}`;
36+
return `${minutes}:${seconds.toString().padStart(2, '0')}`;
2237
}
2338

2439
async function check() {
@@ -27,15 +42,20 @@ async function check() {
2742
headers: { Accept: 'text/html' }
2843
});
2944
if (response.ok) {
30-
console.log(elapsedTime(), 'Startup check passed. Exiting.');
45+
console.log(); // New line after dots
46+
output(`${elapsedTime()} Startup check passed. Exiting.`);
3147
Deno.exit(0);
3248
} else {
33-
console.log(elapsedTime(), 'Startup check failed: ', response.status, response.statusText);
49+
lastError = `${response.status} ${response.statusText}`;
50+
Deno.stdout.writeSync(new TextEncoder().encode('.'));
3451
}
3552
} catch (error) {
36-
console.log(elapsedTime(), 'Startup check failed: ' + error.message);
53+
const message = error instanceof Error ? error.message : String(error);
54+
lastError = message;
55+
Deno.stdout.writeSync(new TextEncoder().encode('.'));
3756
}
3857
}
3958

59+
outputWithoutNewline('Awaiting application startup before running tests ...');
4060
setTimeout(check, 0);
4161
setInterval(check, pollInterval);

src/SIL.XForge.Scripture/ClientApp/e2e/pre_merge_ci.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ function startServer() {
4949
local SERVER_PID="$!"
5050
trap "shutDownServer ${SERVER_PID}" EXIT
5151
output "Server started with PID ${SERVER_PID}"
52-
output "Awaiting application startup before running tests"
5352
cd "${SCRIPT_DIR}"
5453
./await-application-startup.mts
5554
}

0 commit comments

Comments
 (0)