-
-
Notifications
You must be signed in to change notification settings - Fork 229
Development
The backend is written in Kotlin and Spring Boot. To run it, you will need:
- Java 17
- Docker
git clone git@github.com:tolgee/tolgee-platform.git
You can use
./gradlew server-app:bootRun --args='--spring.profiles.active=dev'
- Open the root dir in Idea CE
- Click the Edit configurations button in the top right corner
- Add a new configuration with the plus button
- Select
Gradle
- Set run command to
server-app:bootRun --args='--spring.profiles.active=dev'
- Click the run/debug button in the top right corner with the newly created configuration
- Open the root dir in Idea Ultimate
- Edit run configurations in the top right corner
- Duplicate Spring Boot auto-created configuration
- Rename to "Application Dev"
- Set
Active profiles
input to "dev" - Save by clicking OK
- Select the "Application Dev" configuration in the dropdown.
- Run it with the Run/Debug button
To configure Tolgee, create an empty file backend/app/src/main/resources/application-dev.yaml
. In this file, you can override default configuration properties. You can check application-e2e.yaml
for inspiration. To learn more about externalized configuration in Spring boot, read the docs.
Since we set the active profile to dev
, Spring uses the application-dev.yaml configuration file.
Tolgee uses Liquibase to handle the database migration. The migrations are run on every app startup. To update the changelog, run:
./gradlew diffChangeLog
-
If you misspell the command and run
diffChangelog
, it will find the command, but it would fail, since liquibase changed the command name in the past. We have enhanced thediffChangeLog
(with capital L) command, so you have to run that. -
Sometimes, Gradle cannot find a
docker
command to start the database instance to generate the changelog against. This happens due to some issue with setting the paths for Gradle daemon. Running the command without daemon fixes the issue../gradlew diffChangeLog --no-daemon
- node.js v18 or newer
- go to webapp folder
cd webapp
- Install npm packages "npm ci"
- Run it
npm run start
For the frontend, there are npm tasks prettier
and eslint
, which you should run before every commit. Otherwise, the "Frontend static check" workflow will fail. You can also use prettier plugins for VS Code, Idea, or WebStorm.
To fix prettier issues and check everything is fine, run these commands in webapp
dir:
npm run prettier
npm run tsc
npm run eslint
On the backend, there is Gradle task ktlintFormat, which helps you to format Kotlin code.
./gradlew ktlintFormat
The backend of Tolgee is tested with unit and integration tests. UI and its interaction with the backend are tested using E2E cypress tests.
To run backend tests, you can run Gradle test
task
./gradlew test
Or you can select any integration test the code and run it via Idea CE or Idea Ultimate. It should just work out of the box.
Running E2E tests can be a bit more complicated.
To just run it, you can execute the runE2e
Gradle task. This command runs a complex task, which installs all dependencies and runs everything it needs.
./gradlew runE2e
- Instal npm packages in
e2e
dir
cd e2e
npm install
- Install npm packages in
webapp
dir
However, when developing you would probably also want to modify the frontend code or debug the backend. To do so, you have to run 4 different tasks at the same time.
- Run the web app with E2e settings
./gradlew runWebAppNpmStartE2eDev
- Run the E2e Docker services like fake SMTP server
./gradlew runDockerE2eDev
- Run the backend with
e2e
profile
./gradlew server-app:bootRun --args='--spring.profiles.active=e2e'
You can also do this by running the application with the E2e profile using Idea CE or Ultimate. Then you will be also able to debug the backend while running the tests, which can be pretty useful.
- Run the cypress
./gradlew openE2eDev
These 4 tasks have to run at the same time
When you are done, you can stop docker by running:
./gradlew stopDockerE2e