feat(ci): add Node.js CI workflow for build, lint, and test #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |