-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (106 loc) · 4.4 KB
/
Copy pathurl-check.yml
File metadata and controls
117 lines (106 loc) · 4.4 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
106
107
108
109
110
111
112
113
114
115
116
117
name: URL Check (central)
# Centralised URL-hygiene sweep for the PyAuto ecosystem.
#
# Replaces the 12 per-repo .github/workflows/url_check.yml workflows: instead of
# each repo running its own offline + live URL audit and opening its own
# [url-check] issue, PyAutoHeart sweeps every repo here and consolidates into a
# SINGLE [url-check] tracking issue. Mirrors the heart-health.yml pattern.
#
# Monitoring only — URL hygiene does not gate releases (Heart owns the release
# gate via `readiness`, which this does not touch).
on:
schedule:
- cron: "0 4 * * 1" # Mondays 04:00 UTC (same cadence as the old per-repo crons)
workflow_dispatch:
permissions:
contents: read
issues: write
env:
REPOS: >-
HowToFit HowToGalaxy HowToLens
PyAutoConf PyAutoFit PyAutoArray PyAutoGalaxy PyAutoLens
autofit_workspace autogalaxy_workspace autolens_workspace
euclid_strong_lens_modeling_pipeline
jobs:
url-check:
name: Central URL sweep
runs-on: ubuntu-latest
steps:
- name: Checkout PyAutoHeart
uses: actions/checkout@v4
with:
path: heart
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install requests (for the live HTTP audit)
run: pip install --quiet requests
- name: Sweep every repo (offline + live)
id: sweep
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set +e
body="# URL hygiene report"$'\n'
offline_hits=0
live_hits=0
for repo in $REPOS; do
git clone --depth 1 "https://github.com/PyAutoLabs/$repo" "checkout/$repo" >/dev/null 2>&1
if [ ! -d "checkout/$repo" ]; then
body+=$'\n'"## $repo"$'\n'"- clone failed (skipped)"$'\n'
continue
fi
# Offline forbidden-pattern guard.
off="$(bash heart/heart/checks/url_check.sh "checkout/$repo" 2>/dev/null)"
off_rc=$?
# Live HTTP audit (honours the repo's .url_check_allowlist.txt).
live="$(bash heart/heart/checks/url_check_live.sh "checkout/$repo" 2>/dev/null)"
live_rc=$?
if [ "$off_rc" -ne 0 ] || [ "$live_rc" -ne 0 ]; then
body+=$'\n'"## $repo"$'\n'
if [ "$off_rc" -ne 0 ]; then
offline_hits=$((offline_hits + 1))
body+="### Forbidden URL patterns (offline)"$'\n'
body+='```'$'\n'"$off"$'\n''```'$'\n'
fi
if [ "$live_rc" -ne 0 ]; then
live_hits=$((live_hits + 1))
body+="### Broken live URLs"$'\n'"$live"$'\n'
fi
fi
done
if [ "$offline_hits" -eq 0 ] && [ "$live_hits" -eq 0 ]; then
status=green
body="✅ URL hygiene clean across all $(echo $REPOS | wc -w) repos (offline + live)."
else
status=red
fi
printf '%s\n' "$body" > /tmp/url_body.md
echo "status=$status" >> "$GITHUB_OUTPUT"
cat /tmp/url_body.md
- name: Open or update the [url-check] issue
if: steps.sweep.outputs.status != 'green'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
existing=$(gh issue list --repo "$GITHUB_REPOSITORY" --search '"[url-check]"' --state open --json number --jq '.[0].number // empty')
if [ -n "$existing" ]; then
gh issue comment "$existing" --repo "$GITHUB_REPOSITORY" --body-file /tmp/url_body.md
else
gh issue create --repo "$GITHUB_REPOSITORY" \
--title "[url-check] Broken or forbidden URLs across the ecosystem" \
--body-file /tmp/url_body.md \
--label url-check 2>/dev/null \
|| gh issue create --repo "$GITHUB_REPOSITORY" \
--title "[url-check] Broken or forbidden URLs across the ecosystem" \
--body-file /tmp/url_body.md
fi
- name: Close the [url-check] issue when clean
if: steps.sweep.outputs.status == 'green'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for n in $(gh issue list --repo "$GITHUB_REPOSITORY" --search '"[url-check]"' --state open --json number --jq '.[].number'); do
gh issue close "$n" --repo "$GITHUB_REPOSITORY" --comment "Central URL sweep is clean — closing automatically."
done