#17 Create the workflow CI. #15
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: CI for ecomm-project for Dynamite | |
on: | |
push: | |
branches: [ "develop" ] | |
pull_request: | |
branches: [ "develop" ] | |
jobs: | |
build: | |
#git hub offer virtual machines to run workflows so we will be using ubuntu lastest version its standand one | |
#we using ubuntu because we want to use lunex terminal | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
#each version we specify we be tested on | |
#we are only limited to 3 versions | |
node-version: [16.x, 18.x, 20.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} #this will help use know which version we are testing on. | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' #this we help speed up the workflow by reusing dependencies from previous runs | |
- run: npm ci #run dependencies installing we using ci in place of 'npm install' becouse ci(clearn install) is smooth and faster | |
- run: npm run test --if-present #this line will run test script | |
- run: npm run lint --if-present | |
- run: npm run build --if-present # we using if statement because initial the code have no build script in packege.json | |
- run: npm run test:ci --if-present # this will run test with coverage flag | |
- name: Upload coverage to Coveralls | |
uses: coverallsapp/github-action@v2 | |
with: | |
allow-empty: true |