Skip to content

Commit

Permalink
test: skip reporting CanaryOnly failures for stable version tests (#2698
Browse files Browse the repository at this point in the history
)

* 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
  • Loading branch information
pieh authored Oct 24, 2024
1 parent c1a20f7 commit 3e745e4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 22 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ jobs:
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION_SELECTORS=[${{ github.event.inputs.versions }}]
echo "group=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" >> $GITHUB_OUTPUT
echo "total=12" >> $GITHUB_OUTPUT
echo "group=[1, 2, 3, 4]" >> $GITHUB_OUTPUT
echo "total=4" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" == "pull_request" ]; then
VERSION_SELECTORS=[\"latest\"]
echo "group=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" >> $GITHUB_OUTPUT
echo "total=12" >> $GITHUB_OUTPUT
echo "group=[1, 2, 3, 4]" >> $GITHUB_OUTPUT
echo "total=4" >> $GITHUB_OUTPUT
else
VERSION_SELECTORS=[\"latest\",\"canary\",\"14.2.15\",\"13.5.1\"]
echo "group=[1, 2, 3, 4]" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion run-local-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export NEXT_TEST_MODE=deploy
export RUNTIME_DIR=$(pwd)
cp tests/netlify-deploy.ts ../next.js/test/lib/next-modes/netlify-deploy.ts
cd ../next.js/
git apply ../opennextjs-netlify/tests/e2e-utils.patch || git apply ../opennextjs-netlify/tests/e2e-utils-v2.patch
git apply $RUNTIME_DIR/tests/e2e-utils.patch || git apply $RUNTIME_DIR/tests/e2e-utils-v2.patch
node run-tests.js --type e2e --debug --test-pattern $1
git checkout -- test/lib/e2e-utils.ts

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 ?? ''],
['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.stderr
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
8 changes: 7 additions & 1 deletion tests/test-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@
{
"file": "test/e2e/app-dir/app-static/app-static.test.ts",
"reason": "Uses CLI output",
"tests": ["app-dir static/dynamic handling should warn for too many cache tags"]
"tests": [
"app-dir static/dynamic handling should warn for too many cache tags"
]
},
{
"file": "test/e2e/app-dir/parallel-routes-and-interception/parallel-routes-and-interception.test.ts",
Expand Down Expand Up @@ -358,6 +360,10 @@
{
"file": "test/e2e/app-dir/dynamic-io-request-apis/dynamic-io-request-apis.test",
"reason": "Uses CLI output"
},
{
"file": "test/e2e/next-config-warnings/esm-externals-false/esm-externals-false.test.ts",
"reason": "Uses CLI output"
}
],
"failures": [
Expand Down
7 changes: 7 additions & 0 deletions tools/deno/junit2json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ function junitToJson(xmlData: { testsuites: JUnitTestSuites }): Array<TestSuite>
if (skippedTestsForFile?.some(({ name }) => name === testCase['@name'])) {
continue
}

// skip reporting on tests that even fail to deploy because they rely on experiments not available
// in currently tested version
if (testCase.failure?.includes('CanaryOnlyError')) {
continue
}

const status = testCase.failure ? 'failed' : 'passed'
const test: TestCase = {
name: testCase['@name'],
Expand Down

0 comments on commit 3e745e4

Please sign in to comment.