A couple weeks ago I wrote about starting a project to copy code review evidence from GitHub to Jira. I created an open source repository, on GitHub of course, and started writing. I decided AWS Lambda is a good fit for this application because the scope is pretty small and I need a single endpoint to handle all the events for the webhook. When AWS announced Lambda I was very interested but found it challenging to test without deploying your changes. Over the years, Amazon stepped up their game and released SAM Local CLI. Let’s take a quick look at the SAM Local setup.

SAM Local CLI

The whole setup was much simpler than I thought it. First, you’ll need to install Docker if you don’t already have it. SAML Local simulates the AWS API Gateway and Lambda Function by running these services in containers. You also need Python 3.6. I used Chocolatey,

choco install python --version 3.6.6

If you develop on Windows, Chocolatey is a great utility to install tools, frameworks, and applications. I also run an update script every morning to keep everything up to date. Now we can use pip to install SAM Local.

pip install aws-sam-local

Make sure the installation finished successfully by running checking the version.

sam --version

I created a sample SAM application using for .NET Core 2.0 with the init command.

sam init --runtime dotnetcore2.0

I wanted to use .NET Core 2.1 so I updated various files, project, scripts, and JSON, so the sample project would build and function as expected. The one thing that failed is running the invoke command.

sam local invoke -e PullRequestReviewCommentEvent.json

Unfortunately, the installed scripts didn’t understand the framework. I added dotnetcore21 = "dotnetcore2.1"to the file lambda_container.py and SAM Local worked like a charm.

Technology

Before I get into the progress, let’s step through the technology decisions. I feel this is a relatively small project. The purpose of the project is to support a single client, me, with multiple GitHub repositories and a single Jira Cloud Instance. Right now, this is all it needs to support.

I chose Serverless technology because I wanted to start quickly, stand on the Shoulders of Giants, and remove maintenance concerns. I chose AWS Lambda because AWS is the cloud provider I use as work and this application will most like be deployed for the project I’m on now.

If you don’t know me, I’m a .NET Software Engineer of about 15 years. My core strength is in ASP.NET, i.e. server-side development, web services, REST Web API’s, and the web tech stack in general. The choice to use .NET with AWS Lambda may make the project a little more complicated because it’s a compiled language and requires specific packaging of the application. This hurdle pales in comparison to learning NodeJS with good development and testing practices.

On the flip side, I think the complexity is reduced since I don’t need a data store. I can also leverage the Newtonsoft JSON Serializer to translate the request body to a .NET object, Automapper to transform GitHub models into Jira Models, and RestSharp to talk to Jira.

Progress

I’ve written a few GitHub models to handle the Code Review Comment Event. I tried to find a library but didn’t find one compatible with .NET Core 2.1. I also started writing a repository to interact with Jira. There are a few hurdles to figure out since Jira uses OAuth 1.0a which requires a little more involvement than OAuth 2.0. I very much believe in Test Driven Development so I’ve written tests for each of the classes and methods and implemented Poor Man’s Dependency Injection for isolation.

Jira GitHub Integration Design Diagram

I plan to implement logic to identify the Jira Issue Key using the same convention required by DVCS Connector. I’ll explain more about that in another post. I need to get the Issue from Jira, format and append the code review comment in the Custom Jira Field, and send the update to Jira. Oh! I forgot to mention I need to figure out how to authenticate with Jira otherwise I won’t be able to get anything. Check out the GitHub repository if you’re curious how it’s going. Shoot me a line if you’d like to help out.