Development guide
Launch the project
Requirements: * Java 21 (we recommend using sdkman! to install and manage versions of the JDK)
To develop on a specific service, you can use the provided docker-compose.yml to launch the dependencies:
docker compose -f docker-compose-dependencies.yml up -d
Then, from the root directory, launch the service:
./gradlew search-service:bootRun
Running the tests
Each service has a suite of unit and integration tests. You can run them without manually launching any external component, thanks to Spring Boot embedded test support and to the great TestContainers library.
For instance, you can launch the test suite for entity service with the following command:
./gradlew search-service:test
Building the project
To build all the services, you can launch:
./gradlew build
It will compile the source code, check the code quality (thanks to detekt) and run the tests for all the services.
For each service, a self-executable jar is produced in the build/libs directory of the service.
If you want to build only one of the services, you can launch:
./gradlew search-service:build
Committing
- Commits follow the Conventional Commits specification
- Branches follow the Conventional Branch specification
- In the context of the project, the following prefixes are authorized when naming branches:
feature/,refactor/,fix/,hotfix/andchore/.
Code quality
Code formatting and standard code quality checks are performed by Detekt. Detekt as an autocorrect command to help on easily fixable formatting:
./gradlew detekt --auto-correct
Detekt checks are automatically performed as part of the build and fail the build if any error is encountered.
-
You may consider using a plugin like Save Actions that applies changed code refactoring and optimized imports on save.
-
You can enable Detekt support with the Detekt plugin.
-
You can also set up a precommit hook to run detekt autocorrect automatically
Pre-commit
Automatic setup with pre-commit tool
(if you don't have Python installed, use the manual setup below)
* install pip install pre-commit
* then run pre-commit install
Manual setup
- copy the script in
config/detekt/detekt_auto_correct.shin your.git/pre-commitfile
Releasing a new version
- Merge
developintomaster
git checkout master
git merge develop
- Update version number in
build.gradle.kts(allprojects.versionnear the bottom of the file) and in.env(STELLIO_DOCKER_TAGenvironment variable) - Commit the modification using the following template message
git commit -am "chore: upgrade version to x.y.z"
- Push the modifications
git push origin master
The CI will then create and publish Docker images tagged with the published version number in https://hub.docker.com/u/stellio.
- On GitHub, check and publish the release notes in https://github.com/stellio-hub/stellio-context-broker/releases
Contributing
Guidelines for contributing are available here