Murdock: skip build if PR is unchanged after force push

Hi,

With git it’s possible to compute the hash of the complete RIOTBASE directory using the following command:

git ls-files -s ${RIOTBASE} | git hash-object --stdin

I think it would make sense to adapt Murdock to skip the build when the computed hash remains the same after a force push if it was already successful. This situation typically happens after squashing a PR. That would save a lot of non needed CI time when there’s a lot of activity.

I’m wondering where this should be handled in Murdock code. Any hint ?

this should be handled in murdock’s scripts right after it merged the latest master, before pushing the resulting build commit hash. there’s already a redis instance running that could be used for this.

the skipping part is rather easy, I’m not sure how to present the result. there’d be no ui anymore to see the previous results.

I was not talking about the master branch but the PR branch. Let’s say I have a PR branch with fixup commits and Murdock already built it with success, after squashing the PR contains the same code, so there’s no need to rebuild. Using the command above, the resulting hash should be the same. But we have to store the previous branch content hash somewhere and compare with the new one.

As commits in Git are just a composition of a commit message, some dates and a tree object (+ some more meta data…) you do not even need to calculate a hash, as tree objects are (like commits) uniquely identified by the hash of their content. So the following command suffices to determine the file content of the current HEAD without any metadata:

$ git show --format=%T HEAD
5dac549dba5c9a785f9b0551b4fd4fef826c8814

HEAD was the current master as of the writing of this post (8482434bdfb). As long as the files do not change (including file permissions), the tree object should not change either. See the Git book’s section on commit objects for more details.

The HEAD is of course optional as per usual with git show.

Is there maybe a way to just link to the last build if the tree-ish is the same?

The PR branch gets always merged into current master before a build.

Do you have a link to the code ?

That’s better indeed and this is what I was looking for initially. Thanks!

This is where the PR branch has been merged into current master and would then get pushed to murdocks intermediate repository. It’s hash could be taken and compared here, and that case handled.

Changing this is a bit tricky, as AFAIK, the production murdock is still using some hacks (e.g., not upstream).

I think I removed the robotFW hack from production murdock, murdock-scripts is at least matching master in the riot repo.