Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
81850eb2
Unverified
Commit
81850eb2
authored
May 23, 2022
by
JJ Kasper
Committed by
GitHub
May 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update deploy E2E test setup (#37126)
* Update deploy E2E test setup
parent
e57e2753
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
69 additions
and
19 deletions
+69
-19
build_test_deploy.yml
.github/workflows/build_test_deploy.yml
+9
-2
run-tests.js
run-tests.js
+4
-1
index.test.ts
test/e2e/i18n-data-fetching-redirect/index.test.ts
+6
-0
index.test.ts
test/e2e/reload-scroll-backforward-restoration/index.test.ts
+10
-0
rendering.test.ts
test/e2e/views-dir/rendering.test.ts
+5
-0
e2e-utils.ts
test/lib/e2e-utils.ts
+6
-2
base.ts
test/lib/next-modes/base.ts
+8
-7
next-deploy.ts
test/lib/next-modes/next-deploy.ts
+21
-7
No files found.
.github/workflows/build_test_deploy.yml
View file @
81850eb2
...
...
@@ -911,12 +911,13 @@ jobs:
testDeployE2E
:
name
:
E2E (deploy)
runs-on
:
ubuntu-latest
needs
:
[
publishRelease
]
needs
:
[
publishRelease
,
build
,
build-native-test
]
env
:
NEXT_TELEMETRY_DISABLED
:
1
NEXT_TEST_JOB
:
1
VERCEL_TEST_TOKEN
:
${{ secrets.VERCEL_TEST_TOKEN }}
VERCEL_TEST_TEAM
:
'
vtest314-next-e2e-tests'
NEXT_TEST_MODE
:
deploy
steps
:
-
name
:
Setup node
uses
:
actions/setup-node@v3
...
...
@@ -930,13 +931,19 @@ jobs:
path
:
./*
key
:
${{ github.sha }}-${{ github.run_number }}
-
uses
:
actions/download-artifact@v3
if
:
${{needs.build.outputs.docsChange != 'docs only change'}}
with
:
name
:
next-swc-test-binary
path
:
packages/next-swc/native
-
run
:
npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
name
:
Install playwright dependencies
-
run
:
RESET_VC_PROJECT=true node scripts/reset-vercel-project.mjs
name
:
Reset test project
-
run
:
NEXT_TEST_MODE=deploy
node run-tests.js --type e2e
-
run
:
node run-tests.js --type e2e
name
:
Run test/e2e (deploy)
-
name
:
Upload test trace
...
...
run-tests.js
View file @
81850eb2
...
...
@@ -210,7 +210,10 @@ async function main() {
)
})
if
((
testType
&&
testType
!==
'unit'
)
||
hasIsolatedTests
)
{
if
(
process
.
env
.
NEXT_TEST_MODE
!==
'deploy'
&&
((
testType
&&
testType
!==
'unit'
)
||
hasIsolatedTests
)
)
{
// for isolated next tests: e2e, dev, prod we create
// a starter Next.js install to re-use to speed up tests
// to avoid having to run yarn each time
...
...
test/e2e/i18n-data-fetching-redirect/index.test.ts
View file @
81850eb2
...
...
@@ -7,6 +7,12 @@ import webdriver from 'next-webdriver'
describe
(
'i18n-data-fetching-redirect'
,
()
=>
{
let
next
:
NextInstance
// TODO: investigate tests failures on deploy
if
((
global
as
any
).
isNextDeploy
)
{
it
(
'should skip temporarily'
,
()
=>
{})
return
}
beforeAll
(
async
()
=>
{
next
=
await
createNext
({
files
:
{
...
...
test/e2e/reload-scroll-backforward-restoration/index.test.ts
View file @
81850eb2
...
...
@@ -68,6 +68,11 @@ describe('reload-scroll-back-restoration', () => {
await
browser
.
refresh
()
await
check
(
async
()
=>
{
const
isReady
=
await
browser
.
eval
(
'next.router.isReady'
)
return
isReady
?
'success'
:
isReady
},
'success'
)
// check restore value on history index: 0
await
browser
.
back
()
await
check
(
...
...
@@ -144,6 +149,11 @@ describe('reload-scroll-back-restoration', () => {
await
browser
.
refresh
()
await
check
(
async
()
=>
{
const
isReady
=
await
browser
.
eval
(
'next.router.isReady'
)
return
isReady
?
'success'
:
isReady
},
'success'
)
// check restore value on history index: 2
await
browser
.
forward
()
await
check
(
...
...
test/e2e/views-dir/rendering.test.ts
View file @
81850eb2
...
...
@@ -10,6 +10,11 @@ describe('views dir rendering', () => {
return
}
if
((
global
as
any
).
isNextDeploy
)
{
it
(
'should skip next deploy for now'
,
()
=>
{})
return
}
const
isDev
=
(
global
as
any
).
isDev
let
next
:
NextInstance
...
...
test/lib/e2e-utils.ts
View file @
81850eb2
...
...
@@ -46,7 +46,9 @@ if (testModeFromFile === 'e2e') {
const
validE2EModes
=
[
'dev'
,
'start'
,
'deploy'
]
if
(
!
process
.
env
.
NEXT_TEST_JOB
&&
!
testMode
)
{
console
.
warn
(
'Warn: no NEXT_TEST_MODE set, using default of start'
)
require
(
'console'
).
warn
(
'Warn: no NEXT_TEST_MODE set, using default of start'
)
testMode
=
'start'
}
assert
(
...
...
@@ -74,7 +76,9 @@ if (!testMode) {
`No 'NEXT_TEST_MODE' set in environment, this is required for e2e-utils`
)
}
console
.
log
(
`Using test mode:
${
testMode
}
in test folder
${
testModeFromFile
}
`
)
require
(
'console'
).
warn
(
`Using test mode:
${
testMode
}
in test folder
${
testModeFromFile
}
`
)
/**
* FileRef is wrapper around a file path that is meant be copied
...
...
test/lib/next-modes/base.ts
View file @
81850eb2
...
...
@@ -77,7 +77,7 @@ export class NextInstance {
if
(
this
.
isDestroyed
)
{
throw
new
Error
(
'next instance already destroyed'
)
}
console
.
log
(
`Creating test directory with isolated next...`
)
require
(
'console'
)
.
log
(
`Creating test directory with isolated next...`
)
const
skipIsolatedNext
=
!!
process
.
env
.
NEXT_SKIP_ISOLATE
const
tmpDir
=
skipIsolatedNext
...
...
@@ -129,7 +129,8 @@ export class NextInstance {
process
.
env
.
NEXT_TEST_STARTER
&&
!
this
.
dependencies
&&
!
this
.
installCommand
&&
!
this
.
packageJson
!
this
.
packageJson
&&
!
(
global
as
any
).
isNextDeploy
)
{
await
fs
.
copy
(
process
.
env
.
NEXT_TEST_STARTER
,
this
.
testDir
)
}
else
if
(
!
skipIsolatedNext
)
{
...
...
@@ -140,7 +141,7 @@ export class NextInstance {
this
.
packageLockPath
)
}
console
.
log
(
'created next.js install, writing test files'
)
require
(
'console'
)
.
log
(
'created next.js install, writing test files'
)
}
for
(
const
filename
of
Object
.
keys
(
this
.
files
))
{
...
...
@@ -218,7 +219,7 @@ export class NextInstance {
`
)
}
console
.
log
(
`Test directory created at
${
this
.
testDir
}
`
)
require
(
'console'
)
.
log
(
`Test directory created at
${
this
.
testDir
}
`
)
}
public
async
clean
()
{
...
...
@@ -252,7 +253,7 @@ export class NextInstance {
await
new
Promise
<
void
>
((
resolve
)
=>
{
treeKill
(
this
.
childProcess
.
pid
,
'SIGKILL'
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
'tree-kill'
,
err
)
require
(
'console'
)
.
error
(
'tree-kill'
,
err
)
}
resolve
()
})
...
...
@@ -260,7 +261,7 @@ export class NextInstance {
this
.
childProcess
.
kill
(
'SIGKILL'
)
await
exitPromise
this
.
childProcess
=
undefined
console
.
log
(
`Stopped next server`
)
require
(
'console'
)
.
log
(
`Stopped next server`
)
}
}
...
...
@@ -294,7 +295,7 @@ export class NextInstance {
if
(
!
process
.
env
.
NEXT_TEST_SKIP_CLEANUP
)
{
await
fs
.
remove
(
this
.
testDir
)
}
console
.
log
(
`destroyed next instance`
)
require
(
'console'
)
.
log
(
`destroyed next instance`
)
}
public
get
url
()
{
...
...
test/lib/next-modes/next-deploy.ts
View file @
81850eb2
import
os
from
'os'
import
path
from
'path'
import
execa
from
'execa'
import
fs
from
'fs-extra'
import
{
NextInstance
}
from
'./base'
import
{
TEST_PROJECT_NAME
,
...
...
@@ -23,16 +26,27 @@ export class NextDeployInstance extends NextInstance {
// ensure Vercel CLI is installed
try
{
const
res
=
await
execa
(
'vercel'
,
[
'--version'
])
console
.
log
(
`Using Vercel CLI version:`
,
res
.
stdout
)
require
(
'console'
)
.
log
(
`Using Vercel CLI version:`
,
res
.
stdout
)
}
catch
(
_
)
{
console
.
log
(
`Installing Vercel CLI`
)
require
(
'console'
)
.
log
(
`Installing Vercel CLI`
)
await
execa
(
'npm'
,
[
'i'
,
'-g'
,
'vercel@latest'
],
{
stdio
:
'inherit'
,
})
}
const
vercelFlags
=
[
'--scope'
,
TEST_TEAM_NAME
]
const
vercelEnv
=
{
...
process
.
env
,
TOKEN
:
TEST_TOKEN
}
console
.
log
(
`Linking project at
${
this
.
testDir
}
`
)
// create auth file in CI
if
(
process
.
env
.
NEXT_TEST_JOB
)
{
const
vcConfigDir
=
path
.
join
(
os
.
homedir
(),
'.vercel'
)
await
fs
.
ensureDir
(
vcConfigDir
)
await
fs
.
writeFile
(
path
.
join
(
vcConfigDir
,
'auth.json'
),
JSON
.
stringify
({
token
:
TEST_TOKEN
})
)
vercelFlags
.
push
(
'--global-config'
,
vcConfigDir
)
}
require
(
'console'
).
log
(
`Linking project at
${
this
.
testDir
}
`
)
// link the project
const
linkRes
=
await
execa
(
...
...
@@ -49,7 +63,7 @@ export class NextDeployInstance extends NextInstance {
`Failed to link project
${
linkRes
.
stdout
}
${
linkRes
.
stderr
}
(
${
linkRes
.
exitCode
}
)`
)
}
console
.
log
(
`Deploying project at
${
this
.
testDir
}
`
)
require
(
'console'
)
.
log
(
`Deploying project at
${
this
.
testDir
}
`
)
const
deployRes
=
await
execa
(
'vercel'
,
...
...
@@ -79,7 +93,7 @@ export class NextDeployInstance extends NextInstance {
this
.
_url
=
deployRes
.
stdout
this
.
_parsedUrl
=
new
URL
(
this
.
_url
)
console
.
log
(
`Deployment URL:
${
this
.
_url
}
`
)
require
(
'console'
)
.
log
(
`Deployment URL:
${
this
.
_url
}
`
)
const
buildIdUrl
=
`
${
this
.
_url
}${
this
.
basePath
||
''
}
/_next/static/__BUILD_ID`
...
...
@@ -87,13 +101,13 @@ export class NextDeployInstance extends NextInstance {
const
buildIdRes
=
await
fetch
(
buildIdUrl
)
if
(
!
buildIdRes
.
ok
)
{
console
.
error
(
require
(
'console'
)
.
error
(
`Failed to load buildId
${
buildIdUrl
}
(
${
buildIdRes
.
status
}
)`
)
}
this
.
_buildId
=
(
await
buildIdRes
.
text
()).
trim
()
console
.
log
(
`Got buildId:
${
this
.
_buildId
}
`
)
require
(
'console'
)
.
log
(
`Got buildId:
${
this
.
_buildId
}
`
)
const
cliOutputRes
=
await
fetch
(
`https://vercel.com/api/v1/deployments/
${
this
.
_parsedUrl
.
hostname
}
/events?builds=1&direction=backward`
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment