forked from ChelseaKR/tods-validate
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (56 loc) · 2.16 KB
/
Copy pathspec-watch.yml
File metadata and controls
60 lines (56 loc) · 2.16 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
name: Spec watch (advisory)
# Advisory only. This never runs on pull_request or push, so it cannot block a
# merge. It runs on demand and once a week to catch schema.py's hand
# transcription silently drifting from the upstream TODS spec. See
# docs/spec-watch.md.
on:
workflow_dispatch:
schedule:
# Mondays at 07:00 UTC (mutation.yml runs the same day at 06:00; staggered
# so the two advisory jobs don't contend for runners).
- cron: "0 7 * * 1"
permissions:
contents: read
issues: write
jobs:
spec-watch:
runs-on: ubuntu-latest
# Belt and suspenders: even a non-zero exit must not fail the workflow.
continue-on-error: true
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.12"
- run: python -m pip install -e ".[dev]"
- name: Diff the upstream spec against schema.py
id: diff
run: |
python scripts/spec_watch.py --format markdown > drift.md || true
if [ -s drift.md ] && grep -q "Spec drift detected" drift.md; then
echo "drift=true" >> "$GITHUB_OUTPUT"
else
echo "drift=false" >> "$GITHUB_OUTPUT"
fi
- name: Open or update the drift issue
if: steps.diff.outputs.drift == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TITLE: "Spec drift detected"
run: |
existing="$(gh issue list --state open --search "in:title \"$TITLE\"" --json number --jq '.[0].number // empty')"
if [ -n "$existing" ]; then
gh issue comment "$existing" --body-file drift.md
else
gh issue create --title "$TITLE" --body-file drift.md --label "spec-watch" || \
gh issue create --title "$TITLE" --body-file drift.md
fi
- name: Upload the raw diff
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: spec-watch-diff
path: drift.md
if-no-files-found: ignore