pare-ci 0.1.3__tar.gz
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.
- pare_ci-0.1.3/LICENSE +24 -0
- pare_ci-0.1.3/PKG-INFO +212 -0
- pare_ci-0.1.3/README.md +181 -0
- pare_ci-0.1.3/pare/__init__.py +5 -0
- pare_ci-0.1.3/pare/__main__.py +3 -0
- pare_ci-0.1.3/pare/cli.py +187 -0
- pare_ci-0.1.3/pare/github.py +244 -0
- pare_ci-0.1.3/pare/history.py +463 -0
- pare_ci-0.1.3/pare/pricing.py +131 -0
- pare_ci-0.1.3/pare/pro/LICENSE +20 -0
- pare_ci-0.1.3/pare/pro/__init__.py +258 -0
- pare_ci-0.1.3/pare/pro/ed25519.py +128 -0
- pare_ci-0.1.3/pare/pro/fix.py +300 -0
- pare_ci-0.1.3/pare/pro/guard.py +99 -0
- pare_ci-0.1.3/pare/pro/license.py +278 -0
- pare_ci-0.1.3/pare/pro/org.py +114 -0
- pare_ci-0.1.3/pare/report/__init__.py +5 -0
- pare_ci-0.1.3/pare/report/html.py +160 -0
- pare_ci-0.1.3/pare/report/markdown.py +51 -0
- pare_ci-0.1.3/pare/report/terminal.py +128 -0
- pare_ci-0.1.3/pare/rules.py +448 -0
- pare_ci-0.1.3/pare/scan.py +355 -0
- pare_ci-0.1.3/pare/workflow.py +344 -0
- pare_ci-0.1.3/pare_ci.egg-info/PKG-INFO +212 -0
- pare_ci-0.1.3/pare_ci.egg-info/SOURCES.txt +33 -0
- pare_ci-0.1.3/pare_ci.egg-info/dependency_links.txt +1 -0
- pare_ci-0.1.3/pare_ci.egg-info/entry_points.txt +2 -0
- pare_ci-0.1.3/pare_ci.egg-info/requires.txt +1 -0
- pare_ci-0.1.3/pare_ci.egg-info/top_level.txt +1 -0
- pare_ci-0.1.3/pyproject.toml +49 -0
- pare_ci-0.1.3/setup.cfg +4 -0
- pare_ci-0.1.3/tests/test_core.py +274 -0
- pare_ci-0.1.3/tests/test_pro.py +494 -0
- pare_ci-0.1.3/tests/test_repo.py +47 -0
- pare_ci-0.1.3/tests/test_scan.py +327 -0
pare_ci-0.1.3/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pare
|
|
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
|
+
|
|
23
|
+
This licence covers everything in this repository except the `pare/pro/`
|
|
24
|
+
directory, which is covered by the licence in `pare/pro/LICENSE`.
|
pare_ci-0.1.3/PKG-INFO
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pare-ci
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Find and fix wasted GitHub Actions spend, priced from your real run history.
|
|
5
|
+
Author: Pare
|
|
6
|
+
License-Expression: MIT AND LicenseRef-Pare-Commercial
|
|
7
|
+
Project-URL: Homepage, https://ilachlan627-lgtm.github.io/pare/
|
|
8
|
+
Project-URL: Source, https://github.com/ilachlan627-lgtm/pare
|
|
9
|
+
Project-URL: Issues, https://github.com/ilachlan627-lgtm/pare/issues
|
|
10
|
+
Project-URL: Sample report, https://ilachlan627-lgtm.github.io/pare/sample-report.html
|
|
11
|
+
Keywords: github-actions,ci,cost,finops,devops,github
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
License-File: pare/pro/LICENSE
|
|
29
|
+
Requires-Dist: PyYAML>=6.0
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# Pare
|
|
33
|
+
|
|
34
|
+
**Find the GitHub Actions minutes you paid for and nobody used. Then fix them.**
|
|
35
|
+
|
|
36
|
+
Pare reads your real workflow run history, prices every job at GitHub's rates, and shows the waste as an itemised bill: which workflow, which runs, how many dollars a month. Each line links to the runs that prove it. Most of it can be fixed with a patch Pare writes for you.
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
$ pare scan psf/black --sample 600
|
|
40
|
+
|
|
41
|
+
Pare · psf/black · last 30 days
|
|
42
|
+
|
|
43
|
+
CI spend $806.48 / month 48,989 billed min · list price
|
|
44
|
+
Measured waste $21.86 / month 3% of spend
|
|
45
|
+
Further estimate $648.66 / month needs a stated assumption
|
|
46
|
+
2,839 runs read, 600 sampled down to job level (2956 jobs)
|
|
47
|
+
|
|
48
|
+
Findings (54)
|
|
49
|
+
1. MEASURED Old runs keep billing after a newer commit is pushed $11.75/mo [fix with review]
|
|
50
|
+
.github/workflows/pypi_upload.yml:3 superseded-runs
|
|
51
|
+
26 runs in the last 30 days kept running after a newer commit had already started the same
|
|
52
|
+
workflow on the same branch. Nothing cancels them, so they billed 523 minutes for results nobody
|
|
53
|
+
used.
|
|
54
|
+
e.g. https://github.com/psf/black/actions/runs/44622071756
|
|
55
|
+
|
|
56
|
+
2. MEASURED Every pull request commit is built twice $9.72/mo [fix with review]
|
|
57
|
+
.github/workflows/test.yml:4 duplicate-runs
|
|
58
|
+
...
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
That is real output from a real public repository, scanned on 5 December 2026. Black tests every pull request on Linux, macOS and Windows, so its CI would cost about $800 a month at private-repository list prices. Pare can prove $21.86 of that was thrown away: wheel builds that kept running after a newer commit replaced them, and commits tested twice, once for `push` and once for `pull_request`. The bigger number is an estimate: macOS and Windows legs on pull requests cost up to $384 a month, and how much of that you save depends on how many PR commits you stop testing there. [See the full report](https://ilachlan627-lgtm.github.io/pare/sample-report.html), or the [overview page](https://ilachlan627-lgtm.github.io/pare/).
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pipx install git+https://github.com/ilachlan627-lgtm/pare
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The command it installs is `pare`. Python 3.9 or newer. One dependency (PyYAML). Nothing leaves your machine except calls to the GitHub API. Plain `pip install git+https://github.com/ilachlan627-lgtm/pare` works too. Pare is not on PyPI yet: a package there called `pare` or `pare-ci` is not this project until this README says so.
|
|
70
|
+
|
|
71
|
+
## Use
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pare scan owner/repo # price a repository from its run history
|
|
75
|
+
pare scan . # same, for the checkout you are in
|
|
76
|
+
pare scan . --html report.html --json report.json
|
|
77
|
+
pare lint . # check workflow files only: no network, no token
|
|
78
|
+
pare fix . # preview the patch
|
|
79
|
+
pare fix . --write # apply it (Pro; free on public repos)
|
|
80
|
+
pare guard --base origin/main # fail a PR that adds new waste (Pro; free on public repos)
|
|
81
|
+
pare org my-company # every active repo, ranked by waste (Pro, Business plan)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Set `GITHUB_TOKEN` (or log in with `gh`) for a full-depth scan. Without a token GitHub allows 60 API requests an hour, enough to price one small repository. The token needs read access to Actions and contents; Pare never writes to GitHub.
|
|
85
|
+
|
|
86
|
+
## What it finds
|
|
87
|
+
|
|
88
|
+
| Rule | What it catches | Dollars from | Fix |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| `superseded-runs` | Old runs keep billing after a newer commit replaces them | run history | auto |
|
|
91
|
+
| `duplicate-runs` | The same commit built for both `push` and `pull_request` | run history | review |
|
|
92
|
+
| `missing-timeout` | Jobs with no `timeout-minutes` that hang toward the 6-hour limit | sampled jobs | auto |
|
|
93
|
+
| `uncached-dependencies` | `setup-node` / `setup-python` / `setup-java` without a cache | step timings | auto when the lockfile is confirmed |
|
|
94
|
+
| `expensive-os-on-prs` | macOS (10x) and Windows (1.7x) legs on every PR commit | sampled jobs | manual |
|
|
95
|
+
| `rerun-tax` | Minutes spent re-running flaky workflows | run history | manual |
|
|
96
|
+
| `stale-scheduled-runs` | Scheduled CI re-testing an unchanged commit | run history | manual |
|
|
97
|
+
| `artifact-retention` | Artifacts kept for the 90-day default | — | review |
|
|
98
|
+
| `artifact-storage` | Artifact storage currently held | artifacts API | manual |
|
|
99
|
+
|
|
100
|
+
Findings come in three kinds, and the report never blurs them:
|
|
101
|
+
|
|
102
|
+
- **Measured**: read straight from run history. A run that kept going for eight minutes after its replacement started wasted eight minutes. This is the headline number.
|
|
103
|
+
- **Estimate**: history plus one assumption, stated in the finding (for example "a warm cache removes half of install time").
|
|
104
|
+
- **Hygiene**: a wasteful pattern that cost nothing in this window. No dollars are invented for it.
|
|
105
|
+
|
|
106
|
+
## How the numbers are made
|
|
107
|
+
|
|
108
|
+
1. Every run in the window is read from the runs API (100 per request).
|
|
109
|
+
2. A sample of runs per workflow is priced job by job: each job's duration is rounded up to a whole minute and multiplied by its runner's rate, the way GitHub bills. The sample follows wall-clock time, so the expensive workflows get the most samples, and suspiciously long failed runs are always included.
|
|
110
|
+
3. Unsampled runs are priced from their own wall-clock time at their workflow's sampled rate.
|
|
111
|
+
4. Totals are scaled to 30 days. Measured waste can never exceed spend.
|
|
112
|
+
|
|
113
|
+
Rates are GitHub's published list prices as of 2026-12-05 (`pare/pricing.py`). Standard runners are free in public repositories, so for a public repo Pare shows what the same usage would cost in a private one and says so. Self-hosted and third-party runners are counted in minutes and priced at $0 unless you pass `--rate self-hosted=0.004`.
|
|
114
|
+
|
|
115
|
+
What it does not know: your negotiated discount and your plan's included minutes. Artifact storage is extrapolated from the 100 most recent artifacts. Treat the output as list-price exposure, not an invoice.
|
|
116
|
+
|
|
117
|
+
## Auto-fix
|
|
118
|
+
|
|
119
|
+
`pare fix` writes the smallest possible patch and leaves everything else exactly as you wrote it: comments, quoting, indentation, line endings.
|
|
120
|
+
|
|
121
|
+
```diff
|
|
122
|
+
+concurrency:
|
|
123
|
+
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
124
|
+
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
125
|
+
+
|
|
126
|
+
jobs:
|
|
127
|
+
tests:
|
|
128
|
+
name: "Python ${{ matrix.python-version }}"
|
|
129
|
+
runs-on: "ubuntu-latest"
|
|
130
|
+
+ timeout-minutes: 10
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Every patch is verified before it is shown: the result must parse, and its parsed content may differ from the original only at the keys the fix declared. A patch that fails that check is dropped. Timeouts are learned from history and set to a limit no past successful job would have hit (twice the slowest success, three times the 95th percentile, never under 10 minutes).
|
|
134
|
+
|
|
135
|
+
Fixes that change behaviour you should think about (limiting `push` to the default branch, shortening artifact retention, timeouts with no history behind them) are held back unless you pass `--include-review`. Pare never suggests a dependency cache for release jobs, where a poisoned cache would ship in the artifact.
|
|
136
|
+
|
|
137
|
+
## GitHub Action
|
|
138
|
+
|
|
139
|
+
Weekly bill in the job summary, with a budget:
|
|
140
|
+
|
|
141
|
+
```yaml
|
|
142
|
+
name: CI cost
|
|
143
|
+
on:
|
|
144
|
+
schedule: [{ cron: "0 7 * * 1" }]
|
|
145
|
+
workflow_dispatch:
|
|
146
|
+
permissions:
|
|
147
|
+
actions: read
|
|
148
|
+
contents: read
|
|
149
|
+
jobs:
|
|
150
|
+
pare:
|
|
151
|
+
runs-on: ubuntu-latest
|
|
152
|
+
timeout-minutes: 10
|
|
153
|
+
steps:
|
|
154
|
+
- uses: actions/checkout@v7
|
|
155
|
+
- uses: ilachlan627-lgtm/pare@v1
|
|
156
|
+
with:
|
|
157
|
+
fail-over: "200" # fail when measured waste passes $200 a month
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Stop new waste at review time:
|
|
161
|
+
|
|
162
|
+
```yaml
|
|
163
|
+
name: CI cost guard
|
|
164
|
+
on:
|
|
165
|
+
pull_request:
|
|
166
|
+
paths: [".github/workflows/**"]
|
|
167
|
+
permissions:
|
|
168
|
+
contents: read
|
|
169
|
+
concurrency:
|
|
170
|
+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
|
171
|
+
cancel-in-progress: true
|
|
172
|
+
jobs:
|
|
173
|
+
guard:
|
|
174
|
+
runs-on: ubuntu-latest
|
|
175
|
+
timeout-minutes: 5
|
|
176
|
+
steps:
|
|
177
|
+
- uses: actions/checkout@v7
|
|
178
|
+
- uses: ilachlan627-lgtm/pare@v1
|
|
179
|
+
with:
|
|
180
|
+
command: guard
|
|
181
|
+
license: ${{ secrets.PARE_LICENSE }} # not needed on public repos
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The Action runs on Linux and macOS runners. Outputs: `monthly-spend`, `measured-waste`, `findings`.
|
|
185
|
+
|
|
186
|
+
## Pricing
|
|
187
|
+
|
|
188
|
+
| | Free | Team | Business |
|
|
189
|
+
|---|---|---|---|
|
|
190
|
+
| | $0 | $99 / month | $499 / month |
|
|
191
|
+
| `scan`, `lint`, HTML / JSON / Markdown reports | ✓ | ✓ | ✓ |
|
|
192
|
+
| Fix preview | ✓ | ✓ | ✓ |
|
|
193
|
+
| `fix --write` and PR guard on public repositories | ✓ | ✓ | ✓ |
|
|
194
|
+
| `fix --write` on private repositories | | ✓ | ✓ |
|
|
195
|
+
| PR guard on private repositories | | ✓ | ✓ |
|
|
196
|
+
| Private repositories | | 25 | unlimited |
|
|
197
|
+
| Org-wide scan and ranking | | | ✓ |
|
|
198
|
+
|
|
199
|
+
Your licence key appears on [the website](https://ilachlan627-lgtm.github.io/pare/#pricing) as soon as checkout finishes. Save it as the `PARE_LICENSE` secret for the Action, or run `pare license <KEY>` on your own machine. The key is checked locally and renews itself while you're subscribed: when it is a few days from expiring, Pare sends it (and nothing else) to the licence server, which checks your subscription with Paddle and returns a fresh one. In CI, where nothing is kept between runs, that means one small request per run once the saved key is a month old. You never need to replace the secret.
|
|
200
|
+
|
|
201
|
+
If the licence server is down, Pare keeps using the key it has. If that key has expired, paid steps in GitHub Actions are skipped with a warning instead of failing your build. There is no telemetry.
|
|
202
|
+
|
|
203
|
+
## Development
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
python -m venv .venv && .venv/bin/pip install -e .
|
|
207
|
+
.venv/bin/python -m unittest discover -s tests -t .
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
The licence server is a Cloudflare Worker in [`worker/`](https://github.com/ilachlan627-lgtm/pare/tree/main/worker). `npm test` there runs its tests, and `npm run dev` runs the whole purchase flow on your machine: the website with a fake checkout, and the licence server talking to a fake Paddle.
|
|
211
|
+
|
|
212
|
+
The core (`pare/`) is MIT. `pare/pro/` (auto-fix, guard, org scans, licensing) is under the [Pare Commercial License](https://github.com/ilachlan627-lgtm/pare/blob/main/pare/pro/LICENSE): free on public repositories, paid on private ones.
|
pare_ci-0.1.3/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Pare
|
|
2
|
+
|
|
3
|
+
**Find the GitHub Actions minutes you paid for and nobody used. Then fix them.**
|
|
4
|
+
|
|
5
|
+
Pare reads your real workflow run history, prices every job at GitHub's rates, and shows the waste as an itemised bill: which workflow, which runs, how many dollars a month. Each line links to the runs that prove it. Most of it can be fixed with a patch Pare writes for you.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
$ pare scan psf/black --sample 600
|
|
9
|
+
|
|
10
|
+
Pare · psf/black · last 30 days
|
|
11
|
+
|
|
12
|
+
CI spend $806.48 / month 48,989 billed min · list price
|
|
13
|
+
Measured waste $21.86 / month 3% of spend
|
|
14
|
+
Further estimate $648.66 / month needs a stated assumption
|
|
15
|
+
2,839 runs read, 600 sampled down to job level (2956 jobs)
|
|
16
|
+
|
|
17
|
+
Findings (54)
|
|
18
|
+
1. MEASURED Old runs keep billing after a newer commit is pushed $11.75/mo [fix with review]
|
|
19
|
+
.github/workflows/pypi_upload.yml:3 superseded-runs
|
|
20
|
+
26 runs in the last 30 days kept running after a newer commit had already started the same
|
|
21
|
+
workflow on the same branch. Nothing cancels them, so they billed 523 minutes for results nobody
|
|
22
|
+
used.
|
|
23
|
+
e.g. https://github.com/psf/black/actions/runs/44622071756
|
|
24
|
+
|
|
25
|
+
2. MEASURED Every pull request commit is built twice $9.72/mo [fix with review]
|
|
26
|
+
.github/workflows/test.yml:4 duplicate-runs
|
|
27
|
+
...
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
That is real output from a real public repository, scanned on 5 December 2026. Black tests every pull request on Linux, macOS and Windows, so its CI would cost about $800 a month at private-repository list prices. Pare can prove $21.86 of that was thrown away: wheel builds that kept running after a newer commit replaced them, and commits tested twice, once for `push` and once for `pull_request`. The bigger number is an estimate: macOS and Windows legs on pull requests cost up to $384 a month, and how much of that you save depends on how many PR commits you stop testing there. [See the full report](https://ilachlan627-lgtm.github.io/pare/sample-report.html), or the [overview page](https://ilachlan627-lgtm.github.io/pare/).
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pipx install git+https://github.com/ilachlan627-lgtm/pare
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The command it installs is `pare`. Python 3.9 or newer. One dependency (PyYAML). Nothing leaves your machine except calls to the GitHub API. Plain `pip install git+https://github.com/ilachlan627-lgtm/pare` works too. Pare is not on PyPI yet: a package there called `pare` or `pare-ci` is not this project until this README says so.
|
|
39
|
+
|
|
40
|
+
## Use
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pare scan owner/repo # price a repository from its run history
|
|
44
|
+
pare scan . # same, for the checkout you are in
|
|
45
|
+
pare scan . --html report.html --json report.json
|
|
46
|
+
pare lint . # check workflow files only: no network, no token
|
|
47
|
+
pare fix . # preview the patch
|
|
48
|
+
pare fix . --write # apply it (Pro; free on public repos)
|
|
49
|
+
pare guard --base origin/main # fail a PR that adds new waste (Pro; free on public repos)
|
|
50
|
+
pare org my-company # every active repo, ranked by waste (Pro, Business plan)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Set `GITHUB_TOKEN` (or log in with `gh`) for a full-depth scan. Without a token GitHub allows 60 API requests an hour, enough to price one small repository. The token needs read access to Actions and contents; Pare never writes to GitHub.
|
|
54
|
+
|
|
55
|
+
## What it finds
|
|
56
|
+
|
|
57
|
+
| Rule | What it catches | Dollars from | Fix |
|
|
58
|
+
|---|---|---|---|
|
|
59
|
+
| `superseded-runs` | Old runs keep billing after a newer commit replaces them | run history | auto |
|
|
60
|
+
| `duplicate-runs` | The same commit built for both `push` and `pull_request` | run history | review |
|
|
61
|
+
| `missing-timeout` | Jobs with no `timeout-minutes` that hang toward the 6-hour limit | sampled jobs | auto |
|
|
62
|
+
| `uncached-dependencies` | `setup-node` / `setup-python` / `setup-java` without a cache | step timings | auto when the lockfile is confirmed |
|
|
63
|
+
| `expensive-os-on-prs` | macOS (10x) and Windows (1.7x) legs on every PR commit | sampled jobs | manual |
|
|
64
|
+
| `rerun-tax` | Minutes spent re-running flaky workflows | run history | manual |
|
|
65
|
+
| `stale-scheduled-runs` | Scheduled CI re-testing an unchanged commit | run history | manual |
|
|
66
|
+
| `artifact-retention` | Artifacts kept for the 90-day default | — | review |
|
|
67
|
+
| `artifact-storage` | Artifact storage currently held | artifacts API | manual |
|
|
68
|
+
|
|
69
|
+
Findings come in three kinds, and the report never blurs them:
|
|
70
|
+
|
|
71
|
+
- **Measured**: read straight from run history. A run that kept going for eight minutes after its replacement started wasted eight minutes. This is the headline number.
|
|
72
|
+
- **Estimate**: history plus one assumption, stated in the finding (for example "a warm cache removes half of install time").
|
|
73
|
+
- **Hygiene**: a wasteful pattern that cost nothing in this window. No dollars are invented for it.
|
|
74
|
+
|
|
75
|
+
## How the numbers are made
|
|
76
|
+
|
|
77
|
+
1. Every run in the window is read from the runs API (100 per request).
|
|
78
|
+
2. A sample of runs per workflow is priced job by job: each job's duration is rounded up to a whole minute and multiplied by its runner's rate, the way GitHub bills. The sample follows wall-clock time, so the expensive workflows get the most samples, and suspiciously long failed runs are always included.
|
|
79
|
+
3. Unsampled runs are priced from their own wall-clock time at their workflow's sampled rate.
|
|
80
|
+
4. Totals are scaled to 30 days. Measured waste can never exceed spend.
|
|
81
|
+
|
|
82
|
+
Rates are GitHub's published list prices as of 2026-12-05 (`pare/pricing.py`). Standard runners are free in public repositories, so for a public repo Pare shows what the same usage would cost in a private one and says so. Self-hosted and third-party runners are counted in minutes and priced at $0 unless you pass `--rate self-hosted=0.004`.
|
|
83
|
+
|
|
84
|
+
What it does not know: your negotiated discount and your plan's included minutes. Artifact storage is extrapolated from the 100 most recent artifacts. Treat the output as list-price exposure, not an invoice.
|
|
85
|
+
|
|
86
|
+
## Auto-fix
|
|
87
|
+
|
|
88
|
+
`pare fix` writes the smallest possible patch and leaves everything else exactly as you wrote it: comments, quoting, indentation, line endings.
|
|
89
|
+
|
|
90
|
+
```diff
|
|
91
|
+
+concurrency:
|
|
92
|
+
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
93
|
+
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
94
|
+
+
|
|
95
|
+
jobs:
|
|
96
|
+
tests:
|
|
97
|
+
name: "Python ${{ matrix.python-version }}"
|
|
98
|
+
runs-on: "ubuntu-latest"
|
|
99
|
+
+ timeout-minutes: 10
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Every patch is verified before it is shown: the result must parse, and its parsed content may differ from the original only at the keys the fix declared. A patch that fails that check is dropped. Timeouts are learned from history and set to a limit no past successful job would have hit (twice the slowest success, three times the 95th percentile, never under 10 minutes).
|
|
103
|
+
|
|
104
|
+
Fixes that change behaviour you should think about (limiting `push` to the default branch, shortening artifact retention, timeouts with no history behind them) are held back unless you pass `--include-review`. Pare never suggests a dependency cache for release jobs, where a poisoned cache would ship in the artifact.
|
|
105
|
+
|
|
106
|
+
## GitHub Action
|
|
107
|
+
|
|
108
|
+
Weekly bill in the job summary, with a budget:
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
name: CI cost
|
|
112
|
+
on:
|
|
113
|
+
schedule: [{ cron: "0 7 * * 1" }]
|
|
114
|
+
workflow_dispatch:
|
|
115
|
+
permissions:
|
|
116
|
+
actions: read
|
|
117
|
+
contents: read
|
|
118
|
+
jobs:
|
|
119
|
+
pare:
|
|
120
|
+
runs-on: ubuntu-latest
|
|
121
|
+
timeout-minutes: 10
|
|
122
|
+
steps:
|
|
123
|
+
- uses: actions/checkout@v7
|
|
124
|
+
- uses: ilachlan627-lgtm/pare@v1
|
|
125
|
+
with:
|
|
126
|
+
fail-over: "200" # fail when measured waste passes $200 a month
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Stop new waste at review time:
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
name: CI cost guard
|
|
133
|
+
on:
|
|
134
|
+
pull_request:
|
|
135
|
+
paths: [".github/workflows/**"]
|
|
136
|
+
permissions:
|
|
137
|
+
contents: read
|
|
138
|
+
concurrency:
|
|
139
|
+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
|
140
|
+
cancel-in-progress: true
|
|
141
|
+
jobs:
|
|
142
|
+
guard:
|
|
143
|
+
runs-on: ubuntu-latest
|
|
144
|
+
timeout-minutes: 5
|
|
145
|
+
steps:
|
|
146
|
+
- uses: actions/checkout@v7
|
|
147
|
+
- uses: ilachlan627-lgtm/pare@v1
|
|
148
|
+
with:
|
|
149
|
+
command: guard
|
|
150
|
+
license: ${{ secrets.PARE_LICENSE }} # not needed on public repos
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The Action runs on Linux and macOS runners. Outputs: `monthly-spend`, `measured-waste`, `findings`.
|
|
154
|
+
|
|
155
|
+
## Pricing
|
|
156
|
+
|
|
157
|
+
| | Free | Team | Business |
|
|
158
|
+
|---|---|---|---|
|
|
159
|
+
| | $0 | $99 / month | $499 / month |
|
|
160
|
+
| `scan`, `lint`, HTML / JSON / Markdown reports | ✓ | ✓ | ✓ |
|
|
161
|
+
| Fix preview | ✓ | ✓ | ✓ |
|
|
162
|
+
| `fix --write` and PR guard on public repositories | ✓ | ✓ | ✓ |
|
|
163
|
+
| `fix --write` on private repositories | | ✓ | ✓ |
|
|
164
|
+
| PR guard on private repositories | | ✓ | ✓ |
|
|
165
|
+
| Private repositories | | 25 | unlimited |
|
|
166
|
+
| Org-wide scan and ranking | | | ✓ |
|
|
167
|
+
|
|
168
|
+
Your licence key appears on [the website](https://ilachlan627-lgtm.github.io/pare/#pricing) as soon as checkout finishes. Save it as the `PARE_LICENSE` secret for the Action, or run `pare license <KEY>` on your own machine. The key is checked locally and renews itself while you're subscribed: when it is a few days from expiring, Pare sends it (and nothing else) to the licence server, which checks your subscription with Paddle and returns a fresh one. In CI, where nothing is kept between runs, that means one small request per run once the saved key is a month old. You never need to replace the secret.
|
|
169
|
+
|
|
170
|
+
If the licence server is down, Pare keeps using the key it has. If that key has expired, paid steps in GitHub Actions are skipped with a warning instead of failing your build. There is no telemetry.
|
|
171
|
+
|
|
172
|
+
## Development
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
python -m venv .venv && .venv/bin/pip install -e .
|
|
176
|
+
.venv/bin/python -m unittest discover -s tests -t .
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The licence server is a Cloudflare Worker in [`worker/`](https://github.com/ilachlan627-lgtm/pare/tree/main/worker). `npm test` there runs its tests, and `npm run dev` runs the whole purchase flow on your machine: the website with a fake checkout, and the licence server talking to a fake Paddle.
|
|
180
|
+
|
|
181
|
+
The core (`pare/`) is MIT. `pare/pro/` (auto-fix, guard, org scans, licensing) is under the [Pare Commercial License](https://github.com/ilachlan627-lgtm/pare/blob/main/pare/pro/LICENSE): free on public repositories, paid on private ones.
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""Command line interface."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
import time
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from . import __version__
|
|
13
|
+
from .github import GitHub, GitHubError, default_cache_dir, find_token
|
|
14
|
+
from .pricing import RATES
|
|
15
|
+
from .report import render_html, render_markdown, render_terminal
|
|
16
|
+
from .report.terminal import use_color
|
|
17
|
+
from .rules import RULE_DOCS
|
|
18
|
+
from .scan import Options, Report, lint, repo_from_git, scan
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _looks_like_repo(arg: str) -> bool:
|
|
22
|
+
return arg.count("/") == 1 and not arg.startswith((".", "/", "~")) and not os.path.exists(arg)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _rates(pairs: list[str] | None) -> dict[str, float]:
|
|
26
|
+
rates = dict(RATES)
|
|
27
|
+
for pair in pairs or []:
|
|
28
|
+
if "=" not in pair:
|
|
29
|
+
raise SystemExit(f"--rate expects sku=price, got {pair!r}")
|
|
30
|
+
sku, price = pair.split("=", 1)
|
|
31
|
+
rates[sku.strip()] = float(price)
|
|
32
|
+
return rates
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _client(args) -> GitHub:
|
|
36
|
+
token = args.token or find_token()
|
|
37
|
+
cache = None if args.no_cache else (args.cache_dir or default_cache_dir())
|
|
38
|
+
return GitHub(token=token, cache_dir=cache, offline=args.offline)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _emit(report: Report, args) -> None:
|
|
42
|
+
fmt = args.format
|
|
43
|
+
if fmt == "json":
|
|
44
|
+
text = json.dumps(report.to_dict(), indent=2) + "\n"
|
|
45
|
+
elif fmt == "md":
|
|
46
|
+
text = render_markdown(report)
|
|
47
|
+
elif fmt == "html":
|
|
48
|
+
text = render_html(report)
|
|
49
|
+
else:
|
|
50
|
+
text = render_terminal(report, color=use_color() and not args.output,
|
|
51
|
+
verbose=True if getattr(args, 'verbose', False) else None)
|
|
52
|
+
if args.output:
|
|
53
|
+
Path(args.output).write_text(text, encoding="utf-8")
|
|
54
|
+
print(f"Wrote {args.output}", file=sys.stderr)
|
|
55
|
+
else:
|
|
56
|
+
sys.stdout.write(text)
|
|
57
|
+
for attr, render in (("html", render_html), ("json", lambda r: json.dumps(r.to_dict(), indent=2) + "\n"),
|
|
58
|
+
("md", render_markdown)):
|
|
59
|
+
target = getattr(args, attr, None)
|
|
60
|
+
if target:
|
|
61
|
+
Path(target).write_text(render(report), encoding="utf-8")
|
|
62
|
+
print(f"Wrote {target}", file=sys.stderr)
|
|
63
|
+
if getattr(args, "summary", False):
|
|
64
|
+
summary = os.environ.get("GITHUB_STEP_SUMMARY")
|
|
65
|
+
if summary:
|
|
66
|
+
with open(summary, "a", encoding="utf-8") as fh:
|
|
67
|
+
fh.write(render_markdown(report))
|
|
68
|
+
outputs = os.environ.get("GITHUB_OUTPUT")
|
|
69
|
+
if outputs:
|
|
70
|
+
with open(outputs, "a", encoding="utf-8") as fh:
|
|
71
|
+
fh.write(f"monthly-spend={report.monthly_usd:.2f}\nmeasured-waste={report.measured_usd:.2f}\n"
|
|
72
|
+
f"findings={len(report.findings)}\n")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def cmd_scan(args) -> int:
|
|
76
|
+
target = args.target or "."
|
|
77
|
+
local_root = None
|
|
78
|
+
if _looks_like_repo(target):
|
|
79
|
+
repo = target
|
|
80
|
+
else:
|
|
81
|
+
local_root = target
|
|
82
|
+
repo = args.repo or os.environ.get("GITHUB_REPOSITORY") or repo_from_git(target)
|
|
83
|
+
if not repo:
|
|
84
|
+
print("Could not work out the GitHub repository for this folder. Pass owner/repo, or use "
|
|
85
|
+
"`pare lint` for a check without run history.", file=sys.stderr)
|
|
86
|
+
return 2
|
|
87
|
+
gh = _client(args)
|
|
88
|
+
opts = Options(days=args.days, max_runs=args.max_runs, sample=args.sample,
|
|
89
|
+
disabled=set(args.disable or []), rates=_rates(args.rate), now=args.now)
|
|
90
|
+
quiet = args.format != "text" and not args.output
|
|
91
|
+
progress = (lambda _m: None) if args.quiet or quiet and not sys.stderr.isatty() else (
|
|
92
|
+
lambda m: print(f"· {m}", file=sys.stderr))
|
|
93
|
+
try:
|
|
94
|
+
report = scan(repo, gh, opts, local_root=local_root, progress=progress)
|
|
95
|
+
except GitHubError as exc:
|
|
96
|
+
print(f"pare: {exc}", file=sys.stderr)
|
|
97
|
+
return 2
|
|
98
|
+
_emit(report, args)
|
|
99
|
+
if args.fail_over is not None and report.measured_usd > args.fail_over:
|
|
100
|
+
print(f"pare: measured waste ${report.measured_usd:,.2f}/month is over the ${args.fail_over:,.2f} budget",
|
|
101
|
+
file=sys.stderr)
|
|
102
|
+
return 1
|
|
103
|
+
return 0
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def cmd_lint(args) -> int:
|
|
107
|
+
target = args.target or "."
|
|
108
|
+
if not os.path.exists(target):
|
|
109
|
+
print(f"pare: no such path: {target}", file=sys.stderr)
|
|
110
|
+
return 2
|
|
111
|
+
report = lint(target, default_branch=args.default_branch, disabled=set(args.disable or []))
|
|
112
|
+
_emit(report, args)
|
|
113
|
+
if report.errors:
|
|
114
|
+
return 2
|
|
115
|
+
return 1 if args.strict and report.findings else 0
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def cmd_rules(_args) -> int:
|
|
119
|
+
for rule, doc in RULE_DOCS.items():
|
|
120
|
+
print(f"{rule:<24} {doc}")
|
|
121
|
+
return 0
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _add_output(p: argparse.ArgumentParser) -> None:
|
|
125
|
+
p.add_argument("-f", "--format", choices=["text", "json", "md", "html"], default="text")
|
|
126
|
+
p.add_argument("-o", "--output", help="write the report to a file instead of stdout")
|
|
127
|
+
p.add_argument("--html", help="also write an HTML report to this file")
|
|
128
|
+
p.add_argument("--json", help="also write a JSON report to this file")
|
|
129
|
+
p.add_argument("--md", help="also write a Markdown report to this file")
|
|
130
|
+
p.add_argument("--summary", action="store_true", help="append the report to $GITHUB_STEP_SUMMARY")
|
|
131
|
+
p.add_argument("--disable", action="append", metavar="RULE", help="turn a rule off (repeatable)")
|
|
132
|
+
p.add_argument("-v", "--verbose", action="store_true", help="show full detail for every finding")
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _add_github(p: argparse.ArgumentParser) -> None:
|
|
136
|
+
p.add_argument("--token", help="GitHub token (default: $GITHUB_TOKEN, $GH_TOKEN or `gh auth token`)")
|
|
137
|
+
p.add_argument("--cache-dir", help=f"API response cache (default: {default_cache_dir()})")
|
|
138
|
+
p.add_argument("--no-cache", action="store_true")
|
|
139
|
+
p.add_argument("--offline", action="store_true", help="use only cached API responses")
|
|
140
|
+
p.add_argument("--days", type=int, default=30, help="how far back to read run history (default 30)")
|
|
141
|
+
p.add_argument("--max-runs", type=int, default=1000, help="most runs to read (default 1000)")
|
|
142
|
+
p.add_argument("--sample", type=int, help="runs to cost at job level (default 250 with a token, 40 without)")
|
|
143
|
+
p.add_argument("--rate", action="append", metavar="SKU=USD", help="override a per-minute rate, e.g. self-hosted=0.004")
|
|
144
|
+
p.add_argument("--now", type=float, help=argparse.SUPPRESS)
|
|
145
|
+
p.add_argument("-q", "--quiet", action="store_true")
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
149
|
+
p = argparse.ArgumentParser(prog="pare", description="Find and fix wasted GitHub Actions spend.")
|
|
150
|
+
p.add_argument("--version", action="version", version=f"pare {__version__}")
|
|
151
|
+
sub = p.add_subparsers(dest="command")
|
|
152
|
+
|
|
153
|
+
s = sub.add_parser("scan", help="price a repository's CI from run history and find the waste")
|
|
154
|
+
s.add_argument("target", nargs="?", help="owner/repo, or a local checkout (default: .)")
|
|
155
|
+
s.add_argument("--repo", help="owner/repo when scanning a local checkout without a GitHub remote")
|
|
156
|
+
s.add_argument("--fail-over", type=float, metavar="USD", help="exit 1 when measured waste exceeds this per month")
|
|
157
|
+
_add_github(s)
|
|
158
|
+
_add_output(s)
|
|
159
|
+
s.set_defaults(func=cmd_scan)
|
|
160
|
+
|
|
161
|
+
l = sub.add_parser("lint", help="check workflow files without run history (no network)")
|
|
162
|
+
l.add_argument("target", nargs="?", help="repository root or workflow file (default: .)")
|
|
163
|
+
l.add_argument("--default-branch", default="main")
|
|
164
|
+
l.add_argument("--strict", action="store_true", help="exit 1 when anything is found")
|
|
165
|
+
_add_output(l)
|
|
166
|
+
l.set_defaults(func=cmd_lint)
|
|
167
|
+
|
|
168
|
+
r = sub.add_parser("rules", help="list the rules")
|
|
169
|
+
r.set_defaults(func=cmd_rules)
|
|
170
|
+
|
|
171
|
+
from .pro import register as register_pro
|
|
172
|
+
register_pro(sub, _add_github, _add_output)
|
|
173
|
+
return p
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def main(argv: list[str] | None = None) -> int:
|
|
177
|
+
parser = build_parser()
|
|
178
|
+
args = parser.parse_args(argv)
|
|
179
|
+
if not getattr(args, "func", None):
|
|
180
|
+
parser.print_help()
|
|
181
|
+
return 0
|
|
182
|
+
try:
|
|
183
|
+
return int(args.func(args) or 0)
|
|
184
|
+
except KeyboardInterrupt:
|
|
185
|
+
return 130
|
|
186
|
+
except BrokenPipeError:
|
|
187
|
+
return 0
|