-
Notifications
You must be signed in to change notification settings - Fork 851
Use Karma/BrowserStack to run <model-viewer> tests #1075
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
Changes from 5 commits
0eca663
4c43afb
af3ece3
b1df980
6eb41e3
dc131a9
f3ec62a
67805d5
d311098
518a8fd
230291d
b6db869
ed6cf61
dbe659a
f51c675
1174df8
cbffb27
1158cbf
a5a9a2b
957f425
81ebd9d
0a4e415
459ac03
4eaed2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Unit tests (legacy browsers) | ||
|
||
on: [push] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.x' | ||
|
||
- name: Get npm cache directory | ||
id: npm-cache | ||
run: | | ||
echo "::set-output name=dir::$(npm config get cache)" | ||
|
||
- name: Cache npm packages | ||
uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.npm-cache.outputs.dir }} | ||
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-npm- | ||
|
||
- name: NPM install | ||
run: npm ci | ||
|
||
- name: Lint TypeScript sources | ||
run: npm run lint | ||
|
||
- name: Bootstrap packages | ||
run: npm run bootstrap | ||
|
||
- name: Build packages | ||
run: npm run build | ||
|
||
- name: Generate legacy bundles | ||
run: npm run build:legacy-support | ||
|
||
- name: Unit tests | ||
env: | ||
BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }} | ||
BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }} | ||
run: | | ||
# Don't run Sauce from a forked repo, since the code may not be trusted | ||
# and therefore secrets like the Sauce password are not available. | ||
# GITHUB_HEAD_REF is only defined when building a fork. | ||
if [ ! "$GITHUB_HEAD_REF" ]; then | ||
export USE_BROWSER_STACK=true | ||
fi | ||
npm run test:legacy |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: tests | ||
name: Unit tests | ||
|
||
on: [push, pull_request] | ||
|
||
|
@@ -39,15 +39,13 @@ jobs: | |
|
||
- name: Unit tests | ||
env: | ||
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} | ||
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} | ||
BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }} | ||
BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }} | ||
run: | | ||
# Don't run Sauce from a forked repo, since the code may not be trusted | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above; maybe just do a search for 'Sauce'. |
||
# and therefore secrets like the Sauce password are not available. | ||
# GITHUB_HEAD_REF is only defined when building a fork. | ||
if [ ! "$GITHUB_HEAD_REF" ]; then | ||
export USE_SAUCE=true | ||
export SAUCE_BUILD_ID=model-viewer-tests-${GITHUB_EVENT_NAME}-${GITHUB_ACTION}-${GITHUB_SHA} | ||
export SAUCE_TUNNEL_ID=${SAUCE_BUILD_ID}-tunnel | ||
export USE_BROWSER_STACK=true | ||
fi | ||
npm run test:ci | ||
npm run test |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ install: | |
- npm run bootstrap | ||
- npm run build | ||
script: | ||
- npm run test:ci | ||
- npm run wct-local-chrome | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WCT is gone now, right? |
||
cache: | ||
directories: | ||
- packages/shared-assets/models/glTF-Sample-Models | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,65 +60,117 @@ module.exports = function(config) { | |
], | ||
}); | ||
|
||
if (process.env.USE_SAUCE) { | ||
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) { | ||
if (process.env.USE_BROWSER_STACK) { | ||
if (!process.env.BROWSER_STACK_USERNAME || | ||
!process.env.BROWSER_STACK_ACCESS_KEY) { | ||
throw new Error( | ||
'SAUCE_USERNAME and SAUCE_ACCESS_KEY must be set with USE_SAUCE') | ||
'BROWSER_STACK_USERNAME and BROWSER_STACK_ACCESS_KEY must be set with USE_BROWSER_STACK'); | ||
} | ||
|
||
const sauceLaunchers = { | ||
// 'IE11': { | ||
// base: 'SauceLabs', | ||
// browserName: 'internet explorer', | ||
// version: '11', | ||
// platform: 'Windows 8.1', | ||
// }, | ||
// This terrible hack brought to you by a combination of two things: | ||
// 1. BrowserStack drops the server port when redirecting from localhost | ||
// to bs-local.com on iOS | ||
// 2. karma-browserstack-launcher drops the test-specific browser ID if | ||
// you configure the browser with a custom URL | ||
// A support request to BrowserStack has been filed. | ||
// A related bug has been filed againts karma-browserstack-launcher | ||
// @see https://github.com/karma-runner/karma-browserstack-launcher/issues/172 | ||
const assign = Object.assign; | ||
const newAssign = function(...args) { | ||
// If we know this to be one very specific Object.assign call, then grab | ||
// the test-specific browser ID and append it to our URL: | ||
// @see https://github.com/karma-runner/karma-browserstack-launcher/blob/76dbfd0db6db46f4f85012cfe3c1f4c3accd2e44/index.js#L143 | ||
if (args[2] != null && args[2].url === 'http://bs-local.com:9876') { | ||
console.warn('PATCHING URL TO ADD ID'); | ||
const config = args[0]; | ||
const browser = args[2]; | ||
const query = config.url.split('?')[1]; | ||
browser.url = `${browser.url}?${query}`; | ||
} | ||
return assign.apply(this, args); | ||
}; | ||
// Something in Karma deps actually asserts the sub-keys of Object.assign, | ||
// so make sure to copy those over too: | ||
assign.call(Object, newAssign, assign); | ||
Object.assign = newAssign; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I love JavaScript! 😈 |
||
|
||
const browserStackLaunchers = { | ||
'Edge (latest)': { | ||
base: 'SauceLabs', | ||
browserName: 'microsoftedge', | ||
version: 'latest', | ||
platform: 'Windows 10', | ||
base: 'BrowserStack', | ||
os: 'Windows', | ||
os_version: '10', | ||
browser: 'Edge', | ||
browser_version: 'latest', | ||
}, | ||
'Edge 79.0': { | ||
base: 'BrowserStack', | ||
os: 'Windows', | ||
os_version: '10', | ||
browser: 'Edge', | ||
browser_version: '80.0', | ||
}, | ||
'Firefox (latest)': { | ||
base: 'BrowserStack', | ||
os: 'Windows', | ||
os_version: '10', | ||
browser: 'Firefox', | ||
browser_version: 'latest', | ||
}, | ||
'Safari (latest - 1)': { | ||
base: 'SauceLabs', | ||
browserName: 'safari', | ||
version: 'latest-1', | ||
platform: 'macOS 10.13', | ||
'Firefox 72.0': { | ||
base: 'BrowserStack', | ||
os: 'Windows', | ||
os_version: '10', | ||
browser: 'Firefox', | ||
browser_version: '72.0', | ||
}, | ||
'Safari (latest)': { | ||
base: 'SauceLabs', | ||
browserName: 'safari', | ||
version: 'latest', | ||
platform: 'macOS 10.13', | ||
base: 'BrowserStack', | ||
os: 'OS X', | ||
os_version: 'Catalina', | ||
browser: 'safari', | ||
browser_version: 'latest', | ||
}, | ||
'Firefox (latest)': { | ||
base: 'SauceLabs', | ||
browserName: 'firefox', | ||
platform: 'Windows 10', | ||
version: 'latest' | ||
'Safari 12.1': { | ||
base: 'BrowserStack', | ||
os: 'OS X', | ||
os_version: 'Mojave', | ||
browser: 'safari', | ||
browser_version: '12.1', | ||
}, | ||
'iOS Safari (iOS 13)': { | ||
base: 'BrowserStack', | ||
os: 'iOS', | ||
os_version: '12', | ||
device: 'iPhone 8', | ||
browser: 'iPhone', | ||
real_mobile: 'true', | ||
// BrowserStack seems to drop the port when redirecting to this special | ||
// domain so we go there directly instead: | ||
url: 'http://bs-local.com:9876' | ||
}, | ||
'iOS Safari (iOS 12)': { | ||
base: 'BrowserStack', | ||
os: 'iOS', | ||
os_version: '12', | ||
device: 'iPhone 7', | ||
browser: 'iPhone', | ||
real_mobile: 'true', | ||
// BrowserStack seems to drop the port when redirecting to this special | ||
// domain so we go there directly instead: | ||
url: 'http://bs-local.com:9876' | ||
}, | ||
'Firefox (latest - 1)': { | ||
base: 'SauceLabs', | ||
browserName: 'firefox', | ||
platform: 'Windows 10', | ||
version: 'latest-1' | ||
} | ||
}; | ||
|
||
config.set({ | ||
sauceLabs: { | ||
browserStack: { | ||
idleTimeout: 600, | ||
testName: '3DOM Unit Tests', | ||
build: process.env.SAUCE_BUILD_ID, | ||
tunnelIdentifier: process.env.SAUCE_TUNNEL_ID, | ||
name: '3DOM Unit Tests', | ||
}, | ||
// Attempt to de-flake Sauce Labs tests on TravisCI. | ||
transports: ['polling'], | ||
browserDisconnectTolerance: 1, | ||
reporters: ['saucelabs', 'mocha'], | ||
|
||
customLaunchers: sauceLaunchers, | ||
browsers: [...config.browsers, ...Object.keys(sauceLaunchers)], | ||
reporters: ['BrowserStack', 'mocha'], | ||
|
||
customLaunchers: browserStackLaunchers, | ||
browsers: [...config.browsers, ...Object.keys(browserStackLaunchers)], | ||
}); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is still true, we should probably at least update that it's not Sauce anymore.