jgt_tools package

Package for common jgt commands.

Subpackages

Submodules

jgt_tools.check_version module

Ensure version bump.

jgt_tools.check_version.check_default_branch(default_branch)[source]

Get changed files and pyproject.toml diff for a branch.

jgt_tools.check_version.check_version()[source]

Verify the version is changed if any code files are changed.

jgt_tools.check_version.find_default_branch()[source]

Find the default branch for a git repository.

jgt_tools.check_version.find_remote()[source]

Find the primary remote for a git repository.

jgt_tools.env_setup module

Setup the development environment.

Runs the following commands:

poetry run pip install –upgrade pip poetry install poetry run pre-commit install

jgt_tools.env_setup.env_setup(verbose)[source]

Prepare environment for running.

jgt_tools.env_setup.main()[source]

Execute env_setup using command line args.

jgt_tools.run_tests module

Run all available tests.

Runs the following commands:

poetry run python -m pytest -vvv

jgt_tools.run_tests.main()[source]

Self check with cli args.

jgt_tools.run_tests.run_tests(do_setup=False, self_check=False, verbose=True, additional_args=None)[source]

Run code checks.

jgt_tools.self_check module

Script to make sure the repo is good enough for running tests, meets SDLC, etc.

Basically, antyhing you want to put here that will be part of your automated PR checking and whatever santiy checking you want for the CICD server to be confident that it can start a test run without any missing packages, syntax errors, etc.

We’re leaning in to using ‘pre-commit’ but this script can still be used to run or check things that aren’t a good fit for ‘pre-commit’.

Runs the following commands:

poetry run pre-commit run -a

jgt_tools.self_check.main()[source]

Self check with cli args.

jgt_tools.self_check.self_check(do_setup=False, do_version_check=False, verbose=True)[source]

Run code checks.

jgt_tools.utils module

Shared util functions.

jgt_tools.utils.execute_command_list(commands_to_run, verbose=True)[source]

Execute each command in the list.

If any command fails, print a helpful message and exit with that status.

jgt_tools.utils.get_pyproject_config()[source]

Get the config data from the project’s pyproject.toml file.

jgt_tools.utils.load_configs()[source]

Build configs from defaults and pyproject.toml.

jgt_tools.utils.owner_name_from(origin_url)[source]

Extract the owner name from a git origin URL.

The git origin URL might be in git+ssh form, or https form.

Parameters:

origin_url (str) – Origin URL from git

Returns:

A slash-separated string containing the organization / owner and repository

Return type:

str

Examples

>>> owner_name_from("git@github.com:jolly-good-toolbelt/jgt_tools.git")
"jolly-good-toolbelt/jgt_tools"
>>> owner_name_from("https://github.com/jolly-good-toolbelt/jgt_tools.git")
"jolly-good-toolbelt/jgt_tools"