add eslint and use multi steps, remove eslint.workingdirectories in b… #27
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 | |
on: | |
push: | |
branches: [test] | |
pull_request: | |
branches: [test] | |
env: | |
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | |
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
DB_USER_PASS: ${{ secrets.DB_USER_PASS }} | |
jobs: | |
Jest-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 20 | |
- name: Install front dependencies | |
run: | | |
cd client | |
npm ci | |
- name: Install back dependencies | |
run: | | |
cd server | |
npm ci | |
- name: Run back Jest tests | |
run: | | |
cd server | |
npm test | |
- name: run back server | |
run: | | |
cd server | |
npm run watch & | |
- name: Run front Jest tests | |
run: | | |
cd client | |
npm test | |
Eslint-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 20 | |
- name: Run back Eslint test | |
run: | | |
cd server | |
npx eslint **/*.js -o ./eslint/back_Eslint.txt --no-color | |
- name: Run front Eslint test | |
run: | | |
cd client | |
npx eslint **/*.js -o ./eslint/front_Eslint.txt --no-color | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 20 | |
- name: Build front | |
if: ${{ success() }} | |
run: | | |
cd client | |
npm run build | |
- name: Build Docker images and push to Docker Hub | |
run: | | |
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
docker build ./client -t khagu/khagu-dev-front:latest | |
docker push khagu/khagu-dev-front:latest | |
docker build ./server -t khagu/khagu-dev-back:latest | |
docker push khagu/khagu-dev-back:latest |