Skip to content

Commit

Permalink
copy missing env vars to deploy tests & add blank manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed Jun 10, 2024
1 parent 78505fc commit 64c3279
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 39 deletions.
25 changes: 14 additions & 11 deletions .github/workflows/test_e2e_deploy_scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
group: [1, 2]
group: [1/5, 2/5, 3/5, 4/5, 5/5]

steps:
- name: Setup Node.js
Expand All @@ -60,17 +60,20 @@ jobs:
- name: Run tests
run: |
docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.41.2-jammy /bin/bash -c "cd /work && \
NODE_VERSION=${{ env.NODE_LTS_VERSION }} ./scripts/setup-node.sh && \
NODE_VERSION=${NODE_LTS_VERSION} ./scripts/setup-node.sh && \
corepack enable > /dev/null && \
NEXT_JUNIT_TEST_REPORT=${{ env.NEXT_JUNIT_TEST_REPORT }} \
DATADOG_API_KEY=${{ env.DATADOG_API_KEY }} \
DD_ENV=${{ env.DD_ENV }} \
VERCEL_TEST_TOKEN=${{ env.VERCEL_TEST_TOKEN }} \
VERCEL_TEST_TEAM=${{ env.VERCEL_TEST_TEAM }} \
NEXT_TEST_JOB=${{ env.NEXT_TEST_JOB }} \
NEXT_TEST_MODE=${{ env.NEXT_TEST_MODE }} \
TEST_TIMINGS_TOKEN=${{ env.TEST_TIMINGS_TOKEN }} \
xvfb-run node run-tests.js --type e2e --timings -g ${{ matrix.group }}/2 -c 1 >> /proc/1/fd/1"
NEXT_JUNIT_TEST_REPORT=${NEXT_JUNIT_TEST_REPORT} \
NEXT_TELEMETRY_DISABLED=${NEXT_TELEMETRY_DISABLED} \
DATADOG_API_KEY=${DATADOG_API_KEY} \
DD_ENV=${DD_ENV} \
VERCEL_TEST_TOKEN=${VERCEL_TEST_TOKEN} \
VERCEL_TEST_TEAM=${VERCEL_TEST_TEAM} \
NEXT_TEST_JOB=${NEXT_TEST_JOB} \
NEXT_TEST_MODE=${NEXT_TEST_MODE} \
TEST_TIMINGS_TOKEN=${TEST_TIMINGS_TOKEN} \
NEXT_TEST_CONTINUE_ON_ERROR=${NEXT_TEST_CONTINUE_ON_ERROR} \
NEXT_EXTERNAL_TESTS_FILTERS=./test/deploy-tests-manifest.json \
xvfb-run node run-tests.js --type e2e --timings -g ${{ matrix.group }} -c 1 >> /proc/1/fd/1"
- name: Save test report as artifacts
if: always()
Expand Down
36 changes: 8 additions & 28 deletions run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,12 @@ async function main() {
}
}

console.log('Running tests with concurrency:', options.concurrency)
console.log(
'Running tests with concurrency:',
options.concurrency,
'in test mode',
process.env.NEXT_TEST_MODE
)

/** @type TestFile[] */
let tests = argv._.filter((arg) =>
Expand Down Expand Up @@ -470,7 +475,8 @@ ${ENDGROUP}`)
RECORD_REPLAY: shouldRecordTestWithReplay,
// run tests in headless mode by default
HEADLESS: 'true',
TRACE_PLAYWRIGHT: 'true',
TRACE_PLAYWRIGHT:
process.env.NEXT_TEST_MODE === 'deploy' ? undefined : 'true',
NEXT_TELEMETRY_DISABLED: '1',
// unset CI env so CI behavior is only explicitly
// tested when enabled
Expand Down Expand Up @@ -691,32 +697,6 @@ ${ENDGROUP}`)
}
}

// Emit test output if test failed or if we're continuing tests on error
if ((!passed || shouldContinueTestsOnError) && isTestJob) {
try {
const testsOutput = await fsp.readFile(
`${test.file}${RESULTS_EXT}`,
'utf8'
)
const obj = JSON.parse(testsOutput)
obj.processEnv = {
NEXT_TEST_MODE: process.env.NEXT_TEST_MODE,
HEADLESS: process.env.HEADLESS,
}
await outputSema.acquire()
if (GROUP) console.log(`${GROUP}Result as JSON for tooling`)
console.log(
`--test output start--`,
JSON.stringify(obj),
`--test output end--`
)
if (ENDGROUP) console.log(ENDGROUP)
outputSema.release()
} catch (err) {
console.log(`Failed to load test output`, err)
}
}

sema.release()
if (dirSema) dirSema.release()
})
Expand Down
11 changes: 11 additions & 0 deletions test/deploy-tests-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": 2,
"suites": {},
"rules": {
"include": [
"test/e2e/**/*.test.{t,j}s{,x}",
"test/production/**/*.test.{t,j}s{,x}"
],
"exclude": []
}
}
5 changes: 5 additions & 0 deletions test/get-test-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ function getTestFilter() {
: null
if (!manifest) return null

console.log(
'Filtering tests using manifest:',
process.env.NEXT_EXTERNAL_TESTS_FILTERS
)

// For the legacy manifest without a version, we assume it's a complete list
// of all the tests.
if (!manifest.version || typeof manifest.version !== 'number') {
Expand Down
3 changes: 3 additions & 0 deletions test/lib/next-modes/next-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export class NextDeployInstance extends NextInstance {
{
cwd: this.testDir,
env: vercelEnv,
reject: false,
}
)

Expand Down Expand Up @@ -117,6 +118,7 @@ export class NextDeployInstance extends NextInstance {
{
cwd: this.testDir,
env: vercelEnv,
reject: false,
}
)

Expand Down Expand Up @@ -151,6 +153,7 @@ export class NextDeployInstance extends NextInstance {
['logs', this._url, '--output', 'raw', ...vercelFlags],
{
env: vercelEnv,
reject: false,
}
)
if (logs.exitCode !== 0) {
Expand Down

0 comments on commit 64c3279

Please sign in to comment.