Skip to main content

cangulo.nuke.prcommitsvalidations

ยท 2 min read
Carlos Angulo Mascarell
๐Ÿšง๐Ÿ›‘ Project discontinued

Problem I want to solve

I want to make sure all the commits in a PR follow custom conventions based on the Conventional Commits specification. The conventions should be per repository. Let's consider fix, minor _and _major as a reference.

On the other hand, as I have been playing with NUKE lately, I want to create a solution based on it.

info

NUKE is a build automation framework where you define operations as build, test or push NuGets, in a C# project. I found good reviews and some videos in Channel9 about it. So, for instance, dotnet commands are predefined methods, and its arguments are extension methods, check the next example:

How a NUKE project looks like?
Target Pack => _ => _
.DependsOn(Clean)
.Executes(() =>
{
DotNetTasks
.DotNetPack(s => s
.SetProject(project.Path)
.SetOutputDirectory(outputFolderAbsolutePath)
.SetConfiguration(configuration)
.SetVersionPrefix(currentPackageVersion)
.SetVersionSuffix(versionSuffix)
.EnableNoRestore());
});

Goals

  • Validate the commits from a open PR.
  • The Solution should be based on NUKE.
  • Any repository should be able to use it.

Approach

cangulo.nuke.prcommitsvalidations will execute the following operations sequentially:

  1. Get the commit list using the GH API Client provided by NUKE
  2. Validate they follow the conventions defined in the repo.

Remarks

  • I'm not saying NUKE is the best solution, I just want to give it a try ๐Ÿ˜Š. In the future, I will create another solution based on scripts.
  • The conventions are defined in a json file, you can extend the next example:
{
"conventionalCommitTypes": [
"fix",
"minor",
"major"
]
}

How to use it?

Please check the examples given here.

Where do I use it?

I call this solution through a specific GH Action in the next projects:

Repository

cangulo.nuke.prcommitsvalidations repository

GitHub Action

github action to execute in ANY repository

About me

I'm a Software Engineer with experience as Developer and DevOps. The technologies I have worked with are DotNet, Terraform and AWS. For the last one, I have the Developer Associate certification. I define myself as a challenge-seeker person and team player. I simply give it all to deliver high-quality solutions. On the other hand, I like to analyze and improve processes, promote productivity and document implementations (yes, I'm a developer that likes to document ๐Ÿง‘โ€๐Ÿ’ป).

You can check my experience here.

Personal Blog - cangulo.github.io
GitHub - Carlos Angulo Mascarell - cangulo
LinkedIn - Carlos Angulo Mascarell
Twitter - @AnguloMascarell

Did you like it? Share It!


Comments