Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Web CI to use data dir under Agent.TempDirectory #20074

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions js/web/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const karmaPlugins = args['karma-plugins'] || undefined;
const timeoutMocha = args['timeout-mocha'] || 60000;
const forceLocalHost = !!args['force-localhost'];

// user data directory; will be passed to the Edge/Chrome/ChromeCanary/Firefox launchers
const userDataDir = args['user-data-dir'];
// parse chromium flags
let chromiumFlags = args['chromium-flags'];
if (!chromiumFlags) {
Expand Down Expand Up @@ -87,9 +89,10 @@ module.exports = function(config) {
listenAddress,
customLaunchers: {
// Chromium-based browsers
EdgeTest: {base: 'Edge', flags: chromiumFlags},
ChromeTest: {base: 'Chrome', flags: chromiumFlags},
ChromeCanaryTest: {base: 'ChromeCanary', flags: chromiumFlags},
EdgeTest: {base: 'Edge', flags: chromiumFlags, edgeDataDir: userDataDir},
ChromeTest: {base: 'Chrome', flags: chromiumFlags, chromeDataDir: userDataDir},
ChromeCanaryTest: {base: 'ChromeCanary', flags: chromiumFlags, chromeDataDir: userDataDir},
FirefoxTest: {base: 'Firefox', profile: userDataDir},

//
// ==== BrowserStack browsers ====
Expand Down
6 changes: 6 additions & 0 deletions js/web/script/test-runner-cli-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Options:

--no-sandbox This flag will be passed to Chrome.
Sometimes Chrome need this flag to work together with Karma.
--user-data-dir=<...> This flag will be passed to browsers to specify the user data directory.
--chromium-flags=<...> This flag will be passed to Chrome and Edge browsers. Can be used multiple times.

Examples:
Expand Down Expand Up @@ -195,6 +196,7 @@ export interface TestRunnerCliArgs {
webnnOptions?: InferenceSession.WebNNExecutionProviderOption;
globalEnvFlags?: Test.Options['globalEnvFlags'];
noSandbox?: boolean;
userDataDir?: string;
chromiumFlags: string[];
}

Expand Down Expand Up @@ -477,6 +479,9 @@ export function parseTestRunnerCliArgs(cmdlineArgs: string[]): TestRunnerCliArgs
// Option: --no-sandbox
const noSandbox = !!args['no-sandbox'];

// Option: --user-data-dir
const userDataDir = args['user-data-dir'];

// parse chromium flags
let chromiumFlags = args['chromium-flags'];
if (!chromiumFlags) {
Expand Down Expand Up @@ -515,6 +520,7 @@ export function parseTestRunnerCliArgs(cmdlineArgs: string[]): TestRunnerCliArgs
wasmOptions,
globalEnvFlags,
noSandbox,
userDataDir,
chromiumFlags
};
}
5 changes: 4 additions & 1 deletion js/web/script/test-runner-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ async function main() {
karmaArgs.push('--log-level debug');
}
karmaArgs.push(`--bundle-mode=${args.bundleMode}`);
if (args.userDataDir) {
karmaArgs.push(`--user-data-dir="${args.userDataDir}"`);
}
karmaArgs.push(...chromiumFlags.map(flag => `--chromium-flags=${flag}`));
if (browser.startsWith('Edge')) {
// There are currently 2 Edge browser launchers:
Expand Down Expand Up @@ -671,7 +674,7 @@ async function main() {
case 'edge':
return 'EdgeTest';
case 'firefox':
return 'Firefox';
return 'FirefoxTest';
case 'electron':
return 'Electron';
case 'safari':
Expand Down
50 changes: 40 additions & 10 deletions tools/ci_build/github/azure-pipelines/templates/win-web-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,31 +153,61 @@ jobs:
errorActionPreference: stop
displayName: 'Pack NPM packages'
- script: |
npm test -- -e=chrome -b=webgl,wasm --karma-debug
powershell "Get-WmiObject Win32_Process -Filter \"name = 'chrome.exe'\" | Format-List CommandLine"
displayName: 'Check active Chrome processes (before test)'
condition: and(succeeded(), eq('$(Agent.Diagnostic)', 'true'))
- script: |
mkdir $(Agent.TempDirectory)\web\test\01
npm test -- -e=chrome -b=webgl,wasm --user-data-dir=$(Agent.TempDirectory)\web\test\01
workingDirectory: '$(Build.SourcesDirectory)\js\web'
displayName: 'Run ort-web tests (wasm,webgl backend)'
condition: eq('${{ parameters.RunWebGpuTests }}', 'false')
condition: and(succeeded(), eq('${{ parameters.RunWebGpuTests }}', 'false'))
- script: |
powershell "Get-WmiObject Win32_Process -Filter \"name = 'chrome.exe'\" | Format-List CommandLine"
displayName: 'Check active Chrome processes (before test)'
condition: and(succeeded(), eq('$(Agent.Diagnostic)', 'true'))
- script: |
npm test -- -e=chrome -b=webgl,wasm,webgpu --karma-debug $(webgpuCommandlineExtraFlags)
mkdir $(Agent.TempDirectory)\web\test\02
npm test -- -e=chrome -b=webgl,wasm,webgpu $(webgpuCommandlineExtraFlags) --user-data-dir=$(Agent.TempDirectory)\web\test\02
workingDirectory: '$(Build.SourcesDirectory)\js\web'
displayName: 'Run ort-web tests (ALL backends)'
condition: eq('${{ parameters.RunWebGpuTests }}', 'true')
condition: and(succeeded(), eq('${{ parameters.RunWebGpuTests }}', 'true'))
- script: |
powershell "Get-WmiObject Win32_Process -Filter \"name = 'chrome.exe'\" | Format-List CommandLine"
displayName: 'Check active Chrome processes (before test)'
condition: and(succeeded(), eq('$(Agent.Diagnostic)', 'true'))
- script: |
npm test -- suite1 -e=chrome -b=webgpu --io-binding=gpu-tensor --karma-debug $(webgpuCommandlineExtraFlags)
mkdir $(Agent.TempDirectory)\web\test\03
npm test -- suite1 -e=chrome -b=webgpu --io-binding=gpu-tensor $(webgpuCommandlineExtraFlags) --user-data-dir=$(Agent.TempDirectory)\web\test\03
workingDirectory: '$(Build.SourcesDirectory)\js\web'
displayName: 'Run ort-web tests (Suite1, webgpu, IO-binding=gpu-tensor)'
condition: eq('${{ parameters.RunWebGpuTests }}', 'true')
condition: and(succeeded(), eq('${{ parameters.RunWebGpuTests }}', 'true'))
- script: |
npm test -- suite1 -e=chrome -b=webgpu --io-binding=gpu-location --karma-debug $(webgpuCommandlineExtraFlags)
powershell "Get-WmiObject Win32_Process -Filter \"name = 'chrome.exe'\" | Format-List CommandLine"
displayName: 'Check active Chrome processes (before test)'
condition: and(succeeded(), eq('$(Agent.Diagnostic)', 'true'))
- script: |
mkdir $(Agent.TempDirectory)\web\test\04
npm test -- suite1 -e=chrome -b=webgpu --io-binding=gpu-location $(webgpuCommandlineExtraFlags) --user-data-dir=$(Agent.TempDirectory)\web\test\04
workingDirectory: '$(Build.SourcesDirectory)\js\web'
displayName: 'Run ort-web tests (Suite1, webgpu, IO-binding=gpu-location)'
condition: eq('${{ parameters.RunWebGpuTests }}', 'true')
condition: and(succeeded(), eq('${{ parameters.RunWebGpuTests }}', 'true'))
- script: |
powershell "Get-WmiObject Win32_Process -Filter \"name = 'chrome.exe'\" | Format-List CommandLine"
displayName: 'Check active Chrome processes (before test)'
condition: and(succeeded(), eq('$(Agent.Diagnostic)', 'true'))
- script: |
npm test -- --webgl.pack -b=webgl -e=chrome --karma-debug
mkdir $(Agent.TempDirectory)\web\test\05
npm test -- --webgl.pack -b=webgl -e=chrome --user-data-dir=$(Agent.TempDirectory)\web\test\05
workingDirectory: '$(Build.SourcesDirectory)\js\web'
displayName: 'Run ort-web tests - WebGL: packed mode'
- script: |
npm test -- --wasm.proxy -b=wasm -e=chrome --karma-debug
powershell "Get-WmiObject Win32_Process -Filter \"name = 'chrome.exe'\" | Format-List CommandLine"
displayName: 'Check active Chrome processes (before test)'
condition: and(succeeded(), eq('$(Agent.Diagnostic)', 'true'))
- script: |
mkdir $(Agent.TempDirectory)\web\test\06
npm test -- --wasm.proxy -b=wasm -e=chrome --user-data-dir=$(Agent.TempDirectory)\web\test\06
workingDirectory: '$(Build.SourcesDirectory)\js\web'
displayName: 'Run ort-web tests - WebAssembly: proxy'
condition: and(succeeded(), eq('${{ parameters.BuildConfig }}', 'Release'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,30 @@ jobs:
workingDirectory: '$(Build.SourcesDirectory)\js\web'
displayName: 'npm ci /js/web/'
- script: |
npm test -- suite0 -b=wasm,webgl --wasm.initTimeout=30000 --file-cache
powershell "Get-WmiObject Win32_Process -Filter \"name = 'chrome.exe'\" | Format-List CommandLine"
displayName: 'Check active Chrome processes (before test)'
condition: and(succeeded(), eq('$(Agent.Diagnostic)', 'true'))
- script: |
mkdir $(Agent.TempDirectory)\web\test_multi_browsers\01
npm test -- suite0 -e=chrome -b=wasm,webgl --wasm.initTimeout=30000 --file-cache --user-data-dir=$(Agent.TempDirectory)\web\test_multi_browsers\01
workingDirectory: '$(Build.SourcesDirectory)\js\web'
displayName: 'npm test (Suite0, Chrome)'
- script: |
npm test -- suite0 -b=wasm,webgl -e=firefox --wasm.initTimeout=30000 --file-cache
powershell "Get-WmiObject Win32_Process -Filter \"name = 'firefox.exe'\" | Format-List CommandLine"
displayName: 'Check active Firefox processes (before test)'
condition: and(succeeded(), eq('$(Agent.Diagnostic)', 'true'))
- script: |
mkdir $(Agent.TempDirectory)\web\test_multi_browsers\02
npm test -- suite0 -b=wasm,webgl -e=firefox --wasm.initTimeout=30000 --file-cache --user-data-dir=$(Agent.TempDirectory)\web\test_multi_browsers\02
workingDirectory: '$(Build.SourcesDirectory)\js\web'
displayName: 'npm test (Suite0, Firefox)'
- script: |
npm test -- suite0 -b=wasm,webgl -e=edge --wasm.initTimeout=30000 --file-cache
powershell "Get-WmiObject Win32_Process -Filter \"name = 'msedge.exe'\" | Format-List CommandLine"
displayName: 'Check active Edge processes (before test)'
condition: and(succeeded(), eq('$(Agent.Diagnostic)', 'true'))
- script: |
mkdir $(Agent.TempDirectory)\web\test_multi_browsers\03
npm test -- suite0 -b=wasm,webgl -e=edge --wasm.initTimeout=30000 --file-cache --user-data-dir=$(Agent.TempDirectory)\web\test_multi_browsers\03
workingDirectory: '$(Build.SourcesDirectory)\js\web'
displayName: 'npm test (Suite0, Edge)'
- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
Expand Down
Loading