2020-02-13 10:01:33 +01:00
# Development of OpenSlides 4
2020-07-16 15:20:07 +02:00
## Requirements
2020-07-31 09:22:01 +02:00
You need git, bash, docker, docker-compose, make and openssl installed.
2020-07-16 15:20:07 +02:00
Go is needed to install https://github.com/FiloSottile/mkcert. The development setup uses HTTPS per default. OpenSlides does not work with HTTP anymore since features are required (like http2) that only works in a secure environment.
2020-02-13 10:01:33 +01:00
## First time checkout
2020-07-16 15:20:07 +02:00
Clone this repository:
2021-08-19 12:32:05 +02:00
$ git clone --recurse-submodules git@github.com:OpenSlides/OpenSlides.git
2020-07-16 15:20:07 +02:00
2021-08-19 12:32:05 +02:00
After checking out you need to initialize all submodules:
2020-02-13 10:01:33 +01:00
$ git submodule update --init
2020-07-16 15:20:07 +02:00
2021-08-19 12:32:05 +02:00
Finally, start the development server:
2020-07-16 15:20:07 +02:00
2020-02-13 10:01:33 +01:00
$ make run-dev
2020-08-14 11:09:49 +02:00
You can access the services independently using their corresponding ports
or access the full stack on
$ https://localhost:8000
2020-02-13 10:01:33 +01:00
## Running tests
To run all tests of all services, execute `run-service-tests` . TODO: Systemtests in this repo.
## Adding a new Service
$ git submodule add < git @ myrepo . git >
2022-01-10 17:46:40 +01:00
Append `branch = main` to the new entry in the `.gitmodules` file. Verify,
2020-02-13 10:01:33 +01:00
that it is there (the folder should have 160000 permissions: Submodule) with the
current commit:
$ git diff --cached
2020-06-10 13:58:26 +02:00
Then, commit changes and create a pull request.
2020-02-13 10:01:33 +01:00
## Work in submodules
2020-08-14 11:09:49 +02:00
Create your own fork at github.
2022-01-10 17:46:40 +01:00
Remove the upstream repo as the origin in the submodule:
2020-06-10 13:58:26 +02:00
2020-02-26 15:07:30 +01:00
$ cd < submodule >
$ git remote remove origin
2020-02-13 10:01:33 +01:00
2020-08-14 11:09:49 +02:00
Add your fork and the main repo as origin and upstream
2020-06-10 13:58:26 +02:00
2020-08-14 11:09:49 +02:00
$ git remote add origin `<your fork>`
$ git remote add upstream `<main repo>`
$ git fetch --all
2022-01-10 17:46:40 +01:00
$ git checkout origin main
2021-08-19 12:32:05 +02:00
You can verify that your setup is correct using
$ git remote -v
The output should be similar to
origin git@github.com:< GithubUsername > /OpenSlides.git (fetch)
origin git@github.com:< GithubUsername > /OpenSlides.git (push)
upstream git@github.com:OpenSlides/OpenSlides.git (fetch)
upstream git@github.com:OpenSlides/OpenSlides.git (push)
2020-02-13 10:01:33 +01:00
## Requirements for services
### Environment variables
2020-02-26 15:07:30 +01:00
These environment variables are available:
- `<SERVICE>_HOST` : The host from a required service
- `<SERVICE>_PORT` : The port from a required service
2020-02-13 10:01:33 +01:00
Required services can be `MESSAGE_BUS` , `DATASTORE_WRITER` , `PERMISSION` , `AUTOUPDATE` ,
etc. For private services (e.g. a database dedicated to exactly one service),
use the following syntax: `<SERVICE>_<PRIV_SERVICE>_<ATTRIBUTE>` , e.g. the
Postgresql user for the datastore: `DATASTORE_POSTGRESQL_USER` .
### Makefile
A makefile must be provided at the root-level of the service. The currently
required (phony) targets are:
2020-02-26 15:07:30 +01:00
- `run-tests` : Execute all tests from the submodule
- `build-dev` : Build an image with the tag `openslides-<service>-dev`
2020-02-13 10:01:33 +01:00
2020-02-28 12:55:21 +01:00
### Build arguments in the Dockerfile
These build arguments should be supported by every service:
- `REPOSITORY_URL` : The git-url for the repository to use
- `GIT_CHECKOUT` : A branch/tag/commit to check out during the build
Note that meaningful defaults should be provided in the Dockerfile.
2020-02-13 10:01:33 +01:00
## Developing on a single service
2022-01-10 17:46:40 +01:00
Go to the serivce and create a new branch (from main):
2020-02-13 10:01:33 +01:00
$ cd my-service
2022-01-10 17:46:40 +01:00
$ git status # -> on main?
2020-02-13 10:01:33 +01:00
$ git checkout -b my-feature
Run OpenSlides in development mode (e.g. in a new terminal):
$ make run-dev
After making some changes in my-service, create a commit and push to your fork
$ git add -A
$ git commit -m "A meaningful commit message here"
2021-08-19 12:32:05 +02:00
$ git push origin -u my-feature
2020-02-13 10:01:33 +01:00
As the last step, you can create a PR on Github. After merging, these steps are
required to be executed in the main repo:
$ cd my-service
2022-01-10 17:46:40 +01:00
$ git pull upstream main
2020-02-13 10:01:33 +01:00
$ cd ..
$ git diff # -> commit hash changed for my-service
If the update commit should be a PR:
2020-02-26 15:07:30 +01:00
2020-02-13 10:01:33 +01:00
$ git checkout -b updated-my-service
$ git commit -am "Updated my-service"
$ git push origin updated-my-service
2022-01-10 17:46:40 +01:00
Or a direct push on main:
2020-02-26 15:07:30 +01:00
2020-02-13 10:01:33 +01:00
$ git commit -am "Updated my-service"
2022-01-10 17:46:40 +01:00
$ git push origin main
2020-02-13 10:01:33 +01:00
2020-06-10 13:58:26 +02:00
## Working with Submodules
2020-02-13 10:01:33 +01:00
After working in many services with different branches, this command checks
2022-01-10 17:46:40 +01:00
out `main` (or the given branch in the .gitmodules) in all submodules and
pulls main from upstream (This requres to have `upstream` set up as a remote
2020-06-10 13:58:26 +02:00
in all submodules):
2022-01-10 17:46:40 +01:00
$ git submodule foreach -q --recursive 'git checkout $(git config -f $toplevel/.gitmodules submodule.$name.branch || echo main); git pull upstream $(git config -f $toplevel/.gitmodules submodule.$name.branch || echo main)'
2020-06-10 13:58:26 +02:00
2021-08-19 12:32:05 +02:00
This command has can also be called from the makefile using:
2022-01-10 17:46:40 +01:00
$ make services-to-main
2021-08-19 12:32:05 +02:00
2020-06-10 13:58:26 +02:00
When changing the branch in the main repo (this one), the submodules do not
automatically gets changed. THis ocmmand checks out all submodules to the given
commits in the main repo:
$ git submodule update
2020-02-13 10:01:33 +01:00