Backend service built with Spring Boot.
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.
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:
- Running the
bootRun
Gradle task. - Creating a Run/Debug config in your IDE with Spring support using the profile
local
- This is important to initialize the bootstrap test data
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.
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
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 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
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
If the following statement prints a number > 0, then there are outdated libraries:
./gradlew versionCatalogUpdate
jq .outdated.count build/dependencyUpdates/report.json