-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
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.
- Try our best to parse the PR number from the commit message (if this fails, just bail and run every single test)
- Verify the PR number by checking if the
TRAVIS_COMMIT(and theHEADcommit in our local checkout) matches themerge_commit_shain the PR endpoint: https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2450 - 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:
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.
