Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 0a5e84e

Browse files
authored
feat: github app token management (#1)
* feat/IDP-43: github token generator
1 parent 8a27fc0 commit 0a5e84e

File tree

24 files changed

+3037
-2
lines changed

24 files changed

+3037
-2
lines changed

.github/workflows/precommit.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: precommit
3+
4+
on:
5+
pull_request:
6+
push:
7+
branches: [main]
8+
9+
permissions:
10+
actions: read
11+
checks: write
12+
contents: read
13+
pull-requests: write
14+
15+
jobs:
16+
pre-commit:
17+
runs-on: ubuntu-24.04
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.11'
23+
- uses: pre-commit/[email protected]

.github/workflows/tests.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: Tests
3+
4+
on:
5+
push:
6+
branches: [main, develop]
7+
pull_request:
8+
9+
10+
jobs:
11+
test:
12+
name: Run Tests
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.x'
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -e ".[test]"
28+
29+
- name: Run tests
30+
run: |
31+
pytest cpk_lib_python_github/github_app_token_generator_package/tests/ -v
32+
33+
- name: Run tests with coverage
34+
run: |
35+
pytest cpk_lib_python_github/github_app_token_generator_package/tests/ \
36+
--cov=cpk_lib_python_github.github_app_token_generator_package.github_app_token_generator \
37+
--cov-report=term-missing
38+
39+
test-installation:
40+
name: Test Package Installation
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: '3.x'
51+
52+
- name: Install package
53+
run: |
54+
python -m pip install --upgrade pip
55+
pip install -e .
56+
57+
- name: Test CLI command
58+
run: |
59+
github-app-token-generator --help

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Development files
2+
# IDEs
3+
# Logs
4+
# OS
5+
# Python
6+
# Virtual environments
7+
*$py.class
8+
*.egg
9+
*.egg-info/
10+
*.log
11+
*.py[cod]
12+
*.so
13+
*.swo
14+
*.swp
15+
.DS_Store
16+
.Python
17+
.coverage
18+
.eggs/
19+
.idea/
20+
.installed.cfg
21+
.python-version
22+
.vscode/
23+
ENV/
24+
MANIFEST
25+
Thumbs.db
26+
__pycache__/
27+
build/
28+
deleted
29+
develop-eggs/
30+
dist/
31+
downloads/
32+
eggs/
33+
env/
34+
lib/
35+
lib64/
36+
parts/
37+
pip-wheel-metadata/
38+
sdist/
39+
share/python-wheels/
40+
var/
41+
venv/
42+
wheels/

.gitleaks.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
title = "Gitleaks Configuration"
2+
3+
[allowlist]
4+
description = "Allowlist for test files"
5+
paths = [
6+
'''cpk_lib_python_github/.*tests/.*''',
7+
'''.*conftest\.py''',
8+
'''.*test_.*\.py''',
9+
]

.pre-commit-config.yaml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
repos:
3+
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
6+
hooks:
7+
- id: check-merge-conflict
8+
- id: check-added-large-files
9+
args: [--maxkb=500]
10+
- id: trailing-whitespace
11+
- id: detect-private-key
12+
- id: end-of-file-fixer
13+
- id: fix-encoding-pragma
14+
- id: file-contents-sorter
15+
files: ^(requirements.*\.txt|\.gitignore)$
16+
- id: check-case-conflict
17+
- id: mixed-line-ending
18+
args: [--fix=lf]
19+
# -----------------------------
20+
# Checkov is a static code analysis tool for scanning infrastructure as code (IaC) files for misconfigurations
21+
# that may lead to security or compliance problems.
22+
# -----------------------------
23+
# Checkov includes more than 750 predefined policies to check for common misconfiguration issues.
24+
# Checkov also supports the creation and contribution of custom policies.
25+
# -----------------------------
26+
# - repo: https://github.com/bridgecrewio/checkov.git
27+
# rev: 3.2.174
28+
# hooks:
29+
# - id: checkov
30+
31+
# -----------------------------
32+
# Python Code Formatting with Black
33+
# -----------------------------
34+
- repo: https://github.com/psf/black
35+
rev: 25.1.0
36+
hooks:
37+
- id: black
38+
language_version: python3
39+
files: \.py$
40+
args: [--config=pyproject.toml]
41+
42+
# -----------------------------
43+
# Python Import Sorting with isort (complements Black)
44+
# -----------------------------
45+
- repo: https://github.com/pycqa/isort
46+
rev: 6.0.1
47+
hooks:
48+
- id: isort
49+
files: \.py$
50+
args: [--profile=black, --line-length=88]
51+
52+
# -----------------------------
53+
# Python Code Quality with Pylint
54+
# -----------------------------
55+
- repo: https://github.com/pycqa/pylint
56+
rev: v3.3.7
57+
hooks:
58+
- id: pylint
59+
args: [--rcfile=pyproject.toml]
60+
files: \.py$
61+
additional_dependencies: [PyJWT, requests, toml, colorama, setuptools]
62+
63+
# -----------------------------
64+
# Gitleaks SAST tool for detecting and preventing hardcoded secrets like passwords, api keys, and tokens in git repos
65+
# -----------------------------
66+
# If you are knowingly committing something that is not a secret and gitleaks is catching it,
67+
# you can add an inline comment of '# gitleaks:allow' to the end of that line in your file.
68+
# This will instructs gitleaks to ignore that secret - example:
69+
# some_non_secret_value = a1b2c3d4e5f6g7h8i9j0 # gitleaks:allow
70+
# -----------------------------
71+
- repo: https://github.com/gitleaks/gitleaks
72+
rev: v8.27.2
73+
hooks:
74+
- id: gitleaks
75+
args: ['--config=.gitleaks.toml']
76+
# -----------------------------
77+
# # Generates Table of Contents in Markdown files
78+
# # -----------------------------
79+
- repo: https://github.com/frnmst/md-toc
80+
rev: 9.0.0
81+
hooks:
82+
- id: md-toc
83+
args: [-p, github] # CLI options
84+
# -----------------------------
85+
# YAML Linting on yaml files for pre-commit and github actions
86+
# -----------------------------
87+
- repo: https://github.com/adrienverge/yamllint
88+
rev: v1.37.1
89+
hooks:
90+
- id: yamllint
91+
name: Check YAML syntax with yamllint
92+
args: [--strict, -c=.yamllint.yaml, '.']
93+
always_run: true
94+
pass_filenames: true
95+
96+
# -----------------------------
97+
# GitHub Actions Workflow Linting on .github/workflows/*.yml files
98+
# -----------------------------
99+
- repo: https://github.com/rhysd/actionlint
100+
rev: v1.7.7
101+
hooks:
102+
- id: actionlint
103+
104+
- repo: local
105+
hooks:
106+
- id: toml build
107+
name: test the .toml package health
108+
entry: pip3 install .
109+
language: python
110+
pass_filenames: false
111+
always_run: true

.yamllint.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
yaml-files:
3+
- '*.yaml'
4+
- '*.yml'
5+
- '.yamllint'
6+
7+
rules:
8+
anchors: enable
9+
braces: enable
10+
brackets: enable
11+
colons: enable
12+
commas: enable
13+
comments:
14+
level: warning
15+
comments-indentation:
16+
level: warning
17+
document-end: disable
18+
document-start:
19+
level: warning
20+
empty-lines: enable
21+
empty-values: disable
22+
float-values: disable
23+
hyphens: enable
24+
indentation: enable
25+
key-duplicates: enable
26+
key-ordering: disable
27+
# line-length:
28+
# max: 150
29+
# level: warning
30+
new-line-at-end-of-file: enable
31+
new-lines: enable
32+
octal-values: disable
33+
quoted-strings: disable
34+
trailing-spaces: enable
35+
truthy: disable

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
1-
# cpk-lib-python-github
2-
cpk-lib-python-github
1+
# 🐙 CPK GitHub Python Libraries
2+
3+
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.
4+
5+
## 📋 Overview
6+
7+
**CPK GitHub Python Libraries** is a modular collection of GitHub-related utilities designed for:
8+
- 🔐 **Authentication & Authorization** - GitHub App token management
9+
- 🚀 **CI/CD Integration** - Seamless pipeline automation
10+
- 📊 **Repository Management** - Bulk operations and analysis
11+
- 🔧 **Development Tools** - CLI utilities for daily GitHub tasks
12+
13+
14+
📚 **[Full Documentation](cpk_lib_python_github/README.md)**
15+
16+
17+
## 📄 License
18+
19+
This project is licensed under the **GPLv3 License** - see the [LICENSE](LICENSE) file for details.
20+
21+
## 📞 Support & Community
22+
23+
- 🐛 **Issues**: [GitHub Issues](https://github.com/opencpk/cpk-lib-python-github/issues)
24+
25+
26+
**Made with ❤️ by the CPK Cloud Engineering Platform Kit team**
27+
28+
*Empowering development teams with powerful GitHub automation tools.*

0 commit comments

Comments
 (0)