diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2023-10-18 14:37:11 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2023-10-18 14:37:44 +0200 |
commit | d452b872c9ac7ad17d9b0c60ecb391659bdef831 (patch) | |
tree | e923bc321874e08eeca7c9a0c24487143aaeea1d /cypress | |
parent | da9d06972166247321d8c1cb28566ba181559c03 (diff) | |
download | nextcloud-server-d452b872c9ac7ad17d9b0c60ecb391659bdef831.tar.gz nextcloud-server-d452b872c9ac7ad17d9b0c60ecb391659bdef831.zip |
fix: Improve dockerNode logging
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'cypress')
-rw-r--r-- | cypress/dockerNode.ts | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/cypress/dockerNode.ts b/cypress/dockerNode.ts index 23bed54b671..e2c0db38c97 100644 --- a/cypress/dockerNode.ts +++ b/cypress/dockerNode.ts @@ -41,28 +41,38 @@ const SERVER_IMAGE = 'ghcr.io/nextcloud/continuous-integration-shallow-server' export const startNextcloud = async function(branch: string = getCurrentGitBranch()): Promise<any> { try { - // Pulling images - console.log('\nPulling images... ⏳') - await new Promise((resolve, reject): any => docker.pull(SERVER_IMAGE, (err, stream) => { - if (err) { - reject(err) - } - // https://github.com/apocas/dockerode/issues/357 - docker.modem.followProgress(stream, onFinished) - - /** - * - * @param err - */ - function onFinished(err) { - if (!err) { - resolve(true) + try { + // Pulling images + console.log('\nPulling images... ⏳') + await new Promise((resolve, reject): any => docker.pull(SERVER_IMAGE, (err, stream) => { + if (err) { + reject(err) + } + if (stream === null) { + reject(new Error('Could not connect to docker, ensure docker is running.')) return } - reject(err) - } - })) - console.log('└─ Done') + + // https://github.com/apocas/dockerode/issues/357 + docker.modem.followProgress(stream, onFinished) + + /** + * + * @param err + */ + function onFinished(err) { + if (!err) { + resolve(true) + return + } + reject(err) + } + })) + console.log('└─ Done') + } catch (e) { + console.log('└─ Failed to pull images') + throw e + } // Remove old container if exists console.log('\nChecking running containers... 🔍') @@ -102,7 +112,7 @@ export const startNextcloud = async function(branch: string = getCurrentGitBranc return ip } catch (err) { console.log('└─ Unable to start the container 🛑') - console.log(err) + console.log('\n', err, '\n') stopNextcloud() throw new Error('Unable to start the container') } @@ -191,7 +201,7 @@ export const stopNextcloud = async function() { * @param {Docker.Container} container the container to get the IP from */ export const getContainerIP = async function( - container = docker.getContainer(CONTAINER_NAME) + container = docker.getContainer(CONTAINER_NAME), ): Promise<string> { let ip = '' let tries = 0 @@ -230,7 +240,7 @@ const runExec = async function( container: Docker.Container, command: string[], verbose = false, - user = 'www-data' + user = 'www-data', ) { const exec = await container.exec({ Cmd: command, |