Skip to main content
Binbash

Leverage CLI

Leverage CLI is the tool used to manage and interact with any Leverage project.

It transparently handles the most complex and error prone tasks that arise from working with a state-of-the-art infrastructure definition like our Leverage Reference Architecture. Leverage CLI uses a dockerized approach to encapsulate the tools needed to perform such tasks and to free the user from having to deal with the configuration and management of said tools. Provides the means to interact with your Leverage project and allows you to define custom tasks to run.

Reviewing and implementing the Binbash Leverage Landing Zone for AWS would be a very good place to start!

Documentation

For installation instructions and all documentation regarding Leverage CLI, please refer to this page.

Note for migration from previous versions

If you come from Leverage CLI version <1.8.0 and want to install Leverage CLI version >= 1.8.0 keep into account the following.

The build.env file format has changed. As an example, this is the old format:

# Project settings
PROJECT=bb

# General
MFA_ENABLED=false

# Terraform
TERRAFORM_IMAGE_NAME=binbash/terraform-awscli-slim
TERRAFORM_IMAGE_TAG=1.1.9

New version example:

# Project settings
PROJECT=bb

# General
MFA_ENABLED=false

# Terraform
TF_IMAGE_TAG=1.5.0-0.2.0

So, if you have created a project with version <1.8.0 and want to use it with version >=1.8.0 you should:

  • remove TERRAFORM_IMAGE_NAME line
  • update TF_IMAGE_TAG from this form '9.9.9' to this one '9.9.9-9.9.9'.

For the second item you can check the version here.

System requirements

Supported python versions

Leverage CLI explicitly supports the following Python versions:

  • Python 3.9.x
  • Python 3.10.x
  • Python 3.11.x
  • Python 3.12.x
  • Python 3.13.x

These versions are not only supported but are also the only versions used in our CI/CD pipelines to ensure compatibility and performance. This rigorous testing helps prevent compatibility issues and ensures that the Leverage CLI performs as expected under these versions.

Please ensure that your development and deployment environments are set up with one of these supported versions. Our GitHub Actions and other CI workflows are specifically configured to test against these Python versions, which reinforces our commitment to maintaining a reliable and stable toolset.

Installing multiple python versions with pyenv

If you need to install one of the supported Python versions and would like to manage multiple Python environments, pyenv is a highly recommended tool. Here’s how you can use pyenv to install and manage Python versions:

  1. Installing Pyenv:
curl https://pyenv.run | bash
  1. Add Pyenv to your shell to automate the setup process (if using bash, otherwise you can find details on how to set it up here):
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
exec "$SHELL"
  1. Installing python versions:

Once pyenv is installed, you can install any supported Python version by following these steps:

pyenv install 3.9.7
pyenv install 3.10.1
pyenv install 3.11.8
pyenv install 3.12.7
pyenv install 3.13.6
  1. Create a virtual environment for the leverage project:

Create a virtual environment for your project using Python 3.13.x:

pyenv virtualenv 3.13.6 leverage_py_313_venv
  1. Set your virtual environment to be used in the project:

To set this virtual environment as the local environment for your project, navigate to your project directory and run:

cd <path_to_leverage_project_root>
pyenv local leverage_py_313_venv

This setup commands pyenv to use leverage_py_313_venv as the local Python version for your project directory, ensuring that all Python operations within this directory use this isolated environment.

Setting up development environment

Before you begin, ensure you are running one of the supported Python versions.

We now use Poetry for dependency management. Setup your development environment as follows:

  1. Install Poetry:
curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.2 python -
  1. Clone the repository and navigate into it:
git clone https://github.com/binbashar/leverage.git
cd leverage
  1. Install dependencies using Poetry:
poetry install --with=dev --with=main
  1. To activate the virtual environment and start using the CLI in dev mode, use:
poetry shell

Pre-commit hooks

In order to run black automatically on every commit, you should install pre-commit first:

https://pre-commit.com/#installation

And then the hooks:

poetry run pre-commit install

Running Tests

To run unit tests, pytest is the tool of choice, and the required dependencies are available in the corresponding dev-requirements.txt.

Integration tests are implemented using bats. Bear in mind that bats tests are meant to be run in a throwaway environment since they perform filesystem manipulations and installation and removal of packages, and the cleanup may not be completely thorough. As such, is highly recommended to run these tests using the docker image.

Manually

  1. Unit tests:
poetry run pytest
  1. Integration tests:

Install dependencies (MacOS):

brew install bats-core
brew tap bats-core/bats-core
brew install bats-support
brew install bats-assert
bats -r tests/bats

Using docker image

A Docker image suitable for running all tests can be crafted by running make build-image. After crafting the image all tests can be executed.

To run all tests, run make tests. Alternatively make test-unit or make test-int for unit or integration tests respectively.

Release Process

  • On every PR, a Github Action workflow is triggered to create/update a release draft.
  • The version number is determined by the labels of those PRs (major, minor, fix).
  • The release draft has to be manually published. This allows for any number of PR (features, fixes) to make the cut.
  • Once a release is published, another workflow is triggered to create and push the package to PyPi.

Release Candidate Process

  • There is an Action called "Test Build Package and Push".
  • This Action can be called manually on any branch specifying the version to release to test.
    • The version is a Release Candidate following the Semver: e.g. if the next release is 1.2.3, the test version should be 1.2.3rc.1
  • The package will be published to PyPi.

Contributors/Contributing

License

Leverage CLI is licensed under MIT licenseBinBash Inc

Metadata

Release files for leverage 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for leverage 3.1.0
File Size Uploaded
leverage-3.1.0.tar.gz 51.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for leverage 3.1.0
File Interpreter ABI Platform
leverage-3.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 111.5 kB

Release files / leverage-3.1.0.tar.gz

Download URL leverage-3.1.0.tar.gz
Size 51.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5aa9a6319624e0e4dcf3c8e8653efabac00ba8015dee6f12ce34fcb3c63e7467
BLAKE2b-256 checksum
How to use checksums
4ee7ed4c8506ae78cb6928cebb654923c7025036bbdfd75948051b41b2334ca9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.15

Release files / leverage-3.1.0-py3-none-any.whl

Download URL leverage-3.1.0-py3-none-any.whl
Size 59.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2793e794f672faa6ca0d91d986d0ed4a85d17fb165f2cdf73ecbea67c7973f6
BLAKE2b-256 checksum
How to use checksums
758e4d1048b287388b749c56bcbfbbee28a7f825e6e11047f17012dcd4ac07f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.15

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 release files

3.0.0

2 release files

2.1.1

2 release files

2.0.0

2 release files

1.14.0

2 release files

1.12.4

2 release files

1.12.2

2 release files

1.11.2

2 release files

1.11.1

2 release files

1.11.0

2 release files

1.10.2

2 release files

1.10.0

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.8.0

2 release files

1.7.4

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.10

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.10

2 release files

0.0.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page