Skip to content
Open
Show file tree
Hide file tree
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
49 changes: 30 additions & 19 deletions .github/workflows/weekly-api-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ jobs:
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'
Expand Down Expand Up @@ -165,17 +164,38 @@ jobs:

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:
message = f"πŸ“Š Weekly API Diff β€” {today}\n\nNo API changes detected vs last release β€” all pending changes have been included in a release."
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"
message = f"πŸ“Š Weekly API Diff β€” {today}\n\nNo new API changes since {prev_ref}."
body = f"No new API changes since {prev_ref}."
elif new_release:
message = f"πŸ“Š Weekly API Diff β€” {today}\n\nNew release since last diff β€” resetting baseline. Full diff vs release: {diff_url}\n\nReact βœ… if changes look expected, or 🚨 if something looks wrong."
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}.txt"
model_input = open(delta_path).read() if os.path.exists(delta_path) else ""
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
Comment on lines +195 to +198
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to come up with a way to shrink the diff/or summarize repetitive parts before sending it to the model since the payload can be too big if so. @snowystinger I think you said you were working on making the TSDiffer clean up its output so that it doesn't show unchanged parts of the API?


# Extract classification rules from prompt.md (single source of truth)
prompt_md = open(f"{workspace}/scripts/weekly-api-diff/prompt.md").read()
Expand Down Expand Up @@ -210,18 +230,9 @@ jobs:
}
)
summary = json.loads(urllib.request.urlopen(req).read())['choices'][0]['message']['content']
message = f"πŸ“Š Weekly API Diff β€” {today}\n\n{summary}\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."

req = urllib.request.Request(
'https://slack.com/api/chat.postMessage',
data=json.dumps({"channel": channel, "text": message}).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')}")
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
36 changes: 21 additions & 15 deletions .github/workflows/weekly-chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,29 @@ jobs:
return f"βœ… | {url}"
return f"⚠️ changes pending review | {url}"

message = "\n".join([
f"πŸ“Έ Weekly Chromatic β€” {today}",
"",
body = "\n".join([
f"Chromatic: {fmt(os.environ['CHROMATIC_CODE'], os.environ['CHROMATIC_URL'])}",
f"Forced Colors: {fmt(os.environ['CHROMATIC_FC_CODE'], os.environ['CHROMATIC_FC_URL'])}",
])

req = urllib.request.Request(
'https://slack.com/api/chat.postMessage',
data=json.dumps({"channel": channel, "text": message}).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')}")
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']

ts = post(f"πŸ“Έ Weekly Chromatic β€” {today}")
post(f"πŸ“Έ Weekly Chromatic β€” {today}\n\n{body}", thread_ts=ts)
PYEOF