Skip to content

Latest commit

 

History

History

backend

Backend module

Backend service built with Spring Boot.

Prerequisites

Java 21, Docker for building + running the containerized application:

brew install openjdk@21
brew install --cask docker # or just `brew install docker` if you don't want the Desktop app

Install the latest LTS version of node for running Spotless with Prettier.

Running and developing

Set up and boot the postgres database and the redis database (from the project root):

docker compose up postgres14 redis

You can then start the backend with two different options:

  1. Running the bootRun Gradle task.
  2. Creating a Run/Debug config in your IDE with Spring support using the profile local
    • This is important to initialize the bootstrap test data

Tests

The project has distinct unit and integration test sets.

To run just the unit tests:

./gradlew test

To run the integration tests:

./gradlew integrationTest

Note: Running integration tests requires passing unit tests (in Gradle terms: integration tests depend on unit tests), so unit tests are going to be run first. In case there are failing unit tests we won't attempt to continue running any integration tests.

To run integration tests exclusively, without the unit test dependency:

./gradlew integrationTest --exclude-task test

Denoting an integration test is accomplished by using a JUnit 5 tag annotation: @Tag("integration").

Furthermore, there is another type of test worth mentioning. We're using ArchUnit for ensuring certain architectural characteristics, for instance making sure that there are no cyclic dependencies.

Formatting

Java source code formatting must conform to the Google Java Style. Consistent formatting, for Java as well as various other types of source code, is being enforced via Spotless.

Check formatting:

./gradlew spotlessCheck

Autoformat sources:

./gradlew spotlessApply

Code quality analysis

Continuous code quality analysis is performed in the pipeline upon pushing to trunk; it requires a token provided as SONAR_TOKEN repository secret that needs to be obtained from https://sonarcloud.io.

To run the analysis locally:

SONAR_TOKEN=[sonar-token] ./gradlew sonarqube

Go to https://sonarcloud.io for the analysis results.

License Scanning

License scanning is performed as part of the pipeline's build job. Whenever a production dependency is being added with a yet unknown license the build is going to fail.

To run a scan locally:

./gradlew checkLicense

Javadoc comments check

We aim to write Javadoc comments to at least all public classes and methods. To fulfill this goal we use checkstyle, which is integrated not only into gradle but into lefthook (pre-commit)

To run a check locally:

./gradlew check

Check for outdated libraries

If the following statement prints a number > 0, then there are outdated libraries:

./gradlew versionCatalogUpdate
jq .outdated.count build/dependencyUpdates/report.json