DEV Community

Add00
Add00

Posted on

Continuous Integration and Continuous Learning

Greetings,

Entering week 10 of the open source course. We have been assigned to learn about a topic that has always interested me Continuous Integration (CI) Workflows, and automated testing. I've always wanted to work with GitHub Actions, and this weeks assignment gave the perfect time to do it.

Setting up this workflow was very simple, as the project tests were also simple. The default template GitHub Action for NodeJS testing was able to work out of the box. It functions on every PR and push to the main branch and runs the npm test command which runs the full suite of tests on three major versions on Node.

The full file can be seen below:

name: Node.js CI

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: ubuntu-latest

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

    steps:
    - uses: actions/checkout@v4
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v4
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - run: npm ci
    - run: npm run build --if-present
    - run: npm test
Enter fullscreen mode Exit fullscreen mode

Writing tests for my partners repo was interesting as they had used a different testing framework. They had opted to use Jest where I was using Vitest while syntactically similar the functions had some slight differences. Given that they had very good test coverage out of the gate, I only opted to add some minor tests for some edge cases.

Having implemented CI for this assignment while not a very complex implementation. The fact that a basic automated testing system is just a few clicks away is new information to me. Seeing this I look forwards to adding this to more of my personal project.

Neon image

Resources for building AI applications with Neon Postgres πŸ€–

Core concepts, starter applications, framework integrations, and deployment guides. Use these resources to build applications like RAG chatbots, semantic search engines, or custom AI tools.

Explore AI Tools β†’

Top comments (0)

Image of Stellar post

Check out Episode 1: How a Hackathon Project Became a Web3 Startup πŸš€

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay