Skip to main content

A Python-native CI/CD framework for defining, testing, and transpiling pipelines.

Project description

logo_pygha_dark

A Python-native CI/CD framework for defining, testing, and transpiling pipelines to GitHub Actions.

Read the Full Documentation


PyPI Conda Version Python Versions CI Status Documentation Status Coverage Lint (Ruff) Type Check (mypy) Security (Bandit) License


Installation

PyPI

You can install pygha via pip:

pip install pygha

Conda

You can install pygha from the psidhu22 channel:

conda install -c psidhu22 pygha

Example: Define a CI Pipeline with pygha

Below is an example of a Python-defined pipeline that mirrors what most teams use in production — build, lint, test, coverage, and deploy — all orchestrated through pygha.

from pygha import job, default_pipeline
from pygha.steps import shell, checkout, uses

# Configure the default pipeline to run on main push and PRs
default_pipeline(on_push=["main"], on_pull_request=True)

@job(
    name="test",
    matrix={"python": ["3.11", "3.12", "3.13"]},
)
def test_matrix():
    """Run tests across multiple Python versions."""
    checkout()

    # Use the matrix variable in your step arguments
    uses(
        "actions/setup-python@v5",
        with_args={"python-version": "${{ matrix.python }}"}
    )

    shell("pip install .[dev]")
    shell("pytest")

@job(name="deploy", depends_on=["test"])
def deploy():
    """Build and publish if tests pass."""
    checkout()
    uses("actions/setup-python@v5", with_args={"python-version": "3.11"})

    shell("pip install build twine")
    shell("python -m build")
    shell("twine check dist/*")

Advanced: Conditional Logic

pygha allows you to write conditional workflows using Python syntax instead of raw YAML strings.

Job-Level Conditions

Use the @run_if decorator to skip entire jobs based on context.

from pygha.decorators import run_if
from pygha.expr import github

@job(name="nightly-scan")
@run_if(github.event_name == "schedule")
def security_scan():
    """Only runs on scheduled events."""
    ...

Step-Level Conditions

Use the when context manager to group steps that should only run under certain conditions. Nested conditions are automatically AND-ed together.

from pygha.steps import when
from pygha.expr import runner, always, failure

@job
def conditional_steps():
    # Simple check
    with when(runner.os == 'Linux'):
        shell("sudo apt-get update")

    # Status check helper (runs even if previous steps failed)
    with when(always()):
        shell("echo 'Cleanup...'")

    # Nested check: (failure()) AND (runner.os == 'Linux')
    with when(failure()):
        with when(runner.os == 'Linux'):
            shell("echo 'Linux build failed!'")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygha-0.2.0.tar.gz (56.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygha-0.2.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file pygha-0.2.0.tar.gz.

File metadata

  • Download URL: pygha-0.2.0.tar.gz
  • Upload date:
  • Size: 56.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pygha-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bca4807f8bbbabbd9222906655914849c275aab929fd77760961e8c52ec4f202
MD5 bb6fa1612bcfed0ea7bd0a27cfc4a02c
BLAKE2b-256 a3a6e936565d71159b543a59762cd4b35d9c3f2050ff573a32a300769237970b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygha-0.2.0.tar.gz:

Publisher: publish_pypi.yml on parneetsingh022/pygha

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pygha-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pygha-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pygha-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db60956cabc897eee87b228c14101c59949694aa569cb1d2248f003124c732d6
MD5 89361423b295e3bfcc471e0ddc6535b9
BLAKE2b-256 a586f0c9f6359117637117b6fc7d4409ce9beeb8cca77b0ae6c2baa6560ef1fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygha-0.2.0-py3-none-any.whl:

Publisher: publish_pypi.yml on parneetsingh022/pygha

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page