Skip to content

feat(ci): add Node.js CI workflow for build, lint, and test #1

feat(ci): add Node.js CI workflow for build, lint, and test

feat(ci): add Node.js CI workflow for build, lint, and test #1

Workflow file for this run

name: Node.js CI
on:
push:
branches: ["main","nodejs-workflows"]
pull_request:
branches: ["main"]
jobs:
build:
name: Build, Lint, and Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Display Node.js version
run: node -v
- name: Install dependencies
run: npm ci
- name: Cache node_modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Build the project
run: npm run build --if-present
- name: Lint the code
run: npm run lint
- name: Run Prettier
run: npm run prettier
- name: Run tests
run: npm test