/development

Sets up and manages a development environment for all services / applications.

Primary LanguageShell

This is a top-level repository that helps get a Braven development environment setup on your local machine.

The list of repositories that this sets up is located in repos.txt

Getting Started

First, Fork this repository and all repositories in the repos.txt file.

Ask your team lead to setup an AWS account that can access the proper development S3 buckets. Once you have an account created, add the key and secret to your ~/.bash_profile like so:

export AWS_ACCESS_KEY_ID=<your_key>
export AWS_SECRET_ACCESS_KEY=<your_secret>

Also add the Salesforce Sandbox related environment variables documented here: (https://github.com/beyond-z/beyondz-platform/blob/staging/README.md)

cd [some_root_src_dir]
git clone https://github.com/[your_username]/development.git development
cd development
./setup.sh

After the initial setup, you may have to restart each app after the databases have all loaded b/c we haven't yet solved the timing issue for the app to wait and retry until the DB is up.

Note: this setup.sh script is really only meant for initial setup. Once you have run it once, it may not do what you expect b/c it doesn't rebuild the environment. After initial setup, use the local docker-compose/scripts/rebuild.sh for any apps that you want to cleanly pull in all the latest changes.

Connecting to services

All services are available at the service name specified in the docker-compose.yml inside that repository. Examples:

Development

We use a standard fork/branch/pull-request workflow. To make changes, always start with that repository's staging branch and create your own branch from it. Here is an example of making a change to the Join server (aka beyondz-platform):

cd development/beyondz-platform
git pull upstream staging
git push staging origin
git checkout -b [some_branch]

Then make your code changes.

git add [your_changed_files]
git commit -v
# Enter A descriptive title of the change on the first line
#
# Followed by more details, especially details on how to test it!
git push origin [some_branch]

To get them back into the main codebase login to github in your browser and submit a Pull Request against the beyond-z repo you forked.

Once the Pull Request is merged back to staging, you can delete your development branch:

git checkout staging; git pull upstream staging; git branch -d
[some_branch]; git push origin staging

Note: You can commit multiple times to your branch before you are ready to open a Pull Request. You can also keep committing to your branch even after the Pull Request has been opened as long as it hasn't been merged yet. Just remember to push your commits to origin for them to be included in the Pull Request.

Tips and Tricks

I highly recommend you add this to your ~/.bash_profile

# If you're in the app root of any of our repos, these aliases let you 
# manage the dev env easy
alias devrs='./docker-compose/scripts/restart.sh'
alias devrb='./docker-compose/scripts/rebuild.sh'
alias devdb='./docker-compose/scripts/dbconnect.sh'
alias devc='./docker-compose/scripts/console.sh'
alias deva='./docker-compose/scripts/appconnect.sh'

Also, if you add this as well, it will show the current branch you're on in the shell. E.g. ~/src/development/beyondz-platform(current_branch_name) $

# Adds the current git branch in parentheses to the shell prompt.  E.g. ~/src/my-repo(master)$
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
  }
PS1="\w(\$(parse_git_branch)) $ "