-
Notifications
You must be signed in to change notification settings - Fork 822
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
Use Karma/BrowserStack to run <model-viewer> tests #1075
Conversation
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.
Awesome! I remember one of the first things you told me when I joined this project was that we should purge Sauce Labs with fire. That day has finally arrived.
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 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.
.github/workflows/unit-tests.yml
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above; maybe just do a search for 'Sauce'.
.travis.yml
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
WCT is gone now, right?
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I love JavaScript! 😈
// domain so we go there directly instead: | ||
url: 'http://bs-local.com:9876' | ||
}, | ||
'iOS Safari (iOS 12)': { |
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.
Should we add an android device someday? Not saying today is that day...
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.
Yes, let's make it another day though. Tracked in #691
"focus-visible": "^5.0.1", | ||
"fullscreen-polyfill": "^1.0.2", | ||
"http-server": "^0.12.1", |
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.
Better than local-web-server?
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.
Yes, and consistent with the other packages
"intersection-observer": "^0.5.1", | ||
"lit-html": "^1.1.2", | ||
"local-web-server": "^2.6.0", | ||
"make-dir": "^1.3.0", | ||
"mocha": "^5.2.0", |
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.
Does karma-mocha not include mocha?
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.
It does not, it manages the integration between the two.
|
||
if [[ "${TRAVIS_PULL_REQUEST}" = "false" && "${TRAVIS_BRANCH}" != "master" ]]; then |
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.
Does this mean third parties start browserStack tests, or did this logic end up elsewhere?
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.
This got moved elsewhere
@@ -50,7 +50,7 @@ suite('decorators', () => { | |||
customElements.define(tagName, class extends StyleableElement {}); | |||
|
|||
element = document.createElement(tagName) as StyleableElement; | |||
document.body.appendChild(element); | |||
document.body.insertBefore(element, document.body.firstChild); |
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.
What's all this about? Something browser-specific?
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.
Now that we are running in vanilla mocha, without additional intervention all of our elements get appended after the Mocha test results. This ensures that our test elements are inserted before those Mocha DOM elements.
@@ -338,10 +338,10 @@ suite('ModelViewerElementBase', () => { | |||
|
|||
test('sets a model within viewport to be visible', async () => { | |||
await until(() => { | |||
return elements[0][$scene].visible; | |||
return elements[2][$scene].visible; |
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.
Why this change?
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.
Because we reversed the order that the elements are inserted to the document.
7ede272
to
518a8fd
Compare
I'm happy to share that "full" unit test runs (including Chrome, 2 x Firefox, 2 x Desktop Safari, 2 x MS Edge, 2 x iOS Safari, and IE11 across both @google/model-viewer and @google/3dom) are finishing in ~8 minutes. Unit tests and fidelity tests both complete in under 10 minutes. This is a 55-65% reduction in test time compared to our Travis/WCT/Sauce builds (example build) even though we are running tests against additional browser targets. |
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.
Thank you for slogging through this, @cdata!
@@ -20,11 +20,8 @@ set -x | |||
|
|||
if [ "${TEST_TYPE}" = "unit" ]; then | |||
|
|||
npm run test | |||
npm run wct-local-chrome |
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.
Still confused by this name; are we really still using WCT?
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.
Good catch, this script is vestigial and has been removed 👍
This change grew substantially out of scope, but one thing led to another and now our test toolchain and CI pipeline is totally different ✨
This change updates our pipeline to run in Github Actions instead of Travis. This is good because it brings us closer to Github's well-tread cowpaths, and moves us away from Travis which seems to be more-or-less frozen in time feature/support-wise (probably because of their recent sale).
Secondly, this change moves us from SauceLabs to BrowserStack for our x-browser testing needs. This has generally yielded an increase in overall performance for our x-browser tests, as well as improved reliability for iOS Safari tests and unlocks the potential to re-introduce our Android Chrome tests in the future. We might even get crazy and add tests for Samsung Internet someday. Future work on this tracked in #691 .
Thirdly, this change moves our test toolchain from WCT (which is deprecated) to Karma (which has an uncertain future, but is way better than WCT and has active support for now). Thankfully, only minimal changes were required to our test suites to support this shift. Most of the time spent on this change went to ensuring that the combination of Karma, BrowserStack and Github Actions all worked in harmony and as intended.
And the coup de grâce:
npm run dev
does something useful for the@google/model-viewer
package now (more or less what it does for@google/3dom
), so running all the build tools simultaneously in a single terminal just got easier.A final note on Travis: this PR continues to run Travis builds even though the Travis config has been removed. Travis has to be manually turned off for our repository before those status lines will go away. I will do that after this PR is merged.
An example 3P PR has been set up here to demonstrate how the build changes: #1082