How To Get Started Contributing to OpenFaaS

New Year New You?

Don’t bother with the Gym. We all know you won’t keep it up.

Why not give back to the programming community by contributing to an open source project that you use?

When I first started out it took me a while to get my IDE setup, all the dependencies installed and then once I had this set up, picking a github issue and getting through the Pull Request (PR) process also seemed daunting. This still felt like a big deal even though I raise many PRs a day at work and push code into production frequently. For some reason this “open” and new space felt very exposed.

Fortunately, I was helped through the process by Alex, who was always helpful and patient with my early contributions.

This post focuses mainly on code contributions. There are other types of contributions that are just as important and would be welcomed. Things like documentation, user guides, blog posts and helping members of the community on slack.

There’s a good section in the OpenFaaS docs on contributing too.

Maintainers are amazing!

Maintaining an open source project is hard, time consuming and often done for free. There are a load of great resources on the internet about the things maintainers face.

It might be worth you doing a small amount of reading into this, so you know what to expect from a maintainer, and what they expect from your contribution(s).

Here are some examples:

Setting up Golang

OpenFaaS is almost exclusively written in Golang. If you’re not a strong Golang developer don’t worry, it’s quite easy to pick up. However, there are other contributions you could make to get started, then ease yourself into Golang at a later date.

I like using the Goland IDE by JetBrains, but you can use VSCode or any other IDE that has Golang support, or even Vim/Emacs.

To install Golang

This should install Golang 1.12 on a Macosx or Linux distribution. There’s a good section here on installing Golang on other CPU Architectures.

You should probably use a package manager to install golang. It should sort everything for you.

You probably want to add these lines to your .bashrc or .zshrc so that go is available in new terminals and after you reboot.

export GOPATH=$HOME/go/
export PATH=$PATH:/usr/local/go/bin/

If go version outputs correctly then you should have setup Golang correctly.

Docker & Kubernetes

You will probably will need access to Docker and Kubernetes while writing contributions to OpenFaaS. You can install Docker by following one of the many online guides.

If you are using Kubernetes you will need to install kubectl. Best check online for the most up to date installation method for your Operating System.

I usually use a tool called k3d for creating Kubernetes environments, it creates a single node k3s cluster (Kubernetes compliant) inside a docker container.

Once you have these tools installed you can create, connect to and delete kubernetes clusters like this

# Create a cluster
k3d create

# Connect to it
export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
kubectl get nodes 


# Remove your cluster 
k3d delete

You should now have the tools to deploy an OpenFaaS installation quickly, and reset things when you need a fresh start.

Finding an issue to work on

The best way to find something to work on is to look through the various OpenFaaS Repositories for issues that have the help wanted or good first isse type labels.

This search should show Issues in the main openfaas/faas repository that have the help wanted label.

There are loads of other moving parts of OpenFaaS ecosystem and projects maintained by Alex from OpenFaaS that have various open issues, some good places to look are:

And many, many more…

You can look in the contributing guide at what types of things you can get involved with

If in doubt, you can react out in the #contributing channel in the OpenFaaS Slack

Forking the repository

To get started contributing you need to create your own copy of the repository you want to contribute to.

So, login to Github, and find the repository you are looking to contribute to then click the “fork” button.

Fork a github repository

Creating a branch and committing your code

Once you have cloned your fork to your computer you need to create a branch for you to work on.

You can do this by typing git checkout -b <branch name>. This creates your local branch to work on.

Once you have written your contribution and written tests (if a code change) and tested the change manually you should commit your code,

git add <file names for you have changed/added>
# then 
git commit -s 

This should open a commit window in your chosen editor (Vim by default) In this file you should write the title, leave 2 lines and then a description. This is a good blog about commit messages

Your IDE may also provide a mechanism to commit not using the command line, so feel free to use whatever you’re most comfortable with

Opening your PR

Before you open a PR on github you should read the OpenFaaS Contributing guidelines. This is a requirement for opening a PR against OpenFaaS, and you have to check a box to confirm you have read it.

Once you have finished, you need to open a Pull Request (PR) on github.

Find your fork (copy of the repository) and then go to branches page. From here there’s a “New pull request” button.

You will probably find a “pull request template”, a list of questions you need to answer, like why you have make this change, how its been tested and the impact of the change on existing users.

If you are creating a PR that “Closes” and issue then you can add Closes #<Issue Number> in the box and github will close that issue when the PR is merged!

Fill in the questions inside the pull request box and submit! PR Template image

That’s it

After you have raised your PR someone should take a look at it, provide feedback or suggestions and let you know the next steps. You may need to make a change, update some docs or re-word commit messages.

You might want to post in the #contributing channel on the OpenFaaS Slack

Check this out

Alex Ellis, the maintainer of OpenFaaS did a call in early 2019 about contributing, you can find the recording here

Contributing image