Skip to content

Getting started guide for developers

Mariia Nesvit edited this page Nov 2, 2020 · 14 revisions

WHAT TO DO

You can check a video version by this link: setting up

Preparing infrastructure

  • Download or clone project
  • Download and install Docker
  • Prepare IDE(Idea)
  • Prepare Git
  • Prepare Docker
  • PREPARE ITELLIJ IDEA FOR SCALA

Install Scala plug-in

settings -> plugins -> enter "scala"

Prepare scala formatter

settings -> editor -> codestyle -> scala ->

  • Scheme -> Project
  • Formatter -> Scalafmt
  • Reformat on file save - switch On
  • Check your format-config file must be .scalafmt.conf instead of Default (root project directory)
  • To USE Scala formatter in Idea use: Ctrl + Alt + O - optimize imports Ctrl + Alt + L - format code

Enable GitHook(See KB)

For Windows

  • Using Gitbash terminal go to the project folder and run this command:
bash instal.sh

Tips & Tricks preparing sbt preferences in idea to use sbt shell

Prepare IntelliJ SBT configuration:

  • Settings -> Build, Execution, Deployment -> Build Tools -> Sbt

  • Switch radio-button to Custom, and choose your SBT-installation path(sbt-launch.jar)

  • Download -> check On Library Sources, sbt sources

  • Use SBT-shell -> for imports, for builds

Git. Our work style and workflow. Rules on the project(for students only)

  • We only use rebase. Do not use merge, ever. We use forks, so we push into our forks, not to the origin Before we push, we squash commits using rebase(rebase -i HEAD~)
  • Try not to squash commits that aren't yours, to do that carefully count commits on your branch, it is better to squash not all commits but to avoid conflicts.
  • It is not good practice to force-push your commits(cause this way we lose informative history), so try to check everything and do everything before you push
  • Name your requests like: "EPMLSTRCMW-142: Get project versions from GitLab" - where 142 -is task number in JIRA, and "Get project versions from GitLab" - is branch description
  • Name your branches like: "EPMLSTRCMW-46-setup-project" - using the same rules as in point above When you are ready to be reviewed you should notify(link in clack)your colleagues

Prepare Docker

To tune IDEA to work with DB in Docker

  • run->edit configurations->environment variables-> add variables: EXAMPLE(you should change variables values as you wish):
CMWL_DB_SERVER_NAME=localhost;CMWL_DB_PORT_NUMBER=5432;CMWL_DB_NAME=postgres;CMWL_DB_USER=postgres;CMWL_DB_PASSWORD=docker;
CMWL_MONGO_USER=mongoUser;CMWL_MONGO_PASSWORD=password;CMWL_MONGO_HOST=localhost;CMWL_MONGO_PORT=27017;CMWL_MONGO_AUTH=admin;CMWL_MONGO_DB=mongo;CMWL_MONGO_COLLECTION=configurations;

The same for tests will be done:

CMWL_TEST_DB_SERVER_NAME=localhost;CMWL_TEST_DB_PORT_NUMBER=5432;CMWL_TEST_DB_NAME=postgres;CMWL_TEST_DB_USER=postgres;CMWL_TEST_DB_PASSWORD=docker;
CMWL_TEST_MONGO_USER=mongoUser;CMWL_TEST_MONGO_PASSWORD=password;CMWL_TEST_MONGO_HOST=localhost;CMWL_TEST_MONGO_PORT=27017;CMWL_TEST_MONGO_AUTH=admin;CMWL_TEST_MONGO_DB=mongo;CMWL_TEST_MONGO_COLLECTION=configurations

In unix systems or windows after installing Docker before every project run you should run:

docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres
docker run --rm --name mongo-docker -d -p 27017:27017 mongo mongod - auth
  • instead of previous line you can try:
docker run --rm --name mongo-docker -d -p 27017:27017 mongo

For MongoDB you should first run:

sudo docker exec -i -t mongo-docker bash
mongo
use admin
db.createUser({user:"mongoUser",pwd:"password",roles:[{role:"root",db:"admin"}]})

or you can try

mongo --username mongoUser --password password --authenticationDatabase admin  --host localhost  --port 27017

and then

db.createUser({user:"mongoUser",pwd:"password",roles:[{role:"root",db:"admin"}]})

Prepare Gitlab

Gitlab is available by this address: https://gitlab.cmwl.ru.com/

Make sure you got your GlobalProtect app connected to the EPAM VPN network otherwise you'll not be able work with gitlab.

Then you should add Environment variable with Gitlab token to your idea

CMWL_GITLAB_TOKEN=

A value for CMWL_GITLAB_TOKEN you should copy from this link: CMWL_GITLAB_TOKEN

If you signed-in AWS and still get an error, trying to open a link, then choose this region "Asia Pacific (Tokyo)ap-northeast-1"

Also make sure that config file in cmwl_pipeline/portal/src/main/resources/application.conf has been configured properly:

  gitlab {
    url = "https://gitlab.cmwl.ru.com/api/v4/"
    path = "admin"
    path = ${?CMWL_GITLAB_USER_NAME}
    token = "token"
    token = ${?CMWL_GITLAB_TOKEN}
    defaultFileVersion = "v0.0.1"
    defaultFileVersion = ${?CMWL_DEFAULT_FILE_VERSION}
    defaultBranch = "master"
    defaultBranch = ${?CMWL_DEFAULT_BRANCH}
  }

Summary

  • create a fork and work with it
  • name of commits are checked by githook(see readme)
  • as you can see in our Travis configurations, Travis build, in addition to test and it:test, includes a task to check undeclared dependencies, so pay attention to dependencies you create, and be sure, that they are declared in build.
  • sbt in order to pass undeclaredCompileDependenciesTest task be sure your task has passed Travis check before you ask to review it(name requests and branches using style-guides)