DEV Community

Cover image for Octo: Continuous Integration
Luigi Zaccagnini
Luigi Zaccagnini

Posted on

Octo: Continuous Integration

Welcome to another post about my project Octo! In this blog I am going to go over:

  • The process of integrating CI(continuous integration) into my open source project Octo
  • How writing tests for another repository felt
  • Thoughts of CI

Continuous Integration

Setting up CI with Github actions was extremely easy. Github has prefabs of node configurations making CI easy to integrate in your project. If you followed my previous blogs about testing and static analysis tooling, creating your config should be short.

  1. Navigate to your Github repository and click the actions button beside projects.

  2. Click on the basic node configuration. Once you click on that, it should bring you to a new page with the creation of a .yml file.

name: Node.js CI

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x, 14.x, 16.x]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node-version }}
          cache: "npm"
      - run: npm ci
      - run: npm run prettier-check
      - run: npm run eslint
      - run: npm test
Enter fullscreen mode Exit fullscreen mode

Octo's .yml looks like the above code. Most of the code above was provided by Github as a template to start with. I only added my npm commands created before as checks for the CI so, if you haven't done that yet you should go read those blogs! Once this is done, your CI should be now included in your repository!

Writing Tests in Another Repo

Working in another person's repo was a little tough. The repo's contributing.md was outdated so I had to find the files and commands to use for testing the project. Once I was able to figure that out writing a new test was not as difficult because of Jest's --coverage flag. This helped generate a report to find all the missing coverage for tests in the project. This also helped me understand how the project works and how to write tests for it.

Final Thoughts on CI

I think everyone should have CI integrated in their projects, even if it is being developed solo. I believe this is important for each project because it helps keep broken code from being pushed to a repo. Although developers may feel that they won't run into this, keeping a mind set of writing tests while developing a project makes your code better.

Discussion (0)