-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (72 loc) · 3.06 KB
/
Copy pathpublish-community-curve.yml
File metadata and controls
80 lines (72 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Publish the community curve commons
#
# Pools the human contributions reviewed on main (community-curves/*.json) with
# the accumulated self-samples (seed-self.json on the community-data branch) into
# one community-curve.json. That file's raw URL is what users set COMMUNITY_CURVE
# to, so any zone others have sampled gains an hour-of-day and day-of-week profile
# even with no free history.
#
# The pool is published to the orphan `community-data` branch (not main), so the
# bot's refreshes never touch main's history.
name: Publish community curve
on:
push:
branches: [main]
paths:
- 'community-curves/*.json'
schedule:
- cron: '23 5 * * *' # daily, after most contributions settle
workflow_dispatch:
permissions:
contents: write # to push to the community-data branch
concurrency:
group: community-data # serialize with the sampler: both write community-data
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5 # main: code + reviewed community-curves/
- uses: astral-sh/setup-uv@v7
- name: Check out the community-data branch into a worktree
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin community-data || true
if git worktree add -B community-data ../data origin/community-data 2>/dev/null; then
echo "Tracking existing community-data branch."
else
echo "Creating orphan community-data branch."
git worktree add --detach ../data
git -C ../data checkout --orphan community-data
git -C ../data rm -rf . >/dev/null 2>&1 || true
fi
- name: Merge contributions and self-samples into the pool
run: |
shopt -s nullglob
inputs=(community-curves/*.json) # reviewed human contributions on main
[ -f ../data/seed-self.json ] && inputs+=(../data/seed-self.json)
if [ ${#inputs[@]} -eq 0 ]; then
echo "Nothing to pool yet."
exit 0
fi
# Defense in depth: refuse to pool malformed or implausible data.
# --min-hours 0 because accumulating seed files are legitimately sparse
# early on; volume-weighting and --cap-n already neutralize any skew.
uv run cli.py validate-curves --min-hours 0 "${inputs[@]}"
# Cap each contributor's per-cell weight so no single repo dominates a zone
uv run cli.py merge-curves "${inputs[@]}" --cap-n 1000 --output ../data/community-curve.json
- name: Commit and push if changed
working-directory: ../data
run: |
if [ ! -f community-curve.json ]; then
echo "No pool produced."
exit 0
fi
git add community-curve.json
if git diff --cached --quiet; then
echo "Pool unchanged."
else
git commit -m "chore: refresh community curve pool"
git push origin community-data
fi