Run an expensive job before merging a PR

We are building a CI pipeline for a mobile project. We’d like to be able to trigger a test build, plus run E2E & performance tests on each PR to prevent regressions.

The problem is: mobile builds and E2E tests are expensive & slow. It would cost us a lot to run these on every single commit in main, plus every single commit on every PR.

I am trying to find some concept of “This PR is ready, so run the final checks” to help reduce the cost. Is anyone aware of a solution in CircleCI that might work for this?

Some ideas I’ve had…run additional tests if:

  1. a particular label is present on the PR (AFAIK not supported by default - think we’d have to determine this using the github API)
  2. The PR is no longer in draft status (again, don’t think this is supported)
  3. Run the tests just before a PR is merged (not sure how you could achieve this?)
  4. Run the tests through some other option on the PR that the Engineer could use to signify it’s “ready”?

Any other ideas? Is there anything that would achieve a similar thing supported out of the box?

Very long running E2E testing is something you may want to look at deploying a self-hosted runner for. This is just your own equipment that runs a circleci agent. You just define the self-hosted runner as the target for a job.

Self-hosted runners may not be that helpful if you have a workflow that needs to fan out across a lot of nodes to get the best performance, but if you have a single task that may take hours (such as E2E testing) or you just want to repeat time after time as PRs are created it may help.

As for the checks you have listed as ideas, I’m not aware of such features within the circleci feature set, so you would end up having to code them via git commands and/or calls to the repo API.

I’d suggest putting your E2E job behind a approval type job.

Config Intro: Adding a manual approval

So long as the E2E job is a part of the workflow that your VCS provider has in the required status list your team will have to run them before merging.