Skip to content
Merged
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
8 changes: 5 additions & 3 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,16 @@ Triggers `deploy.yaml` after successful processing via `repository_dispatch`.

Runs every test in `scripts/tests/` (including the SEO checks and the clusters parser and sub-cluster counts) and `scripts/test_parse_disciplines_gdoc.py`.

### [check_images.yaml](check_images.yaml)
**Image validation in PRs**
### [check_content_rules.yaml](check_content_rules.yaml)
**Content policy checks in PRs**

| Trigger | Runs on |
|---------|---------|
| Pull requests | PR branches |

Validates image files and references.
Runs `scripts/check_content_rules.py` in a single runner to flag (via PR comment / summary):
- PNG/JPG/JPEG image files and local references in added/modified files
- Newly added direct publisher URLs with embedded DOIs under hand-maintained `content/`, with `https://doi.org/...` replacements

## Repository Maintenance

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Check Images in PR
name: Check Content Rules

# =======================
# Image Validation Workflow
# PR Content Rules Check
# =======================
# Purpose: Validates image files and references in pull requests
# Purpose: Validates PR content policies in one lightweight runner (advisory warnings):
# 1. WebP image policy (flags PNG/JPG/JPEG files and local references)
# 2. Canonical DOI links (flags newly added publisher URLs with embedded DOIs)
# Triggers: PR opened, synchronized, or reopened
# Checks: Image format, size, accessibility, and broken references

on:
pull_request:
Expand All @@ -17,31 +18,26 @@ permissions:
pull-requests: write

jobs:
check-images:
check-content-rules:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install PyGithub

- name: Run Image Check Script
id: image_check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_REF: ${{ github.ref }}
- name: Run content rules check
id: content_rules
run: |
python scripts/webp_conversion/check_images_in_pr.py
python3 scripts/check_content_rules.py \
--base "${{ github.event.pull_request.base.sha }}" \
--head HEAD

# Same-repo PRs: the token can write, so post/update the result as a PR comment.
- name: Find Comment
Expand All @@ -51,26 +47,26 @@ jobs:
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: mage files/references
body-includes: '<!-- content-rules-check -->'

- name: Create or update comment
if: github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.image_check.outputs.comment }}
body: ${{ steps.content_rules.outputs.comment }}
edit-mode: replace

# Fork PRs: the GITHUB_TOKEN is read-only, so a PR comment would 403.
# Surface the same result as a job-summary report in the workflow run instead.
- name: Image check report (fork PR)
- name: Content rules report (fork PR)
if: github.event.pull_request.head.repo.full_name != github.repository
env:
REPORT: ${{ steps.image_check.outputs.comment }}
REPORT: ${{ steps.content_rules.outputs.comment }}
run: |
{
echo "## 🖼️ Image check report"
echo "## Content rules report"
echo ""
echo "> This PR is from a fork, so the workflow cannot post a PR comment"
echo "> (fork runs receive a read-only token). The result is shown below."
Expand Down
104 changes: 79 additions & 25 deletions .github/workflows/link-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ jobs:
if: steps.lychee.outputs.exit_code != 0
run: |
python3 << 'PYEOF'
import json, re, time, urllib.error, urllib.parse, urllib.request
import json, re, sys, time, urllib.error, urllib.parse, urllib.request
from concurrent.futures import ThreadPoolExecutor, as_completed
from datetime import datetime, timezone

sys.path.insert(0, "scripts")
from link_check_helpers import verify_zenodo_urls

with open("/tmp/lychee/out.md") as f:
content = f.read()

Expand All @@ -80,14 +83,31 @@ jobs:

# Parse errors, tracking which pages each URL appears on
# url -> {"status": str, "pages": [str]}
# Statuses commonly returned by WAFs or HEAD-rejecting servers get a
# second-pass browser GET + Wayback check rather than being reported
# straight away as broken links. 401/404/5xx/ERROR/TIMEOUT stay in
# main_errors so broken auth-gated forms (e.g. restricted Google Forms)
# are never silently marked recovered.
BOT_BLOCK_STATUSES = {"403", "405", "409", "412"}
url_info = {}
main_errors = {} # non-403
forbidden_errors = {} # 403
main_errors = {} # genuine errors / timeouts / auth failures
forbidden_errors = {} # bot-blocked / method-restricted
current_page = ""
in_actionable_section = True

for line in error_lines:
# Track section headers (### Errors in /tmp/site/.../index.html)
page_match = re.match(r"^### Errors in /tmp/site/[^/]+/(.+)", line)
# Only collect bullets from Errors / Timeouts sections so future
# lychee sections such as "## Ignored per input" are not parsed
# as broken links.
if line.startswith("## "):
current_page = ""
in_actionable_section = line.startswith(("## Errors", "## Timeouts"))
continue
if not in_actionable_section:
continue

# Track section headers (### Errors in /tmp/site/... or ### Timeouts in /tmp/site/...)
page_match = re.match(r"^### (?:Errors|Timeouts) in /tmp/site/[^/]+/(.+)", line)
if page_match:
# Convert file path to URL path
path = page_match.group(1)
Expand All @@ -100,20 +120,21 @@ jobs:
continue
status, url = m.group(1), m.group(2)

target = forbidden_errors if status == "403" else main_errors
target = forbidden_errors if status in BOT_BLOCK_STATUSES else main_errors
Comment thread
LukasWallrich marked this conversation as resolved.
Resolved
if url not in target:
target[url] = {"status": status, "pages": []}
if current_page and current_page not in target[url]["pages"]:
target[url]["pages"].append(current_page)

# ------------------------------------------------------------------
# Second-pass verification of 403s.
# Second-pass verification of bot-blocked / method-restricted URLs
# (403, 405, 409, 412).
#
# lychee already sends a browser User-Agent (see .lychee.toml), but some
# WAFs additionally gate on Accept/Accept-Language or on the HEAD method.
# Rather than excluding these domains outright — which silently drops a
# large share of the site's outbound links from any checking at all — we
# re-request each 403 with full browser headers and a GET.
# re-request each candidate with full browser headers and a GET.
#
# Whatever still refuses is genuinely unverifiable over HTTP, so we ask the
# Wayback availability API whether a snapshot exists. "Blocked, and never
Expand All @@ -136,8 +157,9 @@ jobs:
with urllib.request.urlopen(req, timeout=30) as r:
return url, r.status < 400
except urllib.error.HTTPError as e:
# 401/429 mean "authenticate" / "slow down", not "gone".
return url, e.code < 400 or e.code in (401, 429)
# 429 means "slow down", not "gone". Keep 401 unverified so
# auth-gated failures are never silently reported as recovered.
return url, e.code < 400 or e.code == 429
except Exception:
return url, False

Expand Down Expand Up @@ -199,15 +221,26 @@ jobs:
return "unknown", None
return "unknown", None

recovered, blocked_fresh, blocked_stale, blocked_never, blocked_untested = [], [], [], [], []
zenodo_recovered, recovered, blocked_fresh, blocked_stale, blocked_never, blocked_untested = [], [], [], [], [], []
if forbidden_errors:
print(f"Re-checking {len(forbidden_errors)} 403s with full browser headers...")
zenodo_recovered, zenodo_broken, remaining_forbidden = verify_zenodo_urls(list(forbidden_errors))
for zurl, zstatus in zenodo_broken.items():
info = forbidden_errors.pop(zurl)
main_errors[zurl] = {"status": zstatus, "pages": info["pages"]}
if zenodo_recovered or zenodo_broken:
print(
f"Zenodo API verification: {len(zenodo_recovered)} live, "
f"{len(zenodo_broken)} broken (promoted to Broken links)"
)

still_blocked = []
with ThreadPoolExecutor(max_workers=8) as pool:
for fut in as_completed([pool.submit(recheck, u) for u in forbidden_errors]):
url, ok = fut.result()
(recovered if ok else still_blocked).append(url)
print(f" {len(recovered)} recovered, {len(still_blocked)} still blocked")
if remaining_forbidden:
print(f"Re-checking {len(remaining_forbidden)} bot-blocked/method-restricted URLs with full browser headers...")
with ThreadPoolExecutor(max_workers=8) as pool:
for fut in as_completed([pool.submit(recheck, u) for u in remaining_forbidden]):
url, ok = fut.result()
(recovered if ok else still_blocked).append(url)
print(f" {len(recovered)} recovered, {len(still_blocked)} still blocked")

# Wayback lookups run at low concurrency: CDX tolerates a few parallel
# requests but individual queries can take a minute on deep-crawled
Expand All @@ -231,8 +264,8 @@ jobs:
output += (
f"\n\n> **Actionable total: {len(main_errors)} broken links.** "
f"The `Errors` figure above is lychee's raw per-occurrence count and is "
f"dominated by bot-blocking responses; see the 403 section for how those "
f"were resolved.\n"
f"dominated by bot-blocking responses; see the bot-blocked section for "
f"how those were resolved.\n"
)
output += "\n## Broken links\n\n"

Expand All @@ -242,19 +275,26 @@ jobs:
page_str = f" (in {pages[0]})" if len(pages) == 1 else f" (in {len(pages)} pages)"
output += f"* [{info['status']}] <{url}>{page_str}\n"
else:
output += "No broken links found (excluding 403s).\n"
output += "No broken links found (excluding bot-blocked/method-restricted URLs).\n"

if forbidden_errors:
def with_pages(url):
pages = forbidden_errors[url]["pages"]
return f" (in {pages[0]})" if len(pages) == 1 else f" (in {len(pages)} pages)"

output += (
f"\n## Bot-blocked (403) — {len(forbidden_errors)} URLs, re-verified\n\n"
f"These refused lychee. Each was re-requested with full browser headers, and "
f"whatever still refused was dated against its most recent successful Wayback "
f"capture — the question being *when was this last known to work*, not whether "
f"it ever existed.\n\n"
f"\n## Bot-blocked / method-restricted (403/405/409/412) — {len(forbidden_errors)} URLs, re-verified\n\n"
f"These refused lychee. Zenodo records/files/communities were verified via Zenodo's "
f"public REST API (missing records or files are promoted to **Broken links** above); "
f"remaining URLs were re-requested with full browser headers, and whatever still "
f"refused was dated against its most recent successful Wayback capture — the question "
f"being *when was this last known to work*, not whether it ever existed.\n\n"
)
if zenodo_recovered:
output += (
f"* ✅ **{len(zenodo_recovered)}** verified via the Zenodo REST API — not broken.\n"
)
output += (
f"* ✅ **{len(recovered)}** responded normally to a browser request — not broken.\n"
f"* 🗄️ **{len(blocked_fresh)}** blocked, but archived within the last "
f"{STALE_AFTER_DAYS} days — alive recently.\n"
Expand Down Expand Up @@ -295,6 +335,15 @@ jobs:
output += f"* <{url}>" + (f" — last archived `{when}`\n" if when else "\n")
output += "\n</details>\n"

if zenodo_recovered:
output += (
f"\n<details>\n<summary>✅ Verified via Zenodo REST API "
f"({len(zenodo_recovered)} URLs — not broken)</summary>\n\n"
)
for url in sorted(zenodo_recovered):
output += f"* <{url}>\n"
output += "\n</details>\n"

if recovered:
output += (
f"\n<details>\n<summary>✅ Recovered on re-check "
Expand Down Expand Up @@ -354,6 +403,10 @@ jobs:
rel_parts = page_file.relative_to(SITE_ROOT).parts[1:]
page = "/" + "/".join(rel_parts)
page = re.sub(r"/index\.html$", "/", page)
# Match .lychee.toml's exclude_path: archived newsletter issues are
# historical copies of sent emails and are not maintained.
if re.match(r"^/newsletters/\d{4}-\d{2}/", page):
continue
for m in DOI_RE.finditer(text):
# Entities survive into the captured group (SICI DOIs are written
# &lt;...&gt; in HTML); decode them so the DOI matches what was minted.
Expand Down Expand Up @@ -484,6 +537,7 @@ jobs:
set -euo pipefail
TITLE="Link Checker Report"
BODY_FILE=/tmp/lychee/out.md
python3 -c 'import sys; sys.path.insert(0, "scripts"); from link_check_helpers import format_limitations_section; open("/tmp/lychee/out.md", "a", encoding="utf-8").write(format_limitations_section(".lychee.toml"))'
EXISTING=$(gh issue list --label link-check --state open --limit 1 --json number --jq '.[0].number // empty')
if [ -n "$EXISTING" ]; then
echo "Updating existing issue #$EXISTING"
Expand Down
16 changes: 13 additions & 3 deletions .lychee.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@ exclude = [
"127\\.0\\.0\\.1",

# Social media sites that block automated requests
"://(?:[^/]*\\.)?facebook\\.com(?:/|$)",
Comment thread
LukasWallrich marked this conversation as resolved.
Resolved
"linkedin\\.com",
"twitter\\.com",
"x\\.com",
"://(?:[^/]*\\.)?x\\.com(?:/|$)",

# Slack workspace & invite links — always return 403 to unauthenticated
# automated HTTP requests (verified separately; cannot be checked in CI)
"://forrt\\.slack\\.com(?:/|$)",
"://join\\.slack\\.com(?:/|$)",

# Newsletter signup form action (POST-only endpoint; HEAD/GET always returns 405)
"^https://eocampaign1\\.com/form/",

# Web Archive — often slow or flaky
"web\\.archive\\.org",
Expand Down Expand Up @@ -52,8 +61,9 @@ exclude_path = ["newsletters/[0-9]{4}-[0-9]{2}/"]
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"

# Accept 2xx/3xx and 429 (rate limiting)
# Note: 403 is NOT accepted — those are re-verified and categorised by the
# workflow's post-processing step, since many publishers block bots.
# Note: 403/405/409/412 are NOT accepted — those are re-verified with full
# browser GET headers and categorised by the workflow's post-processing step,
# since many publishers and WAFs block bots or reject HEAD probes.
accept = ["100..=399", "429"]

# Timeout per request in seconds
Expand Down
6 changes: 3 additions & 3 deletions content/OS-developing-world/OS-developing-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ subtitle = "A Collection of Practical Guides"
## The what, how, and why of Open Science in the Developing World
---------------------

**Open Science in the Developing World** is a completed, large-scale international collaboration by 49 open scientists from 12 developing countries, led and supported by FORRT members, that culminated in several community resources (see below) and a peer-reviewed publication in the journal *Advances in Methods and Practices in Psychological Science* (AMPPS), entitled ["Open Science in the Developing World: A Collection of Practical Guides for Researchers in Developing Countries."](https://doi.org/10.1177/25152459251357565) See our postprint [here](http://osf.io/7ubk2).
**Open Science in the Developing World** is a completed, large-scale international collaboration by 49 open scientists from 12 developing countries, led and supported by FORRT members, that culminated in several community resources (see below) and a peer-reviewed publication in the journal *Advances in Methods and Practices in Psychological Science* (AMPPS), entitled ["Open Science in the Developing World: A Collection of Practical Guides for Researchers in Developing Countries."](https://doi.org/10.1177/25152459251357565) See our postprint [here](https://osf.io/7ubk2).

The project responds to a central tension in the open science movement:

Expand Down Expand Up @@ -228,7 +228,7 @@ The paper also directly informs FORRT’s ongoing work on:

- [x] Re-structure the first draft of the whole paper.

- [x] Final preprint of the paper is available [here](http://osf.io/7ubk2).
- [x] Final preprint of the paper is available [here](https://osf.io/7ubk2).

- [x] Final Publication is available [here](https://doi.org/10.1177/25152459251357565).

Expand All @@ -249,7 +249,7 @@ The paper also directly informs FORRT’s ongoing work on:

## Peer-reviewed Publication

The open access **<font style="color:#0e2a38">publication</font>** can be found [here](https://doi.org/10.1177/25152459251357565), and the **<font style="color:#0e2a38">postprint</font>** can [be found here (osf.io/7ubk2)](http://osf.io/7ubk2). Download the supplementary material [here](https://doi.org/10.1177/25152459251357565).
The open access **<font style="color:#0e2a38">publication</font>** can be found [here](https://doi.org/10.1177/25152459251357565), and the **<font style="color:#0e2a38">postprint</font>** can [be found here (osf.io/7ubk2)](https://osf.io/7ubk2). Download the supplementary material [here](https://doi.org/10.1177/25152459251357565).

> Hu, C.-P., Xu, Z., Lazić, A., Bhattacharya, P., Seda, L., Hossain, S., Jeftić, A., Özdoğru, A. A., Amaral, O. B., Miljković, N., Ilchovska, Z. G., Lazarevic, L. B., Bao, H. W. S., Ghodke, N., Moreau, D., Elsherif, M., C., C., Ghai, S., Carneiro, C. F. D., ... Azevedo, F. (2025). **Open Science in the Developing World: A Collection of Practical Guides for Researchers in Developing Countries.** *Advances in Methods and Practices in Psychological Science*, *8*(3), 25152459251357565. [https://doi.org/10.1177/25152459251357565](https://doi.org/10.1177/25152459251357565)

Expand Down
Loading
Loading