Skip to content

Commit 3e745e4

Browse files
authored
test: skip reporting CanaryOnly failures for stable version tests (#2698)
* ci: decrease number of shards when running Vercel tests * test: use PWD instead of hardcoded repo directory * test: collect build logs in Vercel e2e tests (like we do in our own e2e tests) * test: skip esm-externals-false tests (they are just checking CLI output) * ci: skip reporting about tests that use canary only features when testing stable * test: fix typo when setting _cliOutput
1 parent c1a20f7 commit 3e745e4

File tree

5 files changed

+38
-22
lines changed

5 files changed

+38
-22
lines changed

.github/workflows/test-e2e.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ jobs:
5656
run: |
5757
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
5858
VERSION_SELECTORS=[${{ github.event.inputs.versions }}]
59-
echo "group=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" >> $GITHUB_OUTPUT
60-
echo "total=12" >> $GITHUB_OUTPUT
59+
echo "group=[1, 2, 3, 4]" >> $GITHUB_OUTPUT
60+
echo "total=4" >> $GITHUB_OUTPUT
6161
elif [ "${{ github.event_name }}" == "pull_request" ]; then
6262
VERSION_SELECTORS=[\"latest\"]
63-
echo "group=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" >> $GITHUB_OUTPUT
64-
echo "total=12" >> $GITHUB_OUTPUT
63+
echo "group=[1, 2, 3, 4]" >> $GITHUB_OUTPUT
64+
echo "total=4" >> $GITHUB_OUTPUT
6565
else
6666
VERSION_SELECTORS=[\"latest\",\"canary\",\"14.2.15\",\"13.5.1\"]
6767
echo "group=[1, 2, 3, 4]" >> $GITHUB_OUTPUT

run-local-test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export NEXT_TEST_MODE=deploy
1515
export RUNTIME_DIR=$(pwd)
1616
cp tests/netlify-deploy.ts ../next.js/test/lib/next-modes/netlify-deploy.ts
1717
cd ../next.js/
18-
git apply ../opennextjs-netlify/tests/e2e-utils.patch || git apply ../opennextjs-netlify/tests/e2e-utils-v2.patch
18+
git apply $RUNTIME_DIR/tests/e2e-utils.patch || git apply $RUNTIME_DIR/tests/e2e-utils-v2.patch
1919
node run-tests.js --type e2e --debug --test-pattern $1
2020
git checkout -- test/lib/e2e-utils.ts
2121

tests/netlify-deploy.ts

+19-16
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ import { tmpdir } from 'node:os'
66
import path from 'path'
77
import { NextInstance } from './base'
88

9-
type NetlifyDeployResponse = {
10-
name: string
11-
site_id: string
12-
site_name: string
13-
deploy_id: string
14-
deploy_url: string
15-
logs: string
16-
}
17-
189
async function packNextRuntimeImpl() {
1910
const runtimePackDir = await fs.mkdtemp(path.join(tmpdir(), 'opennextjs-netlify-pack'))
2011

@@ -133,7 +124,7 @@ export class NextDeployInstance extends NextInstance {
133124

134125
const deployRes = await execa(
135126
'npx',
136-
['netlify', 'deploy', '--build', '--json', '--message', deployTitle ?? ''],
127+
['netlify', 'deploy', '--build', '--message', deployTitle ?? ''],
137128
{
138129
cwd: this.testDir,
139130
reject: false,
@@ -142,17 +133,29 @@ export class NextDeployInstance extends NextInstance {
142133

143134
if (deployRes.exitCode !== 0) {
144135
throw new Error(
145-
`Failed to deploy project ${deployRes.stdout} ${deployRes.stderr} (${deployRes.exitCode})`,
136+
`Failed to deploy project (${deployRes.exitCode}) ${deployRes.stdout} ${deployRes.stderr} `,
146137
)
147138
}
148139

149140
try {
150-
const data: NetlifyDeployResponse = JSON.parse(deployRes.stdout)
151-
this._url = data.deploy_url
141+
const [url] = new RegExp(/https:.+\.netlify\.app/gm).exec(deployRes.stdout) || []
142+
if (!url) {
143+
throw new Error('Could not extract the URL from the build logs')
144+
}
145+
const [deployID] = new URL(url).host.split('--')
146+
this._url = url
152147
this._parsedUrl = new URL(this._url)
153-
this._deployId = data.deploy_id
154-
require('console').log(`Deployment URL: ${data.deploy_url}`)
155-
require('console').log(`Logs: ${data.logs}`)
148+
this._deployId = deployID
149+
this._cliOutput = deployRes.stdout + deployRes.stderr
150+
require('console').log(`Deployment URL: ${this._url}`)
151+
152+
const [buildLogsUrl] =
153+
new RegExp(/https:\/\/app\.netlify\.com\/sites\/.+\/deploys\/[0-9a-f]+/gm).exec(
154+
deployRes.stdout,
155+
) || []
156+
if (buildLogsUrl) {
157+
require('console').log(`Logs: ${buildLogsUrl}`)
158+
}
156159
} catch (err) {
157160
console.error(err)
158161
throw new Error(`Failed to parse deploy output: ${deployRes.stdout}`)

tests/test-config.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@
124124
{
125125
"file": "test/e2e/app-dir/app-static/app-static.test.ts",
126126
"reason": "Uses CLI output",
127-
"tests": ["app-dir static/dynamic handling should warn for too many cache tags"]
127+
"tests": [
128+
"app-dir static/dynamic handling should warn for too many cache tags"
129+
]
128130
},
129131
{
130132
"file": "test/e2e/app-dir/parallel-routes-and-interception/parallel-routes-and-interception.test.ts",
@@ -358,6 +360,10 @@
358360
{
359361
"file": "test/e2e/app-dir/dynamic-io-request-apis/dynamic-io-request-apis.test",
360362
"reason": "Uses CLI output"
363+
},
364+
{
365+
"file": "test/e2e/next-config-warnings/esm-externals-false/esm-externals-false.test.ts",
366+
"reason": "Uses CLI output"
361367
}
362368
],
363369
"failures": [

tools/deno/junit2json.ts

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ function junitToJson(xmlData: { testsuites: JUnitTestSuites }): Array<TestSuite>
117117
if (skippedTestsForFile?.some(({ name }) => name === testCase['@name'])) {
118118
continue
119119
}
120+
121+
// skip reporting on tests that even fail to deploy because they rely on experiments not available
122+
// in currently tested version
123+
if (testCase.failure?.includes('CanaryOnlyError')) {
124+
continue
125+
}
126+
120127
const status = testCase.failure ? 'failed' : 'passed'
121128
const test: TestCase = {
122129
name: testCase['@name'],

0 commit comments

Comments
 (0)