Skip to content

Commit

Permalink
feat(ci): add Node.js CI workflow for build, lint, and test (#14)
Browse files Browse the repository at this point in the history
* chore: allows package-lock.json file to be uploaded into the repo

* build: upload package-lock.json required for Node.JS CI pipeline

* build: package.json scripts for Node.JS CI pipeline

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

- Added a GitHub Actions workflow for Node.js CI
- Workflow triggers on push to 'main' and 'nodejs-workflows' branches, and on pull requests to 'main'
- Uses Node.js version 18.x for testing
- Includes steps for checking out the repository, setting up Node.js, installing dependencies, caching node_modules, building the project, linting the code, running Prettier, and running tests
  • Loading branch information
supitsdu authored Jun 13, 2024
1 parent d9123c6 commit ecbad19
Show file tree
Hide file tree
Showing 4 changed files with 4,603 additions and 3 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ coverage/
*.tgz

# Ignore lock files
*-lock.*
*.lockb

# Ignore IDE and editor-specific files and directories
Expand Down
Loading

0 comments on commit ecbad19

Please sign in to comment.