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 uv for development:
$ cd mycli $ uv sync --extra devWe've just created a virtual environment and installed all the dependencies and tools we need to work on mycli.
-
Create a branch for your bugfix or feature based off the
mainbranch:$ git checkout -b <name-of-bugfix-or-feature> main
-
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 main
-
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.
To run mycli with your local changes:
$ uv run mycliWhile 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:
$ uv run toxSome 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=mycli
$ export PYTEST_PASSWORD=myclirocks
$ export PYTEST_PORT=3306
$ export PYTEST_CHARSET=utf8mb4The default values are localhost, root, no password, 3306, and utf8mb4.
You only need to set the values that differ from the defaults.
If you would like to run the tests as a user with only the necessary privileges,
create a mycli user and run the following grant statements.
GRANT ALL PRIVILEGES ON `mycli_%`.* TO 'mycli'@'localhost';
GRANT SELECT ON mysql.* TO 'mycli'@'localhost';
GRANT SELECT ON performance_schema.* TO 'mycli'@'localhost';Some CLI tests expect the program ex to be a symbolic link to vim.
In some systems (e.g. Arch Linux) 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)- add the contribution to the
changelog.md - add your name to the
AUTHORSfile (or it's already there). - run
uv run ruff check && uv run ruff format && uv run mypy --install-types .
Create a new release in Github. This will trigger a Github action which will run all the tests, build the wheel and upload it to PyPI.