Post

First product using GitHub Copilot

First product using GitHub Copilot

TL;DR Sharing a story of rapid development and iterations with GitHub Copilot.

Once a upon a time with bash

It all started with wanting to make my CICD optimization ideas into real-life implementation, because optimization exercise must always be data-driven rather knee-jerk reaction.

I began the POC with a simple bash script to retrieve the workflow runs with GitHub CLI. It was just a simple command line with a few .jq queries to make the result-sets look pretty. To automate it, I put the script inside a YAML file with schedule trigger. Statistic calculations and report generations were done by another steps with more inline scripts. [1st iteration here]

Although the solution works. The ad-hoc CLI call with inline scriptings could not really enable clients to get started and integrate into Actions properly. I knew I have to refactor all inline scripts into Python functions. This is the time I decided to try GitHub Copilot.

Eureka moment

I am new to Python development, but I wanted to learn it sometime ago. I followed the intuitive design flow by highlighting the inline scripts and asked in the Copilot Chat to translate the code snippet into Python for me. It returned the Python code where I extracted it into a new file and changed the YAML file to call the Python functions. [2nd iteration here, here & here]

The Eureka moment came when it worked on the first attempt. Dopamine was released in less an hour - from installing Copilot Chat in VS Code to running the POC in Python.

Unit test & documentation

The POC was a success. My colleagues further requested organisation-level statistics in addition to the repository-level. I further developed my Copilot and add inline documentations. I asked Copilot with phrases like “generate documentation for this file”. To manage regression, Copilot returned well-formed boilerplate unit tests for the Python functions, and I was surprised that Copilot even generated test data for the stats calculation. [unit tests here & here]

Too ambitious

As the news of this POC reached the field, I heard that customers are planning to use it for their environment. I felt a sense of urgency that this solution needed to evolve into production-like to handle API rate limits. I decided to publish it as a marketplace action. It was an ambitious ask when I asked Copilot to “transform these YAML and Python functions into docker container action”. It did not understand what Docker container action is. This stretched the limitations, so I took a step back to basic fundamental solution design.

Great semantic

I read the GitHub documentations to reorganise my repository manually for container action implementation. However I asked Copilot to draft README.md and CONTRIBUTING.md for me. It leveraged the context of the whole repository, including existing inline documentation, to generate a comprehensive README structure and first draft content, which would have take me long time to complete. The language tone used and sentence structures where so inviting to readers, which is something I am not very good at. Within a couple evenings of fine tuning, I graduated my POC and published my very first OSS action [3rd iteration] in the GitHub marketplace.

Solopreneur a possibility

As a non-Python developer, it is truly amazing that I could rapidly iterate an idea from the POC in bash scripts, to Python functions with unit tests and documentations, and graduated it into a fully-fledged container action available in the marketplace. My motivation to continue the iterations really ignited from the early achievement enabled by Copilot. It took away the pain of starting in: writing unit tests, authoring documentations, and compiling README. Copilot basically removing the inhibitors and excuses to give up, and make building and publishing so easy.

What I like about Copilot?

The documentation boilerplates were great and made writing a bliss rather than a chore. The conversion between languages and syntax made code more portable than ever. This is truly the better pair programmer than you could have for any conversion work.

What I don’t like about Copilot?

I can see how the developers can over-reliant on Copilot and accepting all its suggestions. Copilot does produce buggy code and introduce regressions. Where I spent my time the most was in debugging the incorrect Copilot suggestions. I frequently found that it was generating code with functions that do not exist yet sound very legitimate. Developers need to exercise their engineering craftmanship and experience to leverage Copilot for 10x result.

This post is licensed under CC BY 4.0 by the author.