Skip to content

Commit ec22cd4

Browse files
fix(metrics): fail closed on traffic auth and collector errors
The default Actions GITHUB_TOKEN cannot read /traffic/* (always 403). The workflow now prefers ADOPTION_GITHUB_TOKEN (PAT), runs --strict so failed/skipped collectors do not commit N/A snapshots, retries 429s, and includes traffic deltas in --report. Push path rebases on conflict.
1 parent 3e22382 commit ec22cd4

4 files changed

Lines changed: 225 additions & 58 deletions

File tree

‎.github/workflows/adoption-snapshot.yml‎

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,49 @@ on:
66
- cron: "0 6 * * *"
77
workflow_dispatch: # allow manual runs
88

9+
# The default GITHUB_TOKEN cannot call GET /repos/.../traffic/* (always 403).
10+
# Add repo secret ADOPTION_GITHUB_TOKEN: a PAT with Administration:read
11+
# (fine-grained) or public_repo (classic). Contents:write on GITHUB_TOKEN
12+
# is still what commits the snapshot files.
913
permissions:
10-
contents: write # needed to commit snapshot files
14+
contents: write
15+
16+
concurrency:
17+
group: adoption-snapshot
18+
cancel-in-progress: false
1119

1220
jobs:
1321
snapshot:
1422
runs-on: ubuntu-latest
1523
steps:
16-
- uses: actions/checkout@v4
24+
# Pin checkout: this job has contents: write.
25+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
26+
with:
27+
fetch-depth: 0
1728

1829
- name: Run adoption snapshot
1930
env:
20-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21-
run: python3 scripts/adoption_snapshot.py --out metrics/
31+
GITHUB_TOKEN: ${{ secrets.ADOPTION_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
32+
run: python3 scripts/adoption_snapshot.py --out metrics/ --strict
2233

2334
- name: Commit snapshot
2435
run: |
36+
set -euo pipefail
2537
git config user.name "github-actions[bot]"
2638
git config user.email "github-actions[bot]@users.noreply.github.com"
2739
git add metrics/
2840
if git diff --staged --quiet; then
2941
echo "No changes to commit (snapshot already up to date)"
30-
else
31-
git commit -m "chore(metrics): daily adoption snapshot $(date -u +%Y-%m-%d)"
32-
git push
42+
exit 0
3343
fi
44+
git commit -m "chore(metrics): daily adoption snapshot $(date -u +%Y-%m-%d)"
45+
branch="${GITHUB_REF_NAME}"
46+
for attempt in 1 2 3; do
47+
if git pull --rebase origin "$branch" && git push origin "HEAD:$branch"; then
48+
exit 0
49+
fi
50+
echo "push attempt ${attempt} failed; retrying"
51+
sleep $((attempt * 5))
52+
done
53+
echo "Failed to push snapshot after 3 rebase retries"
54+
exit 1

‎metrics/adoption-2026-09-02.json‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
{
2-
"snapshot_at": "2026-09-02T01:18:42.212052+00:00",
2+
"snapshot_at": "2026-09-02T01:29:29.972374+00:00",
33
"repo": "uniswap-python/uniswap-python",
44
"package": "uniswap-python",
55
"github": {
66
"stars": 1011,
77
"forks": 375,
88
"watchers": 23,
9-
"open_issues": 65
9+
"open_issues": 66
1010
},
1111
"github_traffic": {
12-
"clones_14d": null,
13-
"unique_cloners_14d": null,
14-
"views_14d": null,
15-
"unique_visitors_14d": null,
16-
"clones_error": "HTTP 403: Forbidden",
17-
"views_error": "HTTP 403: Forbidden"
12+
"note": "Skipped \u2014 set ADOPTION_GITHUB_TOKEN (PAT with Administration:read) to capture traffic (14-day window only). The default Actions GITHUB_TOKEN cannot read /traffic/*."
1813
},
1914
"pypi": {
20-
"error": "HTTP 429: Too Many Requests",
21-
"note": "pypistats.org rate-limited; retry after a few minutes"
15+
"downloads_last_day": 19,
16+
"downloads_last_week": 210,
17+
"downloads_last_month": 1044,
18+
"version_split_note": "Per-version counts require BigQuery (pypistats.org does not expose them). To check v4 pickup specifically, compare release-date-filtered BigQuery results."
2219
},
2320
"pypi_versions": [
2421
{

‎metrics/adoption-2026-09-02.md‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# uniswap-python Adoption Snapshot
22

3-
**Snapshot date**: 2026-09-02T01:18:42.212052+00:00
3+
**Snapshot date**: 2026-09-02T01:29:29.972374+00:00
44

55
## GitHub
66

@@ -9,26 +9,21 @@
99
| Stars | 1011 |
1010
| Forks | 375 |
1111
| Watchers | 23 |
12-
| Open Issues | 65 |
12+
| Open Issues | 66 |
1313

1414
## GitHub Traffic (14-day window)
1515

16-
| Metric | Value |
17-
| --- | --- |
18-
| Clones (14d) | N/A |
19-
| Unique Cloners (14d) | N/A |
20-
| Views (14d) | N/A |
21-
| Unique Visitors (14d) | N/A |
16+
_Skipped — set ADOPTION_GITHUB_TOKEN (PAT with Administration:read) to capture traffic (14-day window only). The default Actions GITHUB_TOKEN cannot read /traffic/*._
2217

2318
## PyPI Downloads
2419

2520
| Period | Downloads |
2621
| --- | --- |
27-
| Last day | N/A |
28-
| Last week | N/A |
29-
| Last month | N/A |
22+
| Last day | 19 |
23+
| Last week | 210 |
24+
| Last month | 1044 |
3025

31-
__
26+
_Per-version counts require BigQuery (pypistats.org does not expose them). To check v4 pickup specifically, compare release-date-filtered BigQuery results._
3227

3328
## Recent Releases
3429

0 commit comments

Comments
 (0)