Skip to content

Commit

Permalink
Merge pull request #28 from jordanwalsh23/feat/add-ci-tests
Browse files Browse the repository at this point in the history
Create node-tests.yml
  • Loading branch information
jordanwalsh23 authored Jul 19, 2024
2 parents d342093 + d797e2d commit adbcef7
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/node-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Author: Ashutosh Kumar
# Date: 2023-09-25
# Version: 1.0
# Description: This GitHub Actions workflow automates Node.js CI/CD for a Node.js project.
# It performs the following steps:

# Step 1: Check out the source code.
# Step 2: Set up different versions of Node.js for testing.
# Step 3: Perform a clean install of Node.js dependencies.
# Step 4: Cache and restore dependencies for faster builds.
# Step 5: Build the source code.
# Step 6: Run tests using different versions of Node.js.

name: Node.js CI

on:
push:
branches: [ main ] # Trigger the workflow on every commit to the main branch.
pull_request:
branches: [ main ] # Trigger the workflow on pull requests targeting the main branch.

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x] # Define a matrix of Node.js versions to test.There would be 3 jobs for 12.x, 14.x, 16.x

steps:
- name: Checkout code
uses: actions/checkout@v2 # Step 1: Check out the source code from the repository.

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm' # Step 2: Use npm caching for faster dependency installs.

- name: Install Node.js dependencies
run: npm ci # Step 3: Perform a clean install of Node.js dependencies.

- name: Run tests
run: npm test # Step 4: Run tests using the specified Node.js version.

0 comments on commit adbcef7

Please sign in to comment.