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: ...@@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- run: yarn install --frozen-lockfile --check-files - 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 - uses: actions/cache@v2
id: cache-build id: cache-build
with: with:
...@@ -47,8 +47,25 @@ jobs: ...@@ -47,8 +47,25 @@ jobs:
key: ${{ github.sha }} key: ${{ github.sha }}
- run: ./check-pre-compiled.sh - run: ./check-pre-compiled.sh
testAll: testUnit:
name: Test All 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 runs-on: ubuntu-latest
needs: build needs: build
env: env:
...@@ -116,7 +133,7 @@ jobs: ...@@ -116,7 +133,7 @@ jobs:
testsPass: testsPass:
name: thank you, next name: thank you, next
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [lint, checkPrecompiled, testAll, testYarnPnP] needs: [lint, checkPrecompiled, testIntegration, testUnit, testYarnPnP]
steps: steps:
- run: exit 0 - run: exit 0
......
...@@ -14,9 +14,6 @@ stages: ...@@ -14,9 +14,6 @@ stages:
- script: dir - script: dir
- script: dir $(System.DefaultWorkingDirectory) - script: dir $(System.DefaultWorkingDirectory)
- script: echo $(Build.SourceVersion) - 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 - powershell: Get-MpComputerStatus
- task: NodeTool@0 - task: NodeTool@0
inputs: inputs:
...@@ -33,19 +30,17 @@ stages: ...@@ -33,19 +30,17 @@ stages:
yarn install --frozen-lockfile --check-files yarn install --frozen-lockfile --check-files
displayName: 'Install dependencies' displayName: 'Install dependencies'
- script: | - 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' displayName: 'Fetch test timing data'
- stage: Test - stage: Test
dependsOn: Build dependsOn: Build
jobs: jobs:
- job: test_ie11 - job: test_ie11_production
pool: pool:
vmImage: 'windows-2019' vmImage: 'windows-2019'
steps: steps:
- checkout: none - 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 - task: NodeTool@0
inputs: inputs:
versionSpec: $(node_version) versionSpec: $(node_version)
...@@ -60,7 +55,31 @@ stages: ...@@ -60,7 +55,31 @@ stages:
- script: | - script: |
yarn testie --forceExit test/integration/production/ yarn testie --forceExit test/integration/production/
displayName: 'Run tests' 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: pool:
vmImage: 'windows-2019' vmImage: 'windows-2019'
strategy: strategy:
...@@ -75,9 +94,6 @@ stages: ...@@ -75,9 +94,6 @@ stages:
group: 4/4 group: 4/4
steps: steps:
- checkout: none - 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: | - script: |
wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value
displayName: 'List Chrome version' displayName: 'List Chrome version'
......
...@@ -16,6 +16,13 @@ const RESULTS_EXT = `.results.json` ...@@ -16,6 +16,13 @@ const RESULTS_EXT = `.results.json`
const isTestJob = !!process.env.NEXT_TEST_JOB const isTestJob = !!process.env.NEXT_TEST_JOB
const TIMINGS_API = `https://next-timings.jjsweb.site/api/timings` 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 () => { ;(async () => {
let concurrencyIdx = process.argv.indexOf('-c') let concurrencyIdx = process.argv.indexOf('-c')
const concurrency = const concurrency =
...@@ -27,15 +34,47 @@ const TIMINGS_API = `https://next-timings.jjsweb.site/api/timings` ...@@ -27,15 +34,47 @@ const TIMINGS_API = `https://next-timings.jjsweb.site/api/timings`
const groupIdx = process.argv.indexOf('-g') const groupIdx = process.argv.indexOf('-g')
const groupArg = groupIdx !== -1 && process.argv[groupIdx + 1] 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) console.log('Running tests with concurrency:', concurrency)
let tests = process.argv.filter((arg) => arg.endsWith('.test.js')) let tests = process.argv.filter((arg) => arg.endsWith('.test.js'))
let prevTimings let prevTimings
if (tests.length === 0) { if (tests.length === 0) {
tests = await glob('**/*.test.js', { tests = (
await glob('**/*.test.js', {
nodir: true, nodir: true,
cwd: path.join(__dirname, 'test'), 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) { if (outputTimings && groupArg) {
console.log('Fetching previous timings data') console.log('Fetching previous timings data')
...@@ -96,7 +135,7 @@ const TIMINGS_API = `https://next-timings.jjsweb.site/api/timings` ...@@ -96,7 +135,7 @@ const TIMINGS_API = `https://next-timings.jjsweb.site/api/timings`
let smallestGroup = groupTimes[0] let smallestGroup = groupTimes[0]
let smallestGroupIdx = 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++) { for (let i = 1; i < groupTotal; i++) {
if (!groups[i]) { if (!groups[i]) {
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