tag:help.appveyor.com,2012-11-13:/discussions/questions/55079-two-builds-per-commit-to-pull-requestAppVeyor: Discussion 2021-10-19T21:02:57Ztag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T16:38:32Z2021-08-18T16:38:32ZTwo builds per commit to pull request<div><p>Builds are invoked by a webhook. Those builds are not identical: one of them is for branch and another one is PR. When you push to a branch with opened PR webhook sends two requests: branch "push" and PR "sync". You can avoid building branch if there is an opened PR by adding this to your <code>appveyor.yml</code>:</p>
<pre>
<code>skip_branch_with_pr: true</code>
</pre></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T17:58:09Z2021-08-18T17:58:10ZTwo builds per commit to pull request<div><p>Thanks for the quick response. I added line</p>
<pre>
<code>skip_branch_with_pr: true</code>
</pre>
<p>and created a pull request, see <a href="https://github.com/nlohmann/json/pull/2952">https://github.com/nlohmann/json/pull/2952</a>, yet still see again two builds created and pending.</p>
<p>Is this expected as the change to the configuration is not yet merged to the default branch?</p></div>Niels Lohmanntag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T18:03:20Z2021-08-18T18:03:20ZTwo builds per commit to pull request<div><p>Right, it should be merged into default branch.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T18:52:48Z2021-08-18T18:52:49ZTwo builds per commit to pull request<div><p>I merged the change to the default branch and created a new PR. Again, I see two builds created (see screenshot).</p>
<p>What am I missing?</p>
<p>See <a href="https://ci.appveyor.com/project/nlohmann/json/history">https://ci.appveyor.com/project/nlohmann/json/history</a> and <a href="https://github.com/nlohmann/json/pull/2954">https://github.com/nlohmann/json/pull/2954</a></p></div>Niels Lohmanntag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T18:55:49Z2021-08-18T18:55:49ZTwo builds per commit to pull request<div><p>Looks correct to me. You created a new branch, did a push - build of the branch started. You <em>opened</em> a new PR - another build started. Now, if you do another push into feature branch with open PR only PR build will be started.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T18:56:19Z2021-08-18T18:56:19ZTwo builds per commit to pull request<div><p>You can disable PR builds all together if you don't need them.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T19:04:13Z2021-08-18T19:04:14ZTwo builds per commit to pull request<div><p>I see. This is confusing, because GitHub Actions only create one build for such an action.</p>
<p>You say I can disable PR builds - how would this affect PRs created by other people?</p></div>Niels Lohmanntag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T19:10:25Z2021-08-18T19:10:25ZTwo builds per commit to pull request<div><p>No PR builds would be started at all which is, of course, not what we expect from CI for OSS project.</p>
<p>Could you please elaborate what you mean under "such an action"? Typical workflow would be: create feature branch, do some commits to that branch, push - branch build started. Do another commits into feature branch, push it - another branch build started. Open a new PR for the feature branch - new PR build is started. How is GitHub Actions different?</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T19:14:31Z2021-08-18T19:14:33ZTwo builds per commit to pull request<div><p>The screenshot show the runs created by GitHub actions. You see 4 runs (one for each workflow) - no workflow has been triggered twice. They have only been started once the PR has been created. Once the PR is merged to the main branch, another 4 runs will be created. This is the behavior I would also like to see from AppVeyor. However, I see 2 builds per commit to a PR - only when it is merged, I only see 1 build.</p></div>Niels Lohmanntag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T19:19:13Z2021-08-18T19:19:13ZTwo builds per commit to pull request<div><p>I see. Then, if you only need to run builds for PRs <em>and</em> merges into the main branch you can add branch filtering: <a href="https://www.appveyor.com/docs/branches/#white--and-blacklisting">https://www.appveyor.com/docs/branches/#white--and-blacklisting</a>, to allow only builds to <code>master/main</code>.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T19:21:10Z2021-08-18T19:21:14ZTwo builds per commit to pull request<div><p>So I would add</p>
<pre>
<code>branches:
only:
- develop</code>
</pre>
<p>and remove <code>skip_branch_with_pr</code>?</p></div>Niels Lohmanntag:help.appveyor.com,2012-11-13:Comment/493460762021-08-18T19:23:40Z2021-08-18T19:23:40ZTwo builds per commit to pull request<div><p>Yep, it should do the trick.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/493460762021-08-19T14:11:17Z2021-08-19T14:11:18ZTwo builds per commit to pull request<div><p>Yes, this works now!</p>
<p>Thanks a lot for the support!</p></div>Niels Lohmanntag:help.appveyor.com,2012-11-13:Comment/493460762021-08-19T16:31:37Z2021-08-19T16:31:37ZTwo builds per commit to pull request<div><p>You are welcome! Saw "JSON for Modern C++" release announcement on HN today - cool stuff :)</p></div>Feodor Fitsner