Skip to content

Repository files navigation

HappyCows/HappierCows

Production Deployments

Note: CMPSC 156 Student teams should not change the prod/qa links below to match their team's links; you should maintain the README.md file so that it can be merged into the https://github.com/ucsb-cs156/proj-happycows/ repo at the end of the quarter.

Type Link
prod https://happycows.dokku-00.cs.ucsb.edu/
qa https://happycows-qa.dokku-00.cs.ucsb.edu/

Sprint Planning Doc:

S26 Deployments

Tracks main branch:

Team Tracks Main Branch QA Deployment
s26-13 https://happycows.dokku-13.cs.ucsb.edu/ https://happycows-qa.dokku-13.cs.ucsb.edu/
s26-14 https://happycows.dokku-14.cs.ucsb.edu/ https://happycows-qa.dokku-14.cs.ucsb.edu/
s26-15 https://happycows.dokku-15.cs.ucsb.edu/ https://happycows-qa.dokku-15.cs.ucsb.edu/
s26-16 https://happycows.dokku-16.cs.ucsb.edu/ https://happycows-qa.dokku-16.cs.ucsb.edu/

Description

This is a full rewrite of the application HappyCows, a project sponsored by Mattanjah de Vries, Distingished Professor of Chemistry at UC Santa Barbara.

The application is a simulation game that gives players (typically students in Prof. de Vries' courses) an opportunity to learn about the Tragedy of the Commons.

This rewrite uses the new tech stack being developed for CMPSC 156. This tech stack uses:

  • Spring Boot (Java) for the backend
  • React (JavaScript) for the frontend
  • Spring Security plus Google OAuth for authentication/authorization
    • This last point is what distinguishes this tech stack from the one currently in use (as S21) for the three legacy code apps in CMPSC 156: the current apps use Auth0 with JWTs as the authentication/authorization mechanism.

The GitHub actions script to deploy the Storybook to QA requires some configuration; see docs/github-actions.md for details.

If these repos are not yet setup, see the setup steps in docs/storybook.md.

Game Play for Developers

A description of how the game is played and what scheduled actions are run are given under docs/gamePlay.md

Environment Variables

For information on environment variables used in the app, refer to docs/environment.md.

Setup before running application

Before running the application for the first time, you need to do the steps documented in docs/oauth.md.

Otherwise, when you try to login for the first time, you will likely see an error such as:

Authorization Error; Error 401: invalid_client; The OAuth client was not found.

Getting Started on localhost

  • Open two separate terminal windows
  • In the first window, start up the backend with:
    mvn spring-boot:run
    
  • In the second window:
    cd frontend
    npm install  # only on first run or when dependencies change
    npm start
    

Then, the app should be available on http://localhost:8080

If it doesn't work at first, e.g. you have a blank page on http://localhost:8080, give it a minute and a few page refreshes. Sometimes it takes a moment for everything to settle in.

If you see the following on localhost, make sure that you also have the frontend code running in a separate window.

Failed to connect to the frontend server... On Dokku, be sure that PRODUCTION is defined.  On localhost, open a second terminal window, cd into frontend and type: npm install; npm start;

Accessing swagger

To access the swagger API endpoints, use:

To run React Storybook

Accessing Database Console

To Run Integration and End-to-end Tests

In order to run the integration and end-to-end test suite, using the following series of commands

mvn clean
INTEGRATION=true mvn test-compile
INTEGRATION=true mvn failsafe:integration-test

In order to run the end-to-end tests 'not headless' use the following instead of the last command.

INTEGRATION=true HEADLESS=false mvn failsafe:integration-test

To Run Integration and End-to-end Tests

In order to run the integration and end-to-end test suite, using the following series of commands

mvn clean
INTEGRATION=true mvn test-compile
INTEGRATION=true mvn failsafe:integration-test

In order to run the end-to-end tests 'not headless' use the following instead of the last command.

INTEGRATION=true HEADLESS=false mvn failsafe:integration-test

Partial pitest runs

This repo has support for partial pitest runs

For example, to run pitest on just one class, use:

mvn pitest:mutationCoverage -DtargetClasses=edu.ucsb.cs156.example.controllers.RestaurantsController

To run pitest on just one package, use:

mvn pitest:mutationCoverage -DtargetClasses=edu.ucsb.cs156.example.controllers.\*

To run full mutation test coverage, as usual, use:

mvn pitest:mutationCoverage

Setting Node Version with NVM

The frontend/nvm-pj.sh script reads the required Node version from frontend/package.json and uses NVM to switch to it.

Since the script modifies your current shell environment, you must source it rather than execute it directly:

cd frontend
source ./nvm-pj.sh

or equivalently:

cd frontend
. ./nvm-pj.sh

Running it as ./nvm-pj.sh (without source) will not work because the Node version change would only apply to the subshell, not your current terminal session.

Releases

Packages

Used by

Contributors

Languages