Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/precommit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: precommit

on:
pull_request:
push:
branches: [main]

permissions:
actions: read
checks: write
contents: read
pull-requests: write

jobs:
pre-commit:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: pre-commit/[email protected]
59 changes: 59 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: Tests

on:
push:
branches: [main, develop]
pull_request:


jobs:
test:
name: Run Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[test]"

- name: Run tests
run: |
pytest cpk_lib_python_github/github_app_token_generator_package/tests/ -v

- name: Run tests with coverage
run: |
pytest cpk_lib_python_github/github_app_token_generator_package/tests/ \
--cov=cpk_lib_python_github.github_app_token_generator_package.github_app_token_generator \
--cov-report=term-missing

test-installation:
name: Test Package Installation
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install package
run: |
python -m pip install --upgrade pip
pip install -e .

- name: Test CLI command
run: |
github-app-token-generator --help
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Development files
# IDEs
# Logs
# OS
# Python
# Virtual environments
*$py.class
*.egg
*.egg-info/
*.log
*.py[cod]
*.so
*.swo
*.swp
.DS_Store
.Python
.coverage
.eggs/
.idea/
.installed.cfg
.python-version
.vscode/
ENV/
MANIFEST
Thumbs.db
__pycache__/
build/
deleted
develop-eggs/
dist/
downloads/
eggs/
env/
lib/
lib64/
parts/
pip-wheel-metadata/
sdist/
share/python-wheels/
var/
venv/
wheels/
9 changes: 9 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title = "Gitleaks Configuration"

[allowlist]
description = "Allowlist for test files"
paths = [
'''cpk_lib_python_github/.*tests/.*''',
'''.*conftest\.py''',
'''.*test_.*\.py''',
]
111 changes: 111 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: check-added-large-files
args: [--maxkb=500]
- id: trailing-whitespace
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: file-contents-sorter
files: ^(requirements.*\.txt|\.gitignore)$
- id: check-case-conflict
- id: mixed-line-ending
args: [--fix=lf]
# -----------------------------
# Checkov is a static code analysis tool for scanning infrastructure as code (IaC) files for misconfigurations
# that may lead to security or compliance problems.
# -----------------------------
# Checkov includes more than 750 predefined policies to check for common misconfiguration issues.
# Checkov also supports the creation and contribution of custom policies.
# -----------------------------
# - repo: https://github.com/bridgecrewio/checkov.git
# rev: 3.2.174
# hooks:
# - id: checkov

# -----------------------------
# Python Code Formatting with Black
# -----------------------------
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
language_version: python3
files: \.py$
args: [--config=pyproject.toml]

# -----------------------------
# Python Import Sorting with isort (complements Black)
# -----------------------------
- repo: https://github.com/pycqa/isort
rev: 6.0.1
hooks:
- id: isort
files: \.py$
args: [--profile=black, --line-length=88]

# -----------------------------
# Python Code Quality with Pylint
# -----------------------------
- repo: https://github.com/pycqa/pylint
rev: v3.3.7
hooks:
- id: pylint
args: [--rcfile=pyproject.toml]
files: \.py$
additional_dependencies: [PyJWT, requests, toml, colorama, setuptools]

# -----------------------------
# Gitleaks SAST tool for detecting and preventing hardcoded secrets like passwords, api keys, and tokens in git repos
# -----------------------------
# If you are knowingly committing something that is not a secret and gitleaks is catching it,
# you can add an inline comment of '# gitleaks:allow' to the end of that line in your file.
# This will instructs gitleaks to ignore that secret - example:
# some_non_secret_value = a1b2c3d4e5f6g7h8i9j0 # gitleaks:allow
# -----------------------------
- repo: https://github.com/gitleaks/gitleaks
rev: v8.27.2
hooks:
- id: gitleaks
args: ['--config=.gitleaks.toml']
# -----------------------------
# # Generates Table of Contents in Markdown files
# # -----------------------------
- repo: https://github.com/frnmst/md-toc
rev: 9.0.0
hooks:
- id: md-toc
args: [-p, github] # CLI options
# -----------------------------
# YAML Linting on yaml files for pre-commit and github actions
# -----------------------------
- repo: https://github.com/adrienverge/yamllint
rev: v1.37.1
hooks:
- id: yamllint
name: Check YAML syntax with yamllint
args: [--strict, -c=.yamllint.yaml, '.']
always_run: true
pass_filenames: true

# -----------------------------
# GitHub Actions Workflow Linting on .github/workflows/*.yml files
# -----------------------------
- repo: https://github.com/rhysd/actionlint
rev: v1.7.7
hooks:
- id: actionlint

- repo: local
hooks:
- id: toml build
name: test the .toml package health
entry: pip3 install .
language: python
pass_filenames: false
always_run: true
35 changes: 35 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
yaml-files:
- '*.yaml'
- '*.yml'
- '.yamllint'

rules:
anchors: enable
braces: enable
brackets: enable
colons: enable
commas: enable
comments:
level: warning
comments-indentation:
level: warning
document-end: disable
document-start:
level: warning
empty-lines: enable
empty-values: disable
float-values: disable
hyphens: enable
indentation: enable
key-duplicates: enable
key-ordering: disable
# line-length:
# max: 150
# level: warning
new-line-at-end-of-file: enable
new-lines: enable
octal-values: disable
quoted-strings: disable
trailing-spaces: enable
truthy: disable
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
# cpk-lib-python-github
cpk-lib-python-github
# πŸ™ CPK GitHub Python Libraries

A comprehensive collection of Python libraries for GitHub automation, management, and integration. This package provides a suite of tools designed to simplify GitHub operations for development teams, CI/CD pipelines, and automation scripts.

## πŸ“‹ Overview

**CPK GitHub Python Libraries** is a modular collection of GitHub-related utilities designed for:
- πŸ” **Authentication & Authorization** - GitHub App token management
- πŸš€ **CI/CD Integration** - Seamless pipeline automation
- πŸ“Š **Repository Management** - Bulk operations and analysis
- πŸ”§ **Development Tools** - CLI utilities for daily GitHub tasks


πŸ“š **[Full Documentation](cpk_lib_python_github/README.md)**


## πŸ“„ License

This project is licensed under the **GPLv3 License** - see the [LICENSE](LICENSE) file for details.

## πŸ“ž Support & Community

- πŸ› **Issues**: [GitHub Issues](https://github.com/opencpk/cpk-lib-python-github/issues)


**Made with ❀️ by the CPK Cloud Engineering Platform Kit team**

*Empowering development teams with powerful GitHub automation tools.*
Loading