Fundamentally, how does CircleCI run tests for a PR?

Hello! I just have a brief formality question pertaining to how CircleCI runs pull request testing. For example, I have specified the branches, dev, qa, and prod, to have tests executed when anyone commits or pull requests to those branches.

If I create a new branch using the dev base, naming it dev-update, and make commits to dev-update… it shouldn’t require the [ci skip] command to skip running the CircleCI tests (because it wasn’t specified as a branch in the config.yml); however, if I merged dev-update into the dev branch it won’t have any tests for dev-update to pass, but it will try to run the tests against dev when the pull request is completed… correct?

I’m writing documentation for my team, and want to ensure I personally have the full grasp for the tool. Before using the branches parameter in the config.yml, we originally had if statements in our bash scripts to ensure it was building the proper branch-- so we would always receive a “tests passed” notification for any branch that wasn’t dev, qa, or prod because the if statements wouldn’t execute.

Was everything I said here correct?

Hi Thomas,

This sounds mostly correct. You didn’t mention if you were using branch whitelisting, but you did mention the config.yml so I’m assuming you are.

In that case, assuming forked PRs aren’t involved, CircleCI will only run builds against the target branches listed, regardless of where the PR is coming from. https://circleci.com/docs/2.0/configuration-reference/#branches

If you can think of improvements to our own docs please open an issue or PR and we would be happy to make them clearer.

Thanks for your response @drazisil! I apologize for not being clear the first time: I am using branch whitelisting to specify the specific branches as of now. My team and I didn’t know it existed until now, so we are beginning to use it. Before, we just used if statements.

We never fork PRs; however, if we whitelisted the branches dev & prod and performed a pull request from dev into prod (prod <- dev) would it try to build both branches after the PR was merged-- or would it only build prod? I know that, on the PR screen, it will display “Checks passed” if the previous commit to the branch was successful-- unless I’m mistaken?

Point being, if we were to ever perform a PR merging the prod branch into another that isn’t whitelisted… would it attempt to build prod?

randomBranch <- prod

Or would nothing happen since randomBranch isn’t whitelisted?

Good question. We build on commits, so since you would just be doing a merge and not adding any new commits I don’t believe prod would build again since that commit had already run on CircleCI

1 Like

Thanks for all your help!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.