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

add module build visual diffs #32865

Closed
wants to merge 7 commits into from

Conversation

erwinmombay
Copy link
Member

@erwinmombay erwinmombay commented Feb 24, 2021

add a module build visual diff job using the gulp serve --new_server task which does a transform of the documents

@amp-owners-bot
Copy link

amp-owners-bot bot commented Feb 24, 2021

Hey @rsimha! These files were changed:

.circleci/config.yml
build-system/pr-check/visual-diff-tests.js

Hey @danielrozenberg! These files were changed:

build-system/tasks/visual-diff/index.js

Copy link
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a more maintainable way to do this is to make the job script visual-diff-tests.js take a command line arg, and parametrize the job definition in config.yml.

@danielrozenberg
Copy link
Member

danielrozenberg commented Feb 24, 2021

I think a more maintainable way to do this is to make the job script visual-diff-tests.js take a command line arg, and parametrize the job definition in config.yml.

#32808 has an example of how to do it

@erwinmombay erwinmombay force-pushed the modnomod-viz-diff branch 8 times, most recently from a37c730 to 9bf1029 Compare February 25, 2021 17:35
@erwinmombay erwinmombay changed the title [WIP] add module build visual diffs add module build visual diffs Feb 25, 2021
Copy link
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR is looking great! Just a few comments below.

build-system/tasks/visual-diff/index.js Outdated Show resolved Hide resolved
build-system/tasks/serve.js Outdated Show resolved Hide resolved
build-system/tasks/serve.js Outdated Show resolved Hide resolved
build-system/pr-check/visual-diff-tests.js Outdated Show resolved Hide resolved
.circleci/config.yml Outdated Show resolved Hide resolved
.circleci/config.yml Outdated Show resolved Hide resolved
@danielrozenberg
Copy link
Member

Since both jobs use the same Percy write-only token, they'll both end up in the same project, and Percy will only report one as a status to GitHub - whichever of the two ends later would override the earlier.

Two possible solutions to this are:

  1. create separate projects (ampproject/amphtml-module and ampproject/amphtml-nomodule) with their own tokens, passed as parameters in the job matrix
  2. merge the two by running them in a single job by running the same test suite twice, on two executions of the server (with/without esm) and with adding (module)/(nomodule) to the individual snapshot names to differentiate between the two

I am very slightly leaning towards option #1, but don't really care either way. @rsimha can you think of how to pass the obfuscated token to the PR jobs?

@rsimha
Copy link
Contributor

rsimha commented Feb 25, 2021

Since both jobs use the same Percy write-only token, they'll both end up in the same project, and Percy will only report one as a status to GitHub - whichever of the two ends later would override the earlier.

Oooh, excellent point, and good catch! TBH, after looking at the build logs on CircleCI and on Percy, I am leaning hard towards option 2. Here is my rationale:

  • When you look at a Percy build for a single commit, it's useful to see all results (from module and nomodule) on one page. This way, if module breaks something but nomodule does not, it will be very obvious.
  • Finalizing a visual build for a given commit from one CI job once and for all seems far simpler than trying to coordinate across two jobs, not to mention the cost of maintaining two tokens and two projects.
  • Looking at the actual cost of parallelizing on CircleCI, VM setup / install takes ~2m, and running of all visual tests takes ~2m. I think it's better to test both build types from one job that runs for ~6m. (I assume it will work if we make the job wait for both the module and nomodule builds, download both, and run the correct kind of test server for each testing run.)

WDYT @erwinmombay @danielrozenberg? Maybe a little extra trouble up front to get this to work, but worth it in the end?

@danielrozenberg
Copy link
Member

Again, no strong feelings either way. The overhead having two tokens/projects isn't that serious though, and we already discussed having separate projects for Chrome and for Firefox once Puppeteer fully supports the latter

@rsimha
Copy link
Contributor

rsimha commented Feb 25, 2021

Again, no strong feelings either way. The overhead having two tokens/projects isn't that serious though, and we already discussed having separate projects for Chrome and for Firefox once Puppeteer fully supports the latter

Okay, in that case, I'll lower my hard preference to a mild preference, and let @erwinmombay chime in since he's going to be the primary user of the Percy builds. 😃

Re: adding new tokens to our CircleCI project, it's no trouble, and I can help do it. 👍

@erwinmombay
Copy link
Member Author

@rsimha i think i would prefer option 2, just because seeing the results in a single page seems ideal

Copy link
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting closer! A few more comments below, and two critical changes. (Right now, the PR is neither downloading ESM binaries nor serving them during testing 😃)

.circleci/config.yml Outdated Show resolved Hide resolved
.circleci/config.yml Outdated Show resolved Hide resolved
build-system/pr-check/visual-diff-tests.js Outdated Show resolved Hide resolved
build-system/pr-check/visual-diff-tests.js Outdated Show resolved Hide resolved
build-system/pr-check/visual-diff-tests.js Outdated Show resolved Hide resolved
build-system/tasks/serve.js Outdated Show resolved Hide resolved
build-system/tasks/visual-diff/index.js Outdated Show resolved Hide resolved
build-system/tasks/visual-diff/index.js Outdated Show resolved Hide resolved
build-system/tasks/serve.js Outdated Show resolved Hide resolved
Copy link
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more comments that I think will simplify the code.

build-system/tasks/serve.js Outdated Show resolved Hide resolved
build-system/tasks/serve.js Outdated Show resolved Hide resolved
build-system/tasks/serve.js Outdated Show resolved Hide resolved
'new_server' in serverOptions ? serverOptions.new_server : argv.new_server
) {
try {
buildNewServer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that in #30681, you added a call to buildNewServer() to integration.js. I think that change should be reverted because the server startup logic should entirely live in server.js. Other tasks should trust the server to start itself correctly. Can we clean that up too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with the statement, but buildNewServer isnt really start up logic and more compile logic. the code essentially isnt there (since its in typescript) before we make this call. buildNewServer i believe should be done before the task, i just placed it there since its the latest we can call it to make "lazy"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think it would be imperative i make this change here, or can i follow up on a separate PR? I am working on it already but i wasn't sure if i could clean separate the issue out in another PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#32891 makes this change and cleans up integration.js. Once reviewed and merged, we shouldn't need any of these changes.

Comment on lines 49 to 61
timedExecOrDie('gulp visual-diff --nobuild --esm');
timedExecOrDie('gulp visual-diff --nobuild');
} else {
timedExecOrDie('gulp visual-diff --empty --esm');
timedExecOrDie('gulp visual-diff --empty');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... this still generates two separate builds and has Percy report the 2nd one

Basically you have to loop through both module and nomodule gulp serve inside the visual-diff/index.js job - everything needs to run from when launchPercyAgent() is called and finished before exitPercyAgent_() - this is what starts and finalizes a build on Percy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. ill make the change

@stale
Copy link

stale bot commented Oct 15, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Inactive for one year or more label Oct 15, 2022
@stale stale bot closed this Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Inactive for one year or more WG: infra WG: performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants