DEV Community

Kunwarvir
Kunwarvir

Posted on

Contributing to Telescope: Wrapping up 0.4

Over the past two weeks, I worked on Telescope as a part of release 0.4. My goal, as highlighted in my planning blog, was to focus on the various tools and technologies being used in the project, to enhance the developer experience.

I worked on multiple issues relating from the project CI (continuous integration) using GitHub Actions, to configuring analysis tools and even optimizing the gitpod workspace! I discussed some of the issues and pull requests I created last week as part of my update blog: Click here!

Continuing on from that blog, I ended up creating two more pull requests as I was wrapping up 0.4: #22

Adding ESLint to Satellite's CI runs:

As I had previously configured Satellite with ESLint, this was a perfect time to also add it to the CI runs, so I created a follow-up pr to add a new job to run ESLint in the GitHub Actions workflows.

Building on my knowledge that I had gained last week working on #2537, I used the built in cache from setup-node to cache dependencies and this is how the new job looked:

 # Verify that ESLint passes
  eslint:
    name: ESLint Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2.4.1
        with:
          node-version: '14'
          cache: 'npm'
      - name: Install dependencies and run eslint
        run: |
          npm install
          npm run eslint
Enter fullscreen mode Exit fullscreen mode

Optimize Gitpod Environment Image: 2564

By default, Gitpod uses the gitpod/workspace-full image which includes a lot of tools which weren't needed for Telescope. Since Telescope only really requires Docker, Node and pnpm, creating a custom Dockerfile to have a smaller image for the gitpod workspace using gitpod/workspace-base would be much better than using the default one.

I started off by creating a .gitpod.Dockerfile and supplied it as the image in gitpod.yml:

image:
  file: .gitpod.Dockerfile
Enter fullscreen mode Exit fullscreen mode

To install Node, I intially used NodeSource but after one of the reviewers highlighted that using nvm was a better approach, I ended up using nvm to setup Node, npm and pnpm:

USER gitpod
RUN curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash \
    && bash -c ". .nvm/nvm.sh \
        && nvm install --lts \
        && nvm alias default lts/* \
        && npm install -g pnpm"
Enter fullscreen mode Exit fullscreen mode

The project also uses docker, so I also made sure that Docker was properly setup:

USER root
RUN curl -o /var/lib/apt/dazzle-marks/docker.gpg -fsSL https://download.docker.com/linux/ubuntu/gpg \
    && apt-key add /var/lib/apt/dazzle-marks/docker.gpg \
    && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
    && install-packages docker-ce docker-ce-cli containerd.io

RUN curl -o /usr/bin/slirp4netns -fsSL https://github.com/rootless-containers/slirp4netns/releases/download/v1.1.12/slirp4netns-$(uname -m) \
    && chmod +x /usr/bin/slirp4netns
Enter fullscreen mode Exit fullscreen mode

and not forgetting docker-compose!

RUN curl -o /usr/local/bin/docker-compose -fsSL https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64 \
    && chmod +x /usr/local/bin/docker-compose
Enter fullscreen mode Exit fullscreen mode

Once I had the Dockerfile ready, I wanted to test it locally before creating a pull request. To do that, I first built an image:

docker build -f .gitpod.Dockerfile -t gitpod-dockerfile-test .
Enter fullscreen mode Exit fullscreen mode

and then ran it:

docker run -it gitpod-dockerfile-test bash
Enter fullscreen mode Exit fullscreen mode

Image description

Everything looked promising locally, so I pushed my changes and created a pull request:

Using workspace-base to create a custom gitpod env image - https://github.com/Seneca-CDOT/telescope/pull/2576

Since gitpod is integrated with the project, I was then able to test my changes. It was using the custom image now and I verified that by checking if java was installed in the workspace (as it comes bundled with the default one):
Image description

This was working as expected, and after some reviews, it was merged into master!

Recap

Over the past 2 weeks, I ended up creating 5 pull requests to the project, with the goal of working on the tools and technologies being used in the project:

Learnings and Takeaways

I found that working in a large open source project is a really fun and challenging experience as there are so many different bits and pieces in the project, which do seem quite intimidating as a newcomer. Even working on small issues can take quite some time as things can pop up, which again, as a newcomer to the project are hard to anticipate! For instance, it took me quite a long time to get the CI runs to pass when I was modifying the workflows to use cache from setup-node as there were a lot of unknowns that I would eventually discover.

This also means a constantly changing master branch, so be ready to rebase and resolve any conflicts as they pop up!

That being said, it really is a great opportunity to learn and work with others and I personally felt that all the time I spent contributing to Telescope was more than worth it! Over the past 2 weeks, I learnt so much ranging from GitHub Actions and how npm works to gitpod and creating custom, optimized images using Docker, while also working towards my goal of improving the developer experience in Telescope.

Discussion (0)