Skip to content

Documentation tests

Documentation tests #5

Workflow file for this run

name: test-docs
run-name: Documentation tests
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
env:
HATCH_ENV_TYPE_VIRTUAL_PATH: ${{ github.workspace }}/.hatch_envs
jobs:
doc-test:
name: Sphinx Documentation Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: ./.github/actions/setup-docs-env
- name: Run sphinx html builder
run: hatch run docs:html -W
- name: Check GitHub API Rate Limit
id: rate_limit_check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
API_URL="https://api.github.com/rate_limit"
RESPONSE=$(curl -s -H "Authorization: token $GH_TOKEN" -H "Accept: application/vnd.github.v3+json" $API_URL)
REMAINING_CORE=$(echo "$RESPONSE" | jq -r '.resources.core.remaining')
echo "Remaining core API calls: $REMAINING_CORE"
THRESHOLD=100
echo "remaining_core=$REMAINING_CORE" >> $GITHUB_OUTPUT
echo "threshold=$THRESHOLD" >> $GITHUB_OUTPUT
if [ "$REMAINING_CORE" -lt "$THRESHOLD" ]; then
echo "skip_linkcheck=true" >> $GITHUB_OUTPUT
echo "Low GitHub API core rate limit ($REMAINING_CORE remaining). Skipping linkcheck."
else
echo "skip_linkcheck=false" >> $GITHUB_OUTPUT
echo "Sufficient GitHub API core rate limit ($REMAINING_CORE remaining)."
fi
shell: bash
- name: Run sphinx linkcheck
if: steps.rate_limit_check.outputs.skip_linkcheck == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: hatch run docs:linkcheck
- name: Report Skipped Linkcheck
if: steps.rate_limit_check.outputs.skip_linkcheck == 'true'
run: |
echo "::warning title=Linkcheck Skipped Due to Rate Limit::The Sphinx documentation link check was skipped because the remaining GitHub API core rate limit (${{ steps.rate_limit_check.outputs.remaining_core }} remaining) was below the threshold (${{ steps.rate_limit_check.outputs.threshold }}). The link check will be performed when the rate limit resets."