We welcome everyone to contribute to ehealth.api. The project is written in Elixir language and its best practicies are applied to this project.
Environment requirements:
- elixir 1.8+
- postgresql 9.6+
- postgis extension
- redis
$ git clone [email protected]:edenlabllc/ehealth.api.git
$ mix deps.get
$ mix test
Once tests are passed, you're ready to make your contribution.
develop
- main development branch
preprod
- used for demo/preprod environments
master
- branch for use to production deploy, should always reflect production state.
All new branches should be created from develop
and PR's opened into develop
branches.
Tags seems useless with umbrella app, we can't rely on them anymore.
- Fork repository
- Create a feature branch from
develop
- Commit your changes
- Push back to your repository
- Create a PR to
ehealth.api
There are some general contribution rules we follow to keep each PR easy to understand and manage:
- PR shouldn't be large. Thousands of lines can't be easily reviewed and merged with confidence. Keep is as simple as possible.
- PR should either fix existing issue or implement a documented feature. We probably won't merge features not included in roadmap. In case a new bug is found, please report an issue before starting a PR. PR must be linked with an issue
- Write tests. We keep tests coverage about 90%, the PR shouldn't decrease that value. Each bug or feature should be covered with appropriate tests.
- Naming rules. Use Elixir naming conventions
- Use pattern matching where it's possible.
- Since
ehealth.api
is just a single microservice among many others, to test requests between them we use a Mox library. That means sometimes you need to refer to different repository to understand how to mock the request response. - Environment variables should be used for the application configuration. Whenever you add new configuration parameter, it should be added to the [docs/environment.md] documentation of the respective application.
We use travis.ci as CI engine. Each PR triggers travis builds which run tests and build docker images. So, to be able to merge the PR, tests should pass and image should be able to build. Furthermore, we use Elixir formatter to format the code and credo as static code analysis tool. Before creating a PR, you can verify that:
mix test
mix format
mix credo --strict
If one of them fail, travis build will fail too and PR can't be merged.
Step-by-step manual how to run the cluster from scratch with the recommended default env. vars values
To create a hotfix, you need to create a branch from the master
, apply a hotfix and create a PR back to master.
For code consistency, you should apply the same commit to develop
and preprod
branches.
- Pull the latest
develop
- Create a
release
branch fromdevelop
- Run
mix git_ops.release
, and add--init
option if first release - Do not commit and tag, on interactive question
Shell we commit and tag
pressN
- Run
git commit -am '[ci skip] chore: release ...'
to skip build on PR - Run
git push origin release
to push your changes - Create pull request to
develop
fromrelease
branch - After PR successfully merged, pull latest
develop
, - Add tag
git tag *.*.*
and push tags remotegit push origin *.*.*
(tag name) - Delete old
release
branch locally, rungit branch -D release
- Create a
release
branch fromdevelop
- Rebase on master
git rebase master
- Push changes (step 6)
- Create pull request on master and select
rebase and merge
option when merge - After PR successfully merged, created image can be deployed to demo/preprod/prod
- Pull the latest
master
- Create a
release
branch frommaster
- Cherry-pick your commits
git cherry-pick hotfix-commit-hash
, solve all conflict if any - Create pull request on
master
and selectrebase and merge
option when merge