#!/usr/bin/env bash

set -euo pipefail

./install_yarn.sh
# remove cached modules, only relevant when running locally
rm -rf node_modules .spectrum-ui

# Install dependencies.
yarn install --frozen-lockfile --mutex file:../../yarn.mutex

# Install cypress dependencies
./install_cypress.sh

# Lint the entire project.
yarn lint --no-fix --max-warnings=0

# Run unit tests.
yarn test:unit

# run frontend server, required for cypress. wait up to 5 mins to be available.
yarn serve:e2e & npx wait-on --timeout 300000 http://localhost:8080

# Run cypress system tests.
yarn test:e2e:ci

# Make a production build.
export NODE_OPTIONS="--max-old-space-size=5120"
yarn build
