Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions tests/netlify-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export class NextDeployInstance extends NextInstance {
private _buildId: string
private _deployId: string
private _shouldDeleteDeploy: boolean = false
private _isCurrentlyDeploying: boolean = false
private _deployOutput: string = ''

public get buildId() {
// get deployment ID via fetch since we can't access
Expand All @@ -52,6 +54,8 @@ export class NextDeployInstance extends NextInstance {
return
}

this._isCurrentlyDeploying = true

const setupStartTime = Date.now()

// create the test site
Expand Down Expand Up @@ -131,7 +135,7 @@ export class NextDeployInstance extends NextInstance {
: testName
const deployAlias = 'vercel-next-e2e'

const deployRes = await execa(
const deployResPromise = execa(
'npx',
['netlify', 'deploy', '--build', '--message', deployTitle ?? '', '--alias', deployAlias],
{
Expand All @@ -140,7 +144,18 @@ export class NextDeployInstance extends NextInstance {
},
)

const handleOutput = (chunk) => {
this._deployOutput += chunk
}

deployResPromise.stdout.on('data', handleOutput)
deployResPromise.stderr.on('data', handleOutput)

const deployRes = await deployResPromise

if (deployRes.exitCode !== 0) {
// clear deploy output to avoid printing it again in destroy()
this._deployOutput = ''
throw new Error(
`Failed to deploy project (${deployRes.exitCode}) ${deployRes.stdout} ${deployRes.stderr} `,
)
Expand Down Expand Up @@ -168,7 +183,7 @@ export class NextDeployInstance extends NextInstance {
require('console').log(`Logs: ${buildLogsUrl}`)
}
} catch (err) {
console.error(err)
require('console').error(err)
Comment on lines -171 to +186
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not related to main change

this error was not being printed out before - there is some weird console patching going on - so adjusting this to be same as other logs in case those might hide some important detail for us that would help debugging

throw new Error(`Failed to parse deploy output: ${deployRes.stdout}`)
}

Expand All @@ -181,6 +196,8 @@ export class NextDeployInstance extends NextInstance {

require('console').log(`Got buildId: ${this._buildId}`)
require('console').log(`Setup time: ${(Date.now() - setupStartTime) / 1000.0}s`)

this._isCurrentlyDeploying = false
}

public async destroy(): Promise<void> {
Expand All @@ -205,6 +222,13 @@ export class NextDeployInstance extends NextInstance {
}
}

if (this._isCurrentlyDeploying) {
require('console').log('Destroying before deployment finished.')
if (this._deployOutput) {
require('console').log(`Deploy logs so far:\n\n${this._deployOutput}\n\n`)
}
}

await super.destroy()
}

Expand Down
Loading