Contributing to Open Source Phase at Encora Apprenticeship — Week 3
This post is part of a weekly assignment at Encora Apprentice and in this series, I’ll share my journey as a Software Engineer Apprentice. I hope these stories help and motivate others on their tech journey.
This week at Encora
Debugging with Ruby
As I mentioned last week, I took on an issue for the RubyGems project. To contribute to it, I needed to check how the
install command worked, and how to implement that behavior in the
fetch command. I decided to try the same approach I used to solve the Netlify-CLI issue, which was to set up a debugging tool to help me look at the values of the variables and see which methods were being invoked.
To do this, I used an extension called vscode-ruby or just Ruby for VSCode. To use this extension, it is necessary to install some gems like
debase. After this, we can generate a launch.json, where we define what file we want to run to debug, in my case, I wrote a
main.rb to call the method I needed.
"name": "Debug Local File",
With this, we can now use the
debug tool integrated with VSCode when pressing the “play” button in the
debug menu. Thanks to this approach, I could find the file
fetch_command.rb which contained the method
execute which needed to separate the gem names from the versions.
While on my quest to find new issues, I came across a new issue where was pointed out that it could be implemented an exponential backoff, which is an algorithm to prevent devices from generating excessive calls and loads to servers.
This algorithm consists of the client (who makes the calls) retrying a failed request in certain periods of time, these periods are increasing in an exponential fashion until a
maximum_backoff. The truncated exponential backoff stops increasing the time after this limit.
Anatomy of a Jenkinsfiles
This week I’ve been working a little bit with Jenkins and while following this tutorial, I came across a
Jenkinsfile, where we can define the steps of our CI/CD pipeline and Jenkins will execute them. We can start with a simple file:
args: '-p 3000:3000'
sh 'npm install'
In this example, we are defining an
agent, which will be a container using and
node. And for the stages, we just define one, which is the
Build stage, and will run the command
npm install. We can add more stages that can run the tests or perform other actions in the future.
Before I go
Working on open-source projects is a very interesting experience since we need to become familiar with big codebases while following conventions, which at the same time help on keeping the code readable.