Skip to content

Feature/add json server (#17) #72

Feature/add json server (#17)

Feature/add json server (#17) #72

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: CI/CD
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
defaults:
run:
working-directory: ./apps
jobs:
install:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: apps/package-lock.json
- name: Cache NPM dependencies
uses: actions/cache@v3
id: cache-npm
with:
# npm cache files are stored in `~/.npm`
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
- name: Install package-lock dependencies
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
lint:
runs-on: ubuntu-latest
needs: install
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
# npm cache files are stored in `~/.npm`
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
- name: Linting app
run: |
npm ci
npm run lint
test:
runs-on: ubuntu-latest
needs: install
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
# npm cache files are stored in `~/.npm`
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
- name: Cypress E2E
uses: cypress-io/github-action@v6
with:
working-directory: ./apps
config: retries=1
# start parameter is used for starting the server, json-server is required for booklist tests
start: npm run server
# command parameter overwrites the Cypress run command with your custom command
command: npm run cy:run
- name: Artifacts
uses: actions/upload-artifact@v4
# store screenshots only on failures
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
if-no-files-found: warn