ci: fix lychee --accept quoting and bump checkout to v5 (refs #903)

This commit is contained in:
pluja
2026-07-04 18:15:29 +03:00
parent 6da3245b68
commit fb4a6d12a7
2 changed files with 13 additions and 9 deletions
+10 -6
View File
@@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v5
- name: Run lychee on README.md - name: Run lychee on README.md
uses: lycheeverse/lychee-action@v2 uses: lycheeverse/lychee-action@v2
@@ -34,7 +34,7 @@ jobs:
--retry-wait-time 2 --retry-wait-time 2
--timeout 20 --timeout 20
--exclude-mail --exclude-mail
--accept '200..=299,403,429,999' --accept 200..=299,403,429,999
README.md README.md
format: json format: json
output: lychee/out.json output: lychee/out.json
@@ -57,6 +57,7 @@ jobs:
# ---- 1. Dead links, from the lychee JSON report ------------------------ # ---- 1. Dead links, from the lychee JSON report ------------------------
dead = [] dead = []
dead_ok = True
try: try:
with open("lychee/out.json") as fh: with open("lychee/out.json") as fh:
data = json.load(fh) data = json.load(fh)
@@ -68,8 +69,10 @@ jobs:
text = status.get("text") or status.get("details") or "error" text = status.get("text") or status.get("details") or "error"
dead.append((url, text)) dead.append((url, text))
except FileNotFoundError: except FileNotFoundError:
dead_ok = False
print("::warning::lychee/out.json not found; skipping dead-link section") print("::warning::lychee/out.json not found; skipping dead-link section")
except Exception as exc: except Exception as exc:
dead_ok = False
print(f"::warning::Could not parse lychee output ({exc})") print(f"::warning::Could not parse lychee output ({exc})")
# De-duplicate while keeping order. # De-duplicate while keeping order.
seen = set() seen = set()
@@ -167,13 +170,14 @@ jobs:
lines.append("") lines.append("")
lines.append(f"## Dead links ({len(dead)})") lines.append(f"## Dead links ({len(dead)})")
lines.append("")
if dead: if dead:
lines.append("")
for url, text in dead: for url, text in dead:
lines.append(f"- {url} - {text}") lines.append(f"- {url} - {text}")
else: elif dead_ok:
lines.append("")
lines.append("None found.") lines.append("None found.")
else:
lines.append("_Link scan produced no output this run; dead links were not checked._")
lines.append("") lines.append("")
lines.append(f"## Stale or archived repositories ({len(stale)})") lines.append(f"## Stale or archived repositories ({len(stale)})")
@@ -197,7 +201,7 @@ jobs:
with open("health-report.md", "w", encoding="utf-8") as fh: with open("health-report.md", "w", encoding="utf-8") as fh:
fh.write("\n".join(lines) + "\n") fh.write("\n".join(lines) + "\n")
has_findings = bool(dead or stale) has_findings = bool(dead or stale or not dead_ok)
out = os.environ.get("GITHUB_OUTPUT") out = os.environ.get("GITHUB_OUTPUT")
if out: if out:
with open(out, "a") as fh: with open(out, "a") as fh:
+3 -3
View File
@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v5
- name: Run lychee on README.md - name: Run lychee on README.md
uses: lycheeverse/lychee-action@v2 uses: lycheeverse/lychee-action@v2
@@ -37,7 +37,7 @@ jobs:
--retry-wait-time 2 --retry-wait-time 2
--timeout 20 --timeout 20
--exclude-mail --exclude-mail
--accept '100..=103,200..=299,403,429,500,502,503,504,999' --accept 100..=103,200..=299,403,429,500,502,503,504,999
README.md README.md
format: markdown format: markdown
output: lychee/out.md output: lychee/out.md
@@ -50,7 +50,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v5
with: with:
fetch-depth: 0 fetch-depth: 0