Repository navigation
105 lines (95 loc) · 4.86 KB
/
Copy pathweekly.yml
File metadata and controls
105 lines (95 loc) · 4.86 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Weekly
# The conformance fixtures against the contract agentchat.me publishes, once
# a week and on demand (Actions → Weekly → Run workflow). CI runs the same
# script on every push to main and every pull request into main; this run
# flags a contract change on the server between pushes here. Only this
# comparison runs on the schedule, not the test matrix.
#
# A run on main (scheduled or by hand) that does not pass, because the check
# failed or timed out, opens an issue titled "Weekly checks failed", or
# comments on the open one; a run on main that passes closes it. A run that
# does not pass also posts to the Slack warning channel (SLACK_WEBHOOK_WARNING,
# the secret publish.yml already uses): weekly checks are WARNING tier in the
# platform's notification routing, and the issue is the durable record. Only the
# report job may write issues, with the run's own GITHUB_TOKEN.
#
# Its own file, not a trigger in ci.yml: GitHub turns scheduled workflows off
# in a public repository after 60 days without activity, and that must only
# ever stop this file, never CI. Actions → Weekly → "Enable workflow" turns
# it back on.
on:
schedule:
- cron: "29 6 * * 1" # Mondays, 06:29 UTC
workflow_dispatch:
permissions:
contents: read
concurrency:
group: weekly
cancel-in-progress: false
jobs:
contract-fixtures:
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
# A step timeout fails the step (a job timeout would read as cancelled).
- name: Conformance fixtures match the published contract
timeout-minutes: 3
run: bash scripts/check-contract-fixtures.sh
# Not when the whole run was cancelled by hand; a job that timed out or
# failed is reported.
report:
needs: [contract-fixtures]
if: ${{ !cancelled() && github.ref == 'refs/heads/main' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
issues: write
steps:
# Fail-safe: no secret, a revoked webhook or Slack down logs a warning
# and never stops the issue step below (the durable record).
- name: Post to Slack
continue-on-error: true
if: ${{ needs.contract-fixtures.result != 'success' }}
env:
WEBHOOK: ${{ secrets.SLACK_WEBHOOK_WARNING }}
TEXT: ":warning: *agentchatme (PyPI) weekly checks did not pass* on `main` (contract fixtures: ${{ needs.contract-fixtures.result }}): ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
run: |
if [ -z "$WEBHOOK" ]; then echo "::warning::SLACK_WEBHOOK_WARNING not set — skipped"; exit 0; fi
printf '%s' "$TEXT" | jq -Rs '{text: .}' | curl -fsS -o /dev/null --max-time 15 -H 'Content-Type: application/json' -d @- "$WEBHOOK" \
|| echo "::warning::the Slack post failed (webhook revoked, or Slack unreachable)"
- name: Open, update or close the "Weekly checks failed" issue
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
CONTRACT: ${{ needs.contract-fixtures.result }}
run: |
set -euo pipefail
TITLE="Weekly checks failed"
# The open issues themselves, not the search index (it can lag a
# run behind and open a duplicate); the exact title only.
EXISTING=$(gh issue list --state open --limit 200 --json number,title \
--jq '[.[] | select(.title == "Weekly checks failed")][0].number // empty')
# Only a pass closes; anything else (a failure, a timeout) is
# reported.
if [ "$CONTRACT" = "success" ]; then
if [ -n "$EXISTING" ]; then
gh issue comment "$EXISTING" --body "The weekly checks pass again: $RUN_URL"
gh issue close "$EXISTING"
fi
exit 0
fi
{
echo "A run of \`.github/workflows/weekly.yml\` on \`main\` did not pass: $RUN_URL"
echo
echo "- **Contract fixtures: $CONTRACT.** \`conformance/v1/manifest.sha256\` against https://agentchat.me/contract/v1/conformance/manifest.sha256. A failure means the published contract changed (or could not be fetched): copy the published fixtures into \`conformance/v1/\` byte for byte, run the tests, and fix what they find."
echo
echo "A run on main that does not pass comments here; one that passes closes this issue."
} > issue-body.md
if [ -n "$EXISTING" ]; then
gh issue comment "$EXISTING" --body-file issue-body.md
echo "Commented on issue #$EXISTING"
else
gh issue create --title "$TITLE" --body-file issue-body.md
fi