# Build/test each commit

**URL:** <https://drone.discourse.group/t/build-test-each-commit/4784>\
**Category:** Drone Support\
**Created:** [July 17, 2018, 4:01pm UTC](https://drone.discourse.group/t/build-test-each-commit/4784 "2018-07-17T16:01:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmlb](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/mmlb/32/3907_2.png) [@mmlb](https://drone.discourse.group/u/mmlb)\
**Post date:** [July 17, 2018, 4:01pm UTC](https://drone.discourse.group/t/build-test-each-commit/4784/1 "2018-07-17T16:01:21Z")

</div>

I’d like to be able to have both “no commit ever breaks the build/tests” and also non-squashed merges. This means much use of revisions/rebase/fixup in git. I’d like drone to ensure that each and every commit build/passes tests before allowing merge to master. Is this possible now? Will there be a way to do so in immediate future?

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [July 17, 2018, 5:19pm UTC](https://drone.discourse.group/t/build-test-each-commit/4784/2 "2018-07-17T17:19:46Z")

</div>

> I’d like to be able to have both “no commit ever breaks the build/tests” and also non-squashed merges. This means much use of revisions/rebase/fixup in git.

Not sure I completely follow, but Drone delegates the git clone to a plugin which means you can provide your own custom plugin if you need something more specialized. More details here [https://docs.drone.io/pipeline/docker/syntax/cloning/](http://docs.drone.io/cloning/)

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [July 17, 2018, 7:33pm UTC](https://drone.discourse.group/t/build-test-each-commit/4784/3 "2018-07-17T19:33:12Z")

</div>

Also note that this post might be relevant: [Planned change to git clone logic](http://discuss.harness.io/t/planned-change-to-git-clone-logic/1165/12?u=bradrydzewski)

---

<div class="post-metadata">

**Author:** ![mmlb](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/mmlb/32/3907_2.png) [@mmlb](https://drone.discourse.group/u/mmlb)\
**Post date:** [July 18, 2018, 1:22pm UTC](https://drone.discourse.group/t/build-test-each-commit/4784/4 "2018-07-18T13:22:39Z")

</div>

I don’t think clone needs any change, consider the following PR:

```auto
master
c1
c2 # some bug
c3 # bug is fixed
c4 PR-HEAD

```

When drone clones the PR we get a build/test of c4 which passes. But if I ever need to bisect and land on c2 the build will break and it may not be due to the bug I’m bisecting for, so this failure is just noise.

I’d like for drone to build/test c1, then c2, c3, c4 so that c2 is marked as a fail and blocks the PR.

I do this for my own PRs before submission using `git rebase -x master $build-test-command`.

I don’t want to have to squash when merging because then I lose history of development.

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [July 18, 2018, 3:42pm UTC](https://drone.discourse.group/t/build-test-each-commit/4784/5 "2018-07-18T15:42:56Z")

</div>

Thanks for the clarification.

I think this could be achieved today with a shell script. You would need to perform a diff of commits between the pull request ref and the target branch, and then loop through each commit and run your build and test commands. You would invoke this script from your pipeline step.

```auto
pipeline:
  build:
    image: golang
    commands: ./build_diff.sh

```

---

<div class="post-metadata">

**Author:** ![mmlb](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/mmlb/32/3907_2.png) [@mmlb](https://drone.discourse.group/u/mmlb)\
**Post date:** [July 19, 2018, 9:21pm UTC](https://drone.discourse.group/t/build-test-each-commit/4784/6 "2018-07-19T21:21:51Z")

</div>

Right but the problem then is that I have multiple stages that build different things with different images. And I’d lose on the small niche images that is great about drone, and would need a travis-like _all the things_ image.

I’d be great if drone would not re-build/test commits that haven’t changed (though I don’t think would be possible nor a requirement I’d say)
