Abstract From Your CI. Use Cake!
Cake is a tool for C# allows you to speed up your development in an agile way by allowing you to abstract from your CI server. Sounds tasty!
Join the DZone community and get the full member experience.Join For Free
Here at Coolblue, we can choose our tools from a range of technologies. A while ago, our team started moving from Microsoft MSTest to xUnit.
Although the code change was fairly simple, the build pipeline was tied with the MSTest framework, ignoring the xUnit tests. Between the requests to the deployment team to alter the team's deployment pipelines, Nathan challenged us to use Cake.
What Is Cake?
Although I'm a cake monster, "Cake (C# Make) is a cross-platform build automation system with a C# DSL to do things like compiling code, copy files/folders, running unit tests, compress files and build NuGet packages (source)."
Great, this is the tool that was missing, allowing us to abstract from our CI server, speeding our development (and in the end, that is Agile)!
Cake allows us to build our project in many different ways with a syntax that is our bread and butter (C#). The platform is open-source, meaning that we can fix any bug, or contribute with a module to increase the ecosystem.
During my spare time, I started playing around with Cake in a pet project. The pet project is built using .NET Core 2.0, and the ultimate goal was to build the project in AppVeyor and TravisCI. The build steps were:
- Ensure the non-solution folders exists (for example, artifacts folder).
- Clean the solution.
- Restore the NuGet packages.
- Apply the Semantic Versioning.
- Build the solution.
- Run the tests.
As a bonus, it should be able to:
- Package and push a NuGet package.
- Create and push a Docker container.
Cake offers support to all these steps, either out-of-the-box feature or as a module offered by the community.
The development was simplified since the operations to build & test my project was the same that the build server would execute. It avoids the old developer excuse "it works on my machine," since the developer machine has the same software that the build server (during the development I face this problem with AppVeyor. The solution was published here).
A Plethora of Opportunities
This approach decreased the time to configure two different CI servers since it supports the executing of the scripts in Windows, Linux, and MacOS.
However, the opportunities are endless. In an enterprise environment, the software is a complex web of services and other moving parts; a team needs to be able to add a feature, testing & shipping it quickly; at the same time assuring the business that is working as expected, and more important, it doesn't introduce any regression bugs.
Using Cake, we can setup the script to deploy the necessary components on our development machines, running the tests to assure that everything works before we push our changes. This level of automation and abstraction also enables the developers to focus on delivering value (coding a new feature), rather than spending time configuring and deploying (manually) all the components to run the tests. Raise your hand who was in this situation. Yeah, every developer.
The Final Result
Within our team, we start to move towards this direction. All the new projects are bootstrapped with a basic Cake script (Clean, Restore, Build, Test and Create NuGet package), but the team iteratively adapts it to our development needs. In the end, a development team should be proud of the software delivered, because it improves the business, but also the team was able to use the time is an effective way.
And for Other Languages/Frameworks?
The same concept exists in other languages/frameworks. As a short list, we have:
Be aware that this is a short list. Out there exists other build platforms that allow you to abstract from your CI server.
Published at DZone with permission of João Rosa, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.