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

Speed up "push" builds. #2480

Closed
dhermes opened this issue Oct 3, 2016 · 1 comment
Closed

Speed up "push" builds. #2480

dhermes opened this issue Oct 3, 2016 · 1 comment
Assignees

Comments

@dhermes
Copy link
Contributor

dhermes commented Oct 3, 2016

Travis has two build types that we use: "push" and "pull request". On a "pull request" commit the TRAVIS_BRANCH env. var. tells us what we are diff-ing against and makes it easy to limit the build jobs based on the changed files.

In "push" builds, the best we have is TRAVIS_COMMIT_RANGE but this is not a very dependable value. I propose we rely instead on the GitHub API to determine the changed files.

  1. Try our best to parse the PR number from the commit message (if this fails, just bail and run every single test)
  2. Verify the PR number by checking if the TRAVIS_COMMIT (and the HEAD commit in our local checkout) matches the merge_commit_sha in the PR endpoint: https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2450
  3. Once we have the PR, hit the PR files endpoint to get a list of changed files, e.g.: https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2461/files

As an alternative to the first step, there is an "unpublished" API which helps associate a commit SHA with a PR. For example, see the parenthetical 2461 below:

screen_shot_001

which tells us that 4e8afa8 came as part of #2461. The actual API returns an SVG with the payload containing

          <li class="pull-request">(<a href="/GoogleCloudPlatform/google-cloud-python/pull/2461" title="Merged Pull Request: Clarify docs on last 5 minutes query">#2461</a>)</li>

The API simply requires the commit hash in TRAVIS_COMMIT (i.e. just the HEAD commit on our local checkout), e.g. https://github.com/GoogleCloudPlatform/google-cloud-python/branch_commits/4e8afa8c3877376d7e9a6df79e6a272ae1cdfee7


@tseaver @jonparrott PTAL and LMKWYT

FYI this will build on top of work done for #2277.

@dhermes dhermes added the build label Oct 3, 2016
@dhermes dhermes self-assigned this Oct 3, 2016
@dhermes
Copy link
Contributor Author

dhermes commented Oct 3, 2016

Also worth noting that even if the files endpoint didn't exist, the PR endpoint has a base key which tells what state the main branch was in before the PR was merged. For example, https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2450 has

  "base": {
    "label": "GoogleCloudPlatform:master",
    "ref": "master",
    "sha": "042daf5f2db6fdcc5323cfbdbcabcbf241fa7278",
    ...

dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 5, 2016
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 5, 2016
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants