Unverified Commit 18494fe3 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Break-up unit tests to separate step (#18992)

parent 70d8d8c9
......@@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- run: yarn install --frozen-lockfile --check-files
- run: node run-tests.js --timings --write-timings -g 1/4
- run: node run-tests.js --timings --write-timings -g 1/1
- uses: actions/cache@v2
id: cache-build
with:
......@@ -47,8 +47,25 @@ jobs:
key: ${{ github.sha }}
- run: ./check-pre-compiled.sh
testAll:
name: Test All
testUnit:
name: Test Unit
runs-on: ubuntu-latest
needs: build
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
HEADLESS: true
steps:
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- run: node run-tests.js --timings --type unit -g 1/1
testIntegration:
name: Test Integration
runs-on: ubuntu-latest
needs: build
env:
......@@ -116,7 +133,7 @@ jobs:
testsPass:
name: thank you, next
runs-on: ubuntu-latest
needs: [lint, checkPrecompiled, testAll, testYarnPnP]
needs: [lint, checkPrecompiled, testIntegration, testUnit, testYarnPnP]
steps:
- run: exit 0
......
......@@ -14,9 +14,6 @@ stages:
- script: dir
- script: dir $(System.DefaultWorkingDirectory)
- script: echo $(Build.SourceVersion)
- powershell: Set-MpPreference -ExclusionPath $(System.DefaultWorkingDirectory)
- powershell: Set-MpPreference -ExclusionPath $(Pipeline.Workspace)/.yarn
- powershell: Set-MpPreference -DisableIntrusionPreventionSystem $true -DisableIOAVProtection $true -DisableRealtimeMonitoring $true -DisableScriptScanning $true -EnableControlledFolderAccess Disabled -EnableNetworkProtection AuditMode -Force -MAPSReporting Disabled -SubmitSamplesConsent NeverSend
- powershell: Get-MpComputerStatus
- task: NodeTool@0
inputs:
......@@ -33,19 +30,17 @@ stages:
yarn install --frozen-lockfile --check-files
displayName: 'Install dependencies'
- script: |
node run-tests.js --timings --write-timings --azure -g 1/4
node run-tests.js --timings --write-timings --azure -g 1/1
displayName: 'Fetch test timing data'
- stage: Test
dependsOn: Build
jobs:
- job: test_ie11
- job: test_ie11_production
pool:
vmImage: 'windows-2019'
steps:
- checkout: none
- powershell: Set-MpPreference -ExclusionPath $(System.DefaultWorkingDirectory)
- powershell: Set-MpPreference -ExclusionPath $(Pipeline.Workspace)/.yarn
- powershell: Set-MpPreference -DisableIntrusionPreventionSystem $true -DisableIOAVProtection $true -DisableRealtimeMonitoring $true -DisableScriptScanning $true -EnableControlledFolderAccess Disabled -EnableNetworkProtection AuditMode -Force -MAPSReporting Disabled -SubmitSamplesConsent NeverSend
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
......@@ -60,7 +55,31 @@ stages:
- script: |
yarn testie --forceExit test/integration/production/
displayName: 'Run tests'
- job: test_chrome
- job: test_unit
pool:
vmImage: 'windows-2019'
steps:
- checkout: none
- script: |
wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value
displayName: 'List Chrome version'
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
displayName: 'Install Node.js'
- task: Cache@2
inputs:
# use deterministic cache key that is specific
# to this test run
key: $(Build.SourceVersion)
path: $(System.DefaultWorkingDirectory)
displayName: Cache Build
- script: |
node run-tests.js -g 1/1 --timings --azure --type unit
displayName: 'Run tests'
- job: test_chrome_integration
pool:
vmImage: 'windows-2019'
strategy:
......@@ -75,9 +94,6 @@ stages:
group: 4/4
steps:
- checkout: none
- powershell: Set-MpPreference -ExclusionPath $(System.DefaultWorkingDirectory)
- powershell: Set-MpPreference -ExclusionPath $(Pipeline.Workspace)/.yarn
- powershell: Set-MpPreference -DisableIntrusionPreventionSystem $true -DisableIOAVProtection $true -DisableRealtimeMonitoring $true -DisableScriptScanning $true -EnableControlledFolderAccess Disabled -EnableNetworkProtection AuditMode -Force -MAPSReporting Disabled -SubmitSamplesConsent NeverSend
- script: |
wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value
displayName: 'List Chrome version'
......
......@@ -16,6 +16,13 @@ const RESULTS_EXT = `.results.json`
const isTestJob = !!process.env.NEXT_TEST_JOB
const TIMINGS_API = `https://next-timings.jjsweb.site/api/timings`
const UNIT_TEST_EXT = '.unit.test.js'
const DEV_TEST_EXT = '.dev.test.js'
const PROD_TEST_EXT = '.prod.test.js'
// which types we have configured to run separate
const configuredTestTypes = [UNIT_TEST_EXT]
;(async () => {
let concurrencyIdx = process.argv.indexOf('-c')
const concurrency =
......@@ -27,14 +34,46 @@ const TIMINGS_API = `https://next-timings.jjsweb.site/api/timings`
const groupIdx = process.argv.indexOf('-g')
const groupArg = groupIdx !== -1 && process.argv[groupIdx + 1]
const testTypeIdx = process.argv.indexOf('--type')
const testType = process.argv[testTypeIdx + 1]
let filterTestsBy
switch (testType) {
case 'unit':
filterTestsBy = UNIT_TEST_EXT
break
case 'dev':
filterTestsBy = DEV_TEST_EXT
break
case 'production':
filterTestsBy = PROD_TEST_EXT
break
case 'all':
filterTestsBy = 'none'
break
default:
break
}
console.log('Running tests with concurrency:', concurrency)
let tests = process.argv.filter((arg) => arg.endsWith('.test.js'))
let prevTimings
if (tests.length === 0) {
tests = await glob('**/*.test.js', {
nodir: true,
cwd: path.join(__dirname, 'test'),
tests = (
await glob('**/*.test.js', {
nodir: true,
cwd: path.join(__dirname, 'test'),
})
).filter((test) => {
// only include the specified type
if (filterTestsBy) {
return filterTestsBy === 'none' ? true : test.endsWith(filterTestsBy)
// include all except the separately configured types
} else {
return !configuredTestTypes.some((type) => test.endsWith(type))
}
})
if (outputTimings && groupArg) {
......@@ -96,7 +135,7 @@ const TIMINGS_API = `https://next-timings.jjsweb.site/api/timings`
let smallestGroup = groupTimes[0]
let smallestGroupIdx = 0
// get the samllest group time to add current one to
// get the smallest group time to add current one to
for (let i = 1; i < groupTotal; i++) {
if (!groups[i]) {
groups[i] = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment