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

Refactor visual diff tests, and return build status from pr-check.js #11196

Merged
merged 4 commits into from Sep 7, 2017
Merged

Refactor visual diff tests, and return build status from pr-check.js #11196

merged 4 commits into from Sep 7, 2017

Conversation

rsimha
Copy link
Contributor

@rsimha rsimha commented Sep 7, 2017

Fixes #10536

@rsimha rsimha changed the title Refactor visual diff test driver, and return the build status of a Percy build Refactor visual diff tests, and return build status from pr-check.js Sep 7, 2017
@rsimha rsimha self-assigned this Sep 7, 2017
@rsimha
Copy link
Contributor Author

rsimha commented Sep 7, 2017

/to @cramforce @choumx

def waitForBuildCompletion(buildId)
tries = 0
until ['finished', 'failed'].include?(getBuildStatus(buildId)['state'])
sleep(5)
Copy link
Member

Choose a reason for hiding this comment

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

Make 5 a constant, since you refer to it below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

# Args:
# - buildId: ID of the Percy build.
def verifyBuildStatus(buildId)
status = getBuildStatus(buildId)
Copy link
Member

Choose a reason for hiding this comment

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

Since you always call waitForBuildCompletion first, maybe pass in the status that the wait process yielded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

visualTestsConfig = JSON.parse(visualTestsConfigJson)
buildId = runVisualTests(visualTestsConfig)
waitForBuildCompletion(buildId)
verifyBuildStatus(buildId)
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to split this into two build steps?

  1. Start visual diff as early as possible in build
  2. At the end run only the polling after other build steps completed, so that the polling time is minimized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I've optimized the number of build steps between creating and verifying the visual diffs, so that we still fail fast if there are diffs, and yet, don't have to wait around for any amount of time.

@rsimha
Copy link
Contributor Author

rsimha commented Sep 7, 2017

@cramforce, PTAL.

@rsimha rsimha dismissed cramforce’s stale review September 7, 2017 19:45

All feedback addressed. PR approved by @choumx.

@rsimha rsimha merged commit dbbeb84 into ampproject:master Sep 7, 2017
@rsimha rsimha deleted the 2017-09-06-PercyStatusTravis branch September 7, 2017 19:45
@@ -326,6 +329,7 @@ function runAllCommands() {
command.runVisualDiffTests(/* opt_mode */ 'master');
command.runJsonAndLintChecks();
command.runDepAndTypeChecks();
command.verifyVisualDiffTests();
Copy link
Member

Choose a reason for hiding this comment

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

Don't you want to do this after runUnitTests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this was intentional, because by the time runJsonAndLintChecks and runDepAndTypeChecks are run, we can be sure that the visual build has been processed. This way, we can fail early if there are visual diffs, instead of waiting for the unit tests to run.

Let me know if you'd prefer that the check be moved to the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's an example of the timing I describe above: https://travis-ci.org/ampproject/amphtml/jobs/273041116

Copy link
Member

Choose a reason for hiding this comment

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

I think I'd prefer to do it later. I can see that we'll add so many v-diff tests that they will go much slower.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SGTM. Just sent you #11211 with the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants