This is a guide for developers who would like to contribute to this project.
If you're interested in contributing to mycli, thank you. We'd love your help! You'll always get credit for your work.
-
Fork the repository on GitHub.
-
Clone your fork locally:
$ git clone <url-for-your-fork>
-
Add the official repository (
upstream) as a remote repository:$ git remote add upstream git@github.com:dbcli/mycli.git
-
Set up a virtual environment for development:
$ cd mycli $ pip install virtualenv $ virtualenv mycli_devWe've just created a virtual environment that we'll use to install all the dependencies and tools we need to work on mycli. Whenever you want to work on mycli, you need to activate the virtual environment:
$ source mycli_dev/bin/activateWhen you're done working, you can deactivate the virtual environment:
$ deactivate
-
Install the dependencies and development tools:
$ pip install -r requirements-dev.txt $ pip install --editable . -
Create a branch for your bugfix or feature based off the
masterbranch:$ git checkout -b <name-of-bugfix-or-feature> master
-
While you work on your bugfix or feature, be sure to pull the latest changes from
upstream. This ensures that your local codebase is up-to-date:$ git pull upstream master
-
When your work is ready for the mycli team to review it, push your branch to your fork:
$ git push origin <name-of-bugfix-or-feature>
-
Create a pull request on GitHub.
While you work on mycli, it's important to run the tests to make sure your code hasn't broken any existing functionality. To run the tests, just type in:
$ ./setup.py testMycli supports Python 2.7 and 3.4+. You can test against multiple versions of Python by running:
$ ./setup.py test --allYou can also measure mycli's test coverage by running:
$ ./setup.py test --coverageThe tests require a database connection to work. You can tell the tests which credentials to use by setting the applicable environment variables:
$ export PYTEST_HOST=localhost
$ export PYTEST_USER=user
$ export PYTEST_PASSWORD=myclirocks
$ export PYTEST_PORT=3306
$ export PYTEST_CHARSET=utf8The default values are localhost, root, no password, 3306, and utf8.
You only need to set the values that differ from the defaults.
Some CLI tests expect the program ex to be a symbolic link to vim.
In some systems (e.g. Archlinux) ex is a symbolic link to vi, which will
change the output and therefore make some tests fail.
You can check this by running:
$ readlink -f $(which ex)Mycli requires code submissions to adhere to PEP 8. It's easy to check the style of your code, just run:
$ ./setup.py lintIf you see any PEP 8 style issues, you can automatically fix them by running:
$ ./setup.py lint --fixBe sure to commit and push any PEP 8 fixes.