we have a specific set of long running tests we would like to run ONLY on pull requests, to confirm they all pass before we merge the request.
We want our normal, quicker tests to continue to run as they are now, where they run on ever commit. But we’d like a way to trigger when the commit is a pull request, so we can run the extra tests.
Is there any way we can key off of the PR to decide what to run?
One of the environment variables we make available in every build is the CI_PULL_REQUEST variable which is only populated when the build is part of a PR. So checking that variable should work in this case:
test:
override:
- if [[ ! -z $CI_PULL_REQUEST ]] ; then <long-running-command> ; fi
If the PR is coming from a fork, the fork PR variables will be set, so you might condition the test execution on that instead.
I’m not sure this is actually solving the problem that is asked. Creating a pull request doesn’t kick off a build. We’re also looking to do something like this and would like to not merge a branch if the long running tests fail. Can builds be triggered with the creation of a PR?
I’ve also been teesting this and you need to rebuild each commit to get that variable populated, otherwise, when it’s launched it doesn’t know that it’s inside a PR, is there any issue with this @alexey?