keep-github-workflows-active 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- keep_github_workflows_active/__init__.py +19 -0
- keep_github_workflows_active/__init__conf__.py +67 -0
- keep_github_workflows_active/__main__.py +114 -0
- keep_github_workflows_active/behaviors.py +145 -0
- keep_github_workflows_active/cli.py +584 -0
- keep_github_workflows_active/keep_github_workflow_active.py +516 -0
- keep_github_workflows_active/py.typed +0 -0
- keep_github_workflows_active-2.0.0.dist-info/METADATA +192 -0
- keep_github_workflows_active-2.0.0.dist-info/RECORD +12 -0
- keep_github_workflows_active-2.0.0.dist-info/WHEEL +4 -0
- keep_github_workflows_active-2.0.0.dist-info/entry_points.txt +3 -0
- keep_github_workflows_active-2.0.0.dist-info/licenses/LICENSE +22 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: keep_github_workflows_active
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Template for python apps with registered cli commands
|
|
5
|
+
Project-URL: Homepage, https://github.com/bitranox/keep_github_workflows_active
|
|
6
|
+
Project-URL: Repository, https://github.com/bitranox/keep_github_workflows_active.git
|
|
7
|
+
Project-URL: Issues, https://github.com/bitranox/keep_github_workflows_active/issues
|
|
8
|
+
Author-email: bitranox <bitranox@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ansi,cli,logging,rich,terminal
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.13
|
|
19
|
+
Requires-Dist: lib-cli-exit-tools>=2.1.0
|
|
20
|
+
Requires-Dist: requests>=2.32.3
|
|
21
|
+
Requires-Dist: rich-click>=1.9.3
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: bandit>=1.8.6; extra == 'dev'
|
|
24
|
+
Requires-Dist: build>=1.3.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: codecov-cli>=11.2.3; extra == 'dev'
|
|
26
|
+
Requires-Dist: import-linter>=2.5.2; extra == 'dev'
|
|
27
|
+
Requires-Dist: pip-audit>=2.9.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pyright>=1.1.406; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-cov>=7.0.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=8.4.2; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.14.1; extra == 'dev'
|
|
32
|
+
Requires-Dist: textual>=6.4.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: twine>=6.2.0; extra == 'dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# keep_github_workflows_active
|
|
37
|
+
|
|
38
|
+
<!-- Badges -->
|
|
39
|
+
[](https://github.com/bitranox/keep_github_workflows_active/actions/workflows/ci.yml)
|
|
40
|
+
[](https://github.com/bitranox/keep_github_workflows_active/actions/workflows/codeql.yml)
|
|
41
|
+
[](LICENSE)
|
|
42
|
+
[](https://codespaces.new/bitranox/keep_github_workflows_active?quickstart=1)
|
|
43
|
+
[](https://pypi.org/project/keep_github_workflows_active/)
|
|
44
|
+
[](https://pypi.org/project/keep_github_workflows_active/)
|
|
45
|
+
[](https://docs.astral.sh/ruff/)
|
|
46
|
+
[](https://codecov.io/gh/bitranox/keep_github_workflows_active)
|
|
47
|
+
[](https://qlty.sh/gh/bitranox/projects/keep_github_workflows_active)
|
|
48
|
+
[](https://snyk.io/test/github/bitranox/keep_github_workflows_active)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## Overview
|
|
52
|
+
|
|
53
|
+
`keep_github_workflows_active` is an automation helper that tends to every
|
|
54
|
+
GitHub Actions workflow in a user's repositories. It exists to remove the
|
|
55
|
+
routine maintenance burden that accrues when repositories go quiet and Actions
|
|
56
|
+
start to disable schedules automatically.
|
|
57
|
+
|
|
58
|
+
The automation focuses on two responsibilities:
|
|
59
|
+
|
|
60
|
+
1. **Keep all workflows active** – iterate every repository owned by the
|
|
61
|
+
configured user and flip disabled workflows back to the active state so
|
|
62
|
+
cron-based automation continues to run.
|
|
63
|
+
2. **Delete stale workflow runs** – retain an operator-defined number of the
|
|
64
|
+
freshest runs per workflow and delete older artifacts so storage quotas and
|
|
65
|
+
repository hygiene remain under control.
|
|
66
|
+
|
|
67
|
+
Both behaviors run as part of repository automation (for example on a nightly
|
|
68
|
+
schedule) once the required GitHub token is in place.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## Prerequisites
|
|
72
|
+
|
|
73
|
+
### Generate an access token
|
|
74
|
+
|
|
75
|
+
The automation requires a fine-grained personal access token with repository
|
|
76
|
+
scope. You can create one by visiting the GitHub self-service page:
|
|
77
|
+
|
|
78
|
+
- [Generate fine-grained personal access token](https://github.com/settings/personal-access-tokens)
|
|
79
|
+
|
|
80
|
+
When configuring the token, grant at least the following permissions:
|
|
81
|
+
|
|
82
|
+
- **Actions:** Read/Write (needed to toggle workflow states and delete runs).
|
|
83
|
+
- **Metadata:** Read (lets the script discover repositories you own).
|
|
84
|
+
|
|
85
|
+
Tokens expire automatically. Renew them before the expiry hits to keep the
|
|
86
|
+
automation alive. The previous test token that powered the repository expired on
|
|
87
|
+
**January 19, 2025**, so any current setup must already use a newer credential.
|
|
88
|
+
|
|
89
|
+
### Store the token as a repository secret
|
|
90
|
+
|
|
91
|
+
Add the token to the repository's secrets so GitHub Actions can inject it at
|
|
92
|
+
runtime:
|
|
93
|
+
|
|
94
|
+
- [Repository secrets](https://github.com/bitranox/keep_github_workflows_active/settings/secrets/actions)
|
|
95
|
+
|
|
96
|
+
Define the following secrets:
|
|
97
|
+
|
|
98
|
+
- `SECRET_GITHUB_OWNER` – GitHub username whose repositories should be scanned.
|
|
99
|
+
- `SECRET_GITHUB_TOKEN` – the fine-grained personal access token you generated.
|
|
100
|
+
|
|
101
|
+
Keeping the credentials inside secrets ensures the nightly cleanup workflow can
|
|
102
|
+
authenticate without hard-coding sensitive values in the repository.
|
|
103
|
+
|
|
104
|
+
For local development you can place the same keys inside a `.env` file at the
|
|
105
|
+
repository root. The automation reads from the environment first and falls back
|
|
106
|
+
to `.env` when running outside GitHub Actions.
|
|
107
|
+
|
|
108
|
+
> **Note:** the included tests and CLI commands exercise the live GitHub API.
|
|
109
|
+
> When `SECRET_GITHUB_OWNER` and `SECRET_GITHUB_TOKEN` point at a real account,
|
|
110
|
+
> running `make test` (or the workflow maintenance commands directly) will
|
|
111
|
+
> re-enable workflows and prune old workflow runs across the configured
|
|
112
|
+
> repositories.
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## Installation
|
|
116
|
+
|
|
117
|
+
Install the package locally when you want to run the CLI helpers or contribute
|
|
118
|
+
changes:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pip install keep_github_workflows_active
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Alternative flows (pipx, uv, editable installs, or source builds) are described
|
|
125
|
+
in [INSTALL.md](INSTALL.md). All supported options expose both the
|
|
126
|
+
`keep_github_workflows_active` and `keep-github-workflows-active` entry points on
|
|
127
|
+
your `PATH`.
|
|
128
|
+
|
|
129
|
+
### Python 3.13+ baseline
|
|
130
|
+
|
|
131
|
+
- The package targets **Python 3.13 and newer**. Older interpreters are no
|
|
132
|
+
longer supported; the codebase relies on modern conveniences such as
|
|
133
|
+
`Path.unlink(missing_ok=True)`.
|
|
134
|
+
- Runtime modules now use native Python 3.13 type syntax (e.g., `list[str]`,
|
|
135
|
+
`Sequence[str] | None`) and drop legacy compatibility helpers.
|
|
136
|
+
- Runtime dependencies include `rich-click` for the CLI surface and
|
|
137
|
+
`lib_cli_exit_tools` for consistent exit handling. Development extras pin the
|
|
138
|
+
tooling stack (pytest, ruff, pyright, bandit, build, twine, codecov-cli,
|
|
139
|
+
pip-audit, textual, import-linter) to their latest major releases.
|
|
140
|
+
- Development dependencies were refreshed to the latest stable releases
|
|
141
|
+
(`ruff>=0.14.1`, `textual>=6.4.0`).
|
|
142
|
+
- Continuous integration runs across GitHub's hosted runners (`ubuntu-latest`,
|
|
143
|
+
`macos-latest`, `windows-latest`) on CPython 3.13 in addition to the most
|
|
144
|
+
recent 3.x release Actions makes available.
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
## Usage
|
|
148
|
+
|
|
149
|
+
Once installed and authenticated via repository secrets, schedule the automation
|
|
150
|
+
from a GitHub Actions workflow (see `docs/systemdesign/module_reference.md` for
|
|
151
|
+
the architectural wiring). The CLI remains available for local smoke-tests and
|
|
152
|
+
packaging checks while the richer workflow management helpers iterate:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
keep_github_workflows_active info
|
|
156
|
+
keep_github_workflows_active hello
|
|
157
|
+
keep_github_workflows_active fail
|
|
158
|
+
keep_github_workflows_active --traceback fail
|
|
159
|
+
keep_github_workflows_active enable-all-workflows [--owner <user>] [--token <pat>]
|
|
160
|
+
keep_github_workflows_active delete-old-workflow-runs [--owner <user>] [--token <pat>] [--keep <n>]
|
|
161
|
+
keep-github-workflows-active info
|
|
162
|
+
python -m keep_github_workflows_active info
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The workflow maintenance commands accept optional flags. When ``--owner`` or
|
|
166
|
+
``--token`` is omitted the CLI falls back to the values discovered via
|
|
167
|
+
environment variables or the project's ``.env`` file. ``--keep`` defaults to
|
|
168
|
+
``50`` workflow runs per repository.
|
|
169
|
+
|
|
170
|
+
Programmatic access is also exposed via the public helpers:
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
import keep_github_workflows_active as kgwa
|
|
174
|
+
|
|
175
|
+
kgwa.emit_greeting()
|
|
176
|
+
try:
|
|
177
|
+
kgwa.raise_intentional_failure()
|
|
178
|
+
except RuntimeError as exc:
|
|
179
|
+
print(f"caught expected failure: {exc}")
|
|
180
|
+
|
|
181
|
+
kgwa.print_info()
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
## Further documentation
|
|
186
|
+
|
|
187
|
+
- [Install Guide](INSTALL.md)
|
|
188
|
+
- [Development Handbook](DEVELOPMENT.md)
|
|
189
|
+
- [Contributor Guide](CONTRIBUTING.md)
|
|
190
|
+
- [Changelog](CHANGELOG.md)
|
|
191
|
+
- [Module Reference](docs/systemdesign/module_reference.md)
|
|
192
|
+
- [License](LICENSE)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
keep_github_workflows_active/__init__.py,sha256=tAEJPhRW07E84IzHijcwAf-iu8fhAf3TsvBUQqGz-fY,399
|
|
2
|
+
keep_github_workflows_active/__init__conf__.py,sha256=MBKRESh1V_6C9eYtEqTB52Xx1CAmSAqDFnQBVo7tYYE,2193
|
|
3
|
+
keep_github_workflows_active/__main__.py,sha256=79coRxvGs07uGBSdbw_HpcIv_rqogXvoEkv3lNEEIjE,3552
|
|
4
|
+
keep_github_workflows_active/behaviors.py,sha256=PYDhp_ubXhLud2IVFLIJKylStu36W4Qm7E_daT2dOAM,3741
|
|
5
|
+
keep_github_workflows_active/cli.py,sha256=h-xK6wwbyonIgH0Nhb_eQ_lrws9MGea78AhSbaEW2HI,18355
|
|
6
|
+
keep_github_workflows_active/keep_github_workflow_active.py,sha256=25cEcqfOiedeM443RrqeLc0PcZoSyiAjrcuYkGRmfbk,18809
|
|
7
|
+
keep_github_workflows_active/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
keep_github_workflows_active-2.0.0.dist-info/METADATA,sha256=O1tr_D9rF_NG30WfeIIUzlBZeKfuvZ-2JKAmGlti9VQ,8712
|
|
9
|
+
keep_github_workflows_active-2.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
+
keep_github_workflows_active-2.0.0.dist-info/entry_points.txt,sha256=6B8ytwKR2VIAj6IXUYhF957dlfulwTPPLR39RBXwCM0,156
|
|
11
|
+
keep_github_workflows_active-2.0.0.dist-info/licenses/LICENSE,sha256=6s9SL2InRrwynPjJYiER7ONHBshbGj_yC5EBzfo7l9I,1072
|
|
12
|
+
keep_github_workflows_active-2.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Robert Nowotny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|