# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: ontime_test_CI

on: [push, pull_request]

jobs:
  build:

    runs-on: ubuntu-latest
    env:
      CI: ''

    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '14.x'

      # Utils server
      - name: Utils - Install dependencies
        run: yarn install
        working-directory: ./server/utils

      - name: Utils - run link command
        run: yarn link
        working-directory: ./server/utils

      # React
      - name: React - Link to utils
        run: yarn link ontime-utils
        working-directory: ./client

      - name: React - Install dependencies
        run: yarn install
        working-directory: ./client

      - name: React - Run tests
        run: yarn test:pipeline
        working-directory: ./client

      - name: React - Build project
        run: yarn build
        working-directory: ./client

      # Node server
      - name: React - Link to utils
        run: yarn link ontime-utils
        working-directory: ./server/src

      - name: Server - Install dependencies
        run: yarn install
        working-directory: ./server/src

      # App
      - name: Electron - Install dependencies
        run: yarn install
        working-directory: ./server

      - name: Electron - Run tests
        run: yarn test
        working-directory: ./server
