A Python-native CI/CD framework for defining, testing, and transpiling pipelines.
Project description
A Python-native CI/CD framework for defining, testing, and transpiling pipelines to GitHub Actions.
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 run, 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
setup_python("${{ matrix.python }}", cache="pip")
run("pip install .[dev]")
run("pytest")
@job(name="deploy", depends_on=["test"])
def deploy():
"""Build and publish if tests pass."""
checkout()
setup_python("3.11", cache="pip")
run("pip install build twine")
run("python -m build")
run("twine check dist/*")
Generating Workflows (CLI)
Once you have defined your pipelines (by default, pygha looks for files matching pipeline_*.py or *_pipeline.py in a .pipe directory), use the CLI to generate the GitHub Actions YAML files.
# Default behavior: Scans .pipe/ and outputs to .github/workflows/
pygha build
Options
-
--src-dir: Source directory containing your Python pipeline definitions (default: .pipe). -
--out-dir: Output directory where the generated YAML files will be saved (default: .github/workflows). -
--clean: Automatically deletes YAML files in the output directory that are no longer registered in your pipelines. This is useful when you rename or remove pipelines.If you have a manually created workflow file in your output directory that you want to preserve (e.g.,
manual-deploy.yml), add# pygha: keepto the first 10 lines of that file. The CLI will skip deleting it.
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'):
run("sudo apt-get update")
# Status check helper (runs even if previous steps failed)
with when(always()):
run("echo 'Cleanup...'")
# Nested check: (failure()) AND (runner.os == 'Linux')
with when(failure()):
with when(runner.os == 'Linux'):
run("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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygha-0.3.0.tar.gz.
File metadata
- Download URL: pygha-0.3.0.tar.gz
- Upload date:
- Size: 63.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
931f9417eb228a0ce12f0b5db90eb46e336fded7ffb77fc9bca1a1e8524e5329
|
|
| MD5 |
63a248dfaf10b4be0ca4fa95d9a98655
|
|
| BLAKE2b-256 |
5683bc957546074fe1e56f0fa7bdee71f7138c852360dd0980051b87bb4af95d
|
Provenance
The following attestation bundles were made for pygha-0.3.0.tar.gz:
Publisher:
publish_pypi.yml on parneetsingh022/pygha
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygha-0.3.0.tar.gz -
Subject digest:
931f9417eb228a0ce12f0b5db90eb46e336fded7ffb77fc9bca1a1e8524e5329 - Sigstore transparency entry: 773660882
- Sigstore integration time:
-
Permalink:
parneetsingh022/pygha@a05b386f8d48869ec12723d306db9e3efaa1d007 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/parneetsingh022
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@a05b386f8d48869ec12723d306db9e3efaa1d007 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pygha-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pygha-0.3.0-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1ad7b8fcbbb6eb36c2d640b1a2cd055f26add89cd62cb89e83fc4b2e260a3cb
|
|
| MD5 |
3e01f43bd490dbe4883b60731716a14c
|
|
| BLAKE2b-256 |
bf796891c33a0240b46b2317b92ce297ff6e9e8f220f703f27e6ecbed2f551aa
|
Provenance
The following attestation bundles were made for pygha-0.3.0-py3-none-any.whl:
Publisher:
publish_pypi.yml on parneetsingh022/pygha
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygha-0.3.0-py3-none-any.whl -
Subject digest:
f1ad7b8fcbbb6eb36c2d640b1a2cd055f26add89cd62cb89e83fc4b2e260a3cb - Sigstore transparency entry: 773660887
- Sigstore integration time:
-
Permalink:
parneetsingh022/pygha@a05b386f8d48869ec12723d306db9e3efaa1d007 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/parneetsingh022
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@a05b386f8d48869ec12723d306db9e3efaa1d007 -
Trigger Event:
push
-
Statement type: