Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 0 additions & 108 deletions .github/workflows/weekly-api-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
models: read
env:
SNAPSHOTS_REPO: LFDanLu/react-spectrum-api-snapshots

Expand Down Expand Up @@ -130,110 +129,3 @@ jobs:
else
echo "Skipping commit — diff-current empty=$([ ! -s /tmp/diff-current.md ] && echo yes || echo no), new_release=$NEW_RELEASE, delta_empty=$([ ! -s /tmp/weekly-delta.txt ] && echo yes || echo no)"
fi

# Summarize with GitHub Models (free via GITHUB_TOKEN) and post to Slack
- name: Summarize and post to Slack
env:
SLACK_TSDIFF_CHROMATIC_BOT_TOKEN: ${{ secrets.SLACK_TSDIFF_CHROMATIC_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
TEST_SLACK_ID: ${{ secrets.TEST_SLACK_ID }}
GITHUB_TOKEN: ${{ github.token }}
run: |
python3 << 'PYEOF'
import glob, json, os, urllib.request

required = ['SLACK_TSDIFF_CHROMATIC_BOT_TOKEN', 'SLACK_CHANNEL_ID', 'GITHUB_TOKEN', 'TODAY', 'SNAPSHOTS_REPO', 'GITHUB_WORKSPACE']
missing = [k for k in required if not os.environ.get(k)]
if missing:
raise SystemExit(f"Missing required environment variables: {', '.join(missing)}")

today = os.environ['TODAY']
channel = os.environ['SLACK_CHANNEL_ID']
snapshots_repo = os.environ['SNAPSHOTS_REPO']
slack_token = os.environ['SLACK_TSDIFF_CHROMATIC_BOT_TOKEN']
github_token = os.environ['GITHUB_TOKEN']
workspace = os.environ['GITHUB_WORKSPACE']
diff_url = f"https://github.com/{snapshots_repo}/blob/main/diffs/{today}.md"
delta_url = f"https://github.com/{snapshots_repo}/blob/main/deltas/{today}.md"

vs_release_size = os.path.getsize('/tmp/diff-current.md')
vs_last_week_size = os.path.getsize('/tmp/weekly-delta.txt') if os.path.exists('/tmp/weekly-delta.txt') else 0

prev_files = sorted(glob.glob(f"{workspace}/snapshots/diffs/*.md"), reverse=True)
prev_date = os.path.basename(prev_files[0]).replace('.md', '') if prev_files else None
prev_url = f"https://github.com/{snapshots_repo}/blob/main/diffs/{prev_date}.md" if prev_date else None

new_release = os.environ.get('NEW_RELEASE') == 'true'

def post(text, thread_ts=None):
payload = {"channel": channel, "text": text, "unfurl_links": False, "unfurl_media": False}
if thread_ts:
payload["thread_ts"] = thread_ts
req = urllib.request.Request(
'https://slack.com/api/chat.postMessage',
data=json.dumps(payload).encode(),
headers={
'Authorization': f'Bearer {slack_token}',
'Content-Type': 'application/json'
}
)
resp = json.loads(urllib.request.urlopen(req).read())
print("Slack response:", resp.get('ok'), resp.get('error', ''))
if not resp.get('ok'):
raise SystemExit(f"Slack error: {resp.get('error')}")
return resp['message']['ts']

if vs_release_size == 0:
body = "No API changes detected vs last release — all pending changes have been included in a release."
elif vs_last_week_size == 0 and not new_release:
prev_ref = f"last diff ({prev_date}): {prev_url}" if prev_date else "last diff"
body = f"No new API changes since {prev_ref}."
elif new_release:
body = f"New release since last diff — resetting baseline. Full diff vs release: {diff_url}\n\nReact ✅ if changes look expected, or 🚨 if something looks wrong."
else:
# Read the already-processed delta saved by the shell step
delta_path = f"{workspace}/snapshots/deltas/{today}.md"
model_input_full = open(delta_path).read() if os.path.exists(delta_path) else ""
TRUNCATE_LIMIT = 8000
truncated = len(model_input_full) > TRUNCATE_LIMIT
model_input = model_input_full[:TRUNCATE_LIMIT] if truncated else model_input_full

# Extract classification rules from prompt.md (single source of truth)
prompt_md = open(f"{workspace}/scripts/weekly-api-diff/prompt.md").read()
rules_start = prompt_md.find("Apply these grouping and classification rules")
rules_end = prompt_md.find("\n## Step 9", rules_start)
rules = prompt_md[rules_start:rules_end].strip() if rules_start != -1 else ""

payload = {
"model": "gpt-4o-mini",
"max_tokens": 800,
"messages": [{
"role": "user",
"content": (
f"Summarize this week's react-spectrum API changes using grouped bullet points. Group related changes together (e.g. multiple layout classes losing the same method = one bullet). For each group or item:\n"
f"- Name the component(s) or interface(s)\n"
f"- Say what changed (added, removed, signature changed)\n"
f"- Flag net-new components \n"
f"Don't spell out full type signatures. Aim for a knowledgeable teammate skimming Slack.\n\n"
f"IMPORTANT: Only report what is explicitly listed below. Do not infer or add anything from your training knowledge.\n\n"
f"{rules}\n\n"
f"{model_input}"
)
}]
}

req = urllib.request.Request(
'https://models.inference.ai.azure.com/chat/completions',
data=json.dumps(payload).encode(),
headers={
'Authorization': f'Bearer {github_token}',
'Content-Type': 'application/json'
}
)
summary = json.loads(urllib.request.urlopen(req).read())['choices'][0]['message']['content']
truncation_note = "\n\n⚠️ Delta was large — summary may be incomplete. Check the full delta link below." if truncated else ""
body = f"{summary}{truncation_note}\n\nWhat's new this week: {delta_url}\nFull diff vs release: {diff_url}\n\nReact ✅ if changes look expected, or 🚨 if something looks wrong."

ts = post(f"📊 Weekly API Diff — {today}")
post(f"📊 Weekly API Diff — {today}\n\n{body}", thread_ts=ts)
PYEOF
Loading