Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: skip reporting CanaryOnly failures for stable version tests #2698

Merged
merged 6 commits into from
Oct 24, 2024
Merged
35 changes: 19 additions & 16 deletions tests/netlify-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ import { tmpdir } from 'node:os'
import path from 'path'
import { NextInstance } from './base'

type NetlifyDeployResponse = {
name: string
site_id: string
site_name: string
deploy_id: string
deploy_url: string
logs: string
}

async function packNextRuntimeImpl() {
const runtimePackDir = await fs.mkdtemp(path.join(tmpdir(), 'opennextjs-netlify-pack'))

Expand Down Expand Up @@ -133,7 +124,7 @@ export class NextDeployInstance extends NextInstance {

const deployRes = await execa(
'npx',
['netlify', 'deploy', '--build', '--json', '--message', deployTitle ?? ''],
Copy link
Contributor

Choose a reason for hiding this comment

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

there's a weird bug in ntl deploy --json that makes debugging failures annoying anyway so I like this change :)

(I should write it up but I don't know how to reproduce it 😞)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we are just not getting any output at all on failures with --json flag. At least that's was my experience here and why I wanted to change this stuff in the first place to see actual logs on deploy failures

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, I think that's right... maybe it's by design?

['netlify', 'deploy', '--build', '--message', deployTitle ?? ''],
{
cwd: this.testDir,
reject: false,
Expand All @@ -142,17 +133,29 @@ export class NextDeployInstance extends NextInstance {

if (deployRes.exitCode !== 0) {
throw new Error(
`Failed to deploy project ${deployRes.stdout} ${deployRes.stderr} (${deployRes.exitCode})`,
`Failed to deploy project (${deployRes.exitCode}) ${deployRes.stdout} ${deployRes.stderr} `,
)
}

try {
const data: NetlifyDeployResponse = JSON.parse(deployRes.stdout)
this._url = data.deploy_url
const [url] = new RegExp(/https:.+\.netlify\.app/gm).exec(deployRes.stdout) || []
if (!url) {
throw new Error('Could not extract the URL from the build logs')
}
const [deployID] = new URL(url).host.split('--')
this._url = url
this._parsedUrl = new URL(this._url)
this._deployId = data.deploy_id
require('console').log(`Deployment URL: ${data.deploy_url}`)
require('console').log(`Logs: ${data.logs}`)
this._deployId = deployID
this._cliOutput = deployRes.stdout + deployRes.stdout
pieh marked this conversation as resolved.
Show resolved Hide resolved
require('console').log(`Deployment URL: ${this._url}`)

const [buildLogsUrl] =
new RegExp(/https:\/\/app\.netlify\.com\/sites\/.+\/deploys\/[0-9a-f]+/gm).exec(
deployRes.stdout,
) || []
if (buildLogsUrl) {
require('console').log(`Logs: ${buildLogsUrl}`)
}
} catch (err) {
console.error(err)
throw new Error(`Failed to parse deploy output: ${deployRes.stdout}`)
Expand Down