Travis failed push but passed PR

Background

This repository is configured in Travis CI to run tests on two environments - named pr and push.

A Pull Request (pr) build will be named continuous-integration/travis-ci/pr and from the docs:

Rather than test the commits that have been pushed to the branch the pull request is from, we test the merge between the origin and the upstream branch. To only build on push events, you can disable Build on Pull Requests from your repository settings.

A push build will be named continuous-integration/travis-ci/push and from the docs

Travis only runs a build on the commits you push AFTER adding the repository to Travis.

Solution

Since the merge of your branch into the base branch passed tests for continuous-integration/travis-ci/push, updating your branch to include the latest commits from the base branch will get your branch passing tests. From the image above, the GitHub UI should allow you to Update branch from the Pull Request page.

Caveat

With branch protections in place, it should be unlikely that your branch fails tests while merging into the base branch succeeds.

Be sure that you confirm that whatever was broken was actually fixed. That is, did someone "fix the build" by disabling that failing test in the base branch? As a cautious person, I would cherry-pick fixes into your branch to verify the problem is resolved.


By a comment of @osowskit, I've found the solution of the problem. He/she said:

PR will merge your changes into the base branch and run CI tests. Push will run CI tests on the current branch. Merging the base branch into your branch will likely resolve your build test on the branch.