HINT - HIV Indicators Tool
SpringBoot Kotlin web app for interfacing with the Naomi model for joint small-area estimation of HIV prevalence, ART coverage, and HIV incidence via the hintr package
Developing
Requirements:
- Docker
- npm
- openjdk 11 Mac users may find it easier to install adoptopenjdk-11k rather than openjdk-11: wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add - add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ apt-get update apt-get install adoptopenjdk-11-hotspot -y
- coreutils or realpath (Mac users only)
- Clone this repo
- Run
npm installfromsrc/app/static - Run
./scripts/run-development-dependencies.shto start docker instances of hint-db and hintr and add a test user with usernametest.user@example.comand passwordpassword. - Run
npm run buildfromsrc/app/staticto compile front-end dependencies. - Run app from your IDE or by
./src/gradlew -p src :app:bootRunto serve the app on port 8080
To run with hot reloading of the front end, after installing npm packages and running development dependencies.
- Open a terminal at
src/app/staticand runnpm run serve - In another terminal, from the root run
src/gradlew -PhotReload=true -p src app:bootRun
For more information about developing the front-end see src/app/static/README
For more information on Generic Chart, see /docs/GenericChart.md
Run up app with Auth0 authentication
By default, when running up the app locally we use our own authentication system. On production we are using Auth0 to manage users and enable SSO with the ADR. Sometimes it can be useful to run up the local app using Auth0 authentication, so we can develop or test those slightly different UIs. To run locally with Auth0
- Read the secrets from vault
vault read secret/hint/oauth2/developmentif you want to use the production auth0 tenant with dev ADR. - Place these into the
config.propertiesat./src/app/src/main/resources/config.propertiesin the following wayoauth2_client_idto be theidvalueoauth2_client_secretto be thesecretvalueoauth2_client_urlto be theurlvalueoauth2_client_audienceto be theaudiencevalueoauth2_client_adr_server_urlto be theadr_server_urlvalue
- Set the
oauth2_login_methodinconfig.propertiesto true - Ensure that you do not commit the secret to github
Testing
Ensure dependencies are running and then execute tests on the command line or through IntelliJ
./scripts/run-development-dependencies.sh./src/gradlew -p src :app:test
To run a specific test alone, add --test + the fully qualified class name to the command. For example, the command for running ProjectsControllerTests.kt would be: ./src/gradlew -p src :app:test --tests org.imperial.mrc.hint.unit.controllers.ProjectsControllerTests
Linting
./src/gradlew -p src :app:detektMainDatabase Interface
If the database schema has changed, you can regenerate the database interface code (in /src/databaseInterface)
by running ./src/gradlew -p src :generateDatabaseInterface:run while the database container is running.
Versioning
HINT Versions are recorded here. The latest version should match the value of currentHintVersion in
src/app/static/src/app/hintVersion.ts
If you make any change to the application which affects its functionality (i.e. anything other than a refactor, or documentation or CI change, you should update the version by adding an entry to NEWS.md and setting currentHintVersion).
Versions should follow the semantic versioning format, so you should update the:
- MAJOR version when you make incompatible changes (e.g. a change to serialised version state format),
- MINOR version when you add functionality in a backwards compatible manner, and
- PATCH version when you make backwards compatible bug fixes.
This may cause relatively frequently conflicts since more than one person is likely to be working on a new version at a time. In this case, you should give your branch its own new version number, rather than rolling your changes into the same version number as changes from another branch.
Distribution
A docker image containing the app is created as part of the BuildKite build. To create such an image locally,
run ./buildkite/make-build-env.sh followed by ./buildkite/build.sh. A CLI image is also created as part of
the BuildKite build, using ./buildkite/build-cli.sh.
Run docker run -p 8080:8080 --name hint mrcide/hint:branch_name to run a built image. The app will not start until
config is provided at /etc/hint/config.properties. This config is added during deployment with
hint-deploy