Contributing to Telescope: Wrapping up 0.4
Published: 2021-12-11 03:09:12

Over the past two weeks, I worked on [Telescope](https://github.com/Seneca-CDOT/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](https://gitpod.io/) workspace! I discussed some of the issues and pull requests I created last week as part of my update blog: [Click here!](https://dev.to/dhillonks/contributing-to-telescope-the-update-pj6)

Continuing on from that blog, I ended up creating two more pull requests as I was wrapping up 0.4: [#22](https://github.com/Seneca-CDOT/satellite/pull/22)

## Adding ESLint to Satellite's CI runs:
As I had previously configured [Satellite](https://github.com/Seneca-CDOT/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:
```yaml
 # 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
```

## Optimize Gitpod Environment Image: [2564](https://github.com/Seneca-CDOT/telescope/issues/2564)

By default, Gitpod uses the [`gitpod/workspace-full`](https://github.com/gitpod-io/workspace-images/blob/master/full/Dockerfile) 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`](https://github.com/gitpod-io/workspace-images/blob/master/base/Dockerfile) 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`:
```yml
image:
  file: .gitpod.Dockerfile
```

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:
```dockerfile
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"
```

The project also uses docker, so I also made sure that Docker was properly setup:
```dockerfile
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
```
and not forgetting docker-compose!
```dockerfile
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
```

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:
```bash
docker build -f .gitpod.Dockerfile -t gitpod-dockerfile-test .
```
and then ran it:
```bash
docker run -it gitpod-dockerfile-test bash
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9j440qotyukpla92iav4.png)
 
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iecbtx3ec7ojjp1sih32.png)

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:
- [Enabling cache for actions/setup-node](https://github.com/Seneca-CDOT/telescope/pull/2558)
- [Adding anti-trojan-source plugin to eslint](https://github.com/Seneca-CDOT/telescope/pull/2561)
- [Using workspace-base to create a custom gitpod env image](https://github.com/Seneca-CDOT/telescope/pull/2576)
- [Add ESLint to satellite](https://github.com/Seneca-CDOT/satellite/pull/21)
- [Adding ESLint to satellite runs](https://github.com/Seneca-CDOT/satellite/pull/22)

## 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.