CI/CD Grasshopper Plugins with Tests

I’ve been looking this repo for doing Unit tests for a Grasshopper plugin. Is it possible to run those tests automatically on Github, while doing a PR?

I guess the follow-up is also saving the builds automatically on releases!

Any examples where you can do that?

If you use NUnit for unit tests you can run tests with a cake build script, which can also be triggered through a ci server(bamboo,jenkins …)

Edit: Cake now supports xUnit and MsTest as well. For some specific reason I’ve picked NUnit but I can’t remember…

Running unit tests on Github? What is it for? The way I check if everything is fine during PR is simple Checkout and running all the tests. Also maybe you’ll find my new plugin helpful: :wink:

I guess he means-> pulling a branch, build it, run unit tests. This what I do with the software I’m developing.
Whenever you push to the main dev branch, a unit test and version iteration is performed. It refuses to update version number, when the unit test or build in general fails and informs me over an email.
Quite useful with 300 unit tests on a mid-to-large sized app. Not so sure if its worth for a plugin.

1 Like

If you have multiple people working on a plugin it becomes a bit tedious to check out everything but you are right, this is what I am doing at the moment

1 Like

Sounds promising, do you have any suggestive resources or snippets I can look at?

Sorry, I cannot share this. Its actually not so easy to set up a working ci pipe. Took us several weeks to make it work. But we also do a lot of other things. I think the first step is to create a build script, I would propose Cake. Which outputs a powershell script, coded in C# syntax. Go to This ps script is part of your repro.

Once you have this one, setting it up on a build server is another deal. Can be easy, can be difficult. Depends. We had a lot of issues with minor differences between local and remote build.
E.g. if you fetch the newest nuget packages from 3rd party code but you are behind on your local machine, then this can cause issues for instance.
The build server should checkout from git, run the build script, do something on success or on failure and store the a compiled binary somewhere.

1 Like

Hi @psarras_st,

I’m using yaml Azure pipelines on for CI. They support github repos as well. I haven’t used a github repo yet, however as Tom mentions it should as simple as checking out, building and testing. You need a vm or local build agent to do this.
What you need after building is a VSTest@2 task on your pipeline.

I have rhino and gh X-unit tests that run fine using this.

If the test succeed you can proceed in generating the artefacts and deploy them or copy them to a local directory.

If you have the process split into jobs, remember not to checkout the repo on every step so you can use the previous binaries.
More info here:

Hope this helps,


Tell me about it.

Well, if you know what you are doing its not so complicated. But we started from none to 100. Learning cake and writing a bullet-proofed build script, dealing with subrepros and 3rd party libraries etc. Then creating a build server and handle issues, as I said doing other things as well. Checking code metrics, putting the msi in the installation manager database, etc. Needed a lot if tweaks. Maybe Azure is much simpler, since it Microsoft… Don’t know. What is your experience?

Cannot really tell if its easier, as I haven’t tried Cake. I started from zero on Azure Pipelines and took me a lot of time to build something robust. But I don’t think my project is nowhere near as complicated as yours.
There seem to be more resources on WebApp CI/CDs for Azure Pipelines.
I find the PS scripts really powerful tool in the azure arsenal.
I would like to try Cake, but I’m not sure if I want to spend more time on building pipelines :sweat_smile:

1 Like

Thank you for your replies guys. I looked through the github Actions in more detail and it is indeed easy to do build automatically. I am using msbuild + nuget restore to get it working. However, for the tests I think I will encounter a problem, because I would need an active Rhino machine / licence and github VMs do not come with that. If only we could run the tests using the nuget packages! Anyway I am coming to the conclusion based on what I’ve been told that I would need to setup a custom build machine to do the everything there. Will let you know how it goes and I would post some snippets once I have something.

I think the tricky part is RhinoCommon and Grasshopper. Github CI itself isn’t very complex.

Depends. Its not directly possible to run Rhinocommon or Grasshopper without running Rhino. But some plugins only have a minimal facade to it. Say you implement a new geometric Type, a wrapper to 3rd code libraries or just mathematical addins, then you don’t need to test in Rhino. And a Unittest is no Integration test. So you always test small code units.
But even if you like to run a Unittest in Grasshopper, you can remotely start Rhino, run the test and close once you are finished. Its tricky as you say, but feasable. But as I said, building a CI pipe is a bit of an overkill for the average GH Plugin if you ask me.
Also if you use interfaces, di containers and inversion of control mechanismn a lot, you partially can mock Rhinocommon functionality for testing…