Diff Linkchecker #664
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Pull Request Docs Check" | |
on: | |
- pull_request | |
jobs: | |
build-pdf: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Refresh Packages | |
run: sudo apt-fast -y update | |
- name: Install Dependencies | |
run: xargs -a dependencies sudo apt-fast install -y | |
- name: Python Setup | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
cache: 'pip' | |
- name: Python Install Dependencies | |
run: pip install -r docs/requirements.txt | |
- name: Build PDF | |
env: | |
SPHINXOPTS: "-D html_context.commit=${{ github.sha }} -D version=latest -A display_github=true -A github_user=${{ github.repository_owner }} -A github_repo=${{ github.event.repository.name }} -A github_version=${{ github.ref_name }} -A conf_py_path=/docs/source/" | |
run: make -C docs/ latexpdf | |
- name: Archive PDF | |
env: | |
PR_NUMBER: ${{ github.event.number }} | |
ID: ${{ github.run_attempt }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: FTCDOCS-PDF | |
path: | | |
docs/build/latex/*.pdf | |
FTCDOCS-PR-${{ env.PR_NUMBER }}-${{ env.ID }} | |
if-no-files-found: error | |
build-html: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Refresh Packages | |
run: sudo apt-fast -y update | |
- name: Python Setup | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
cache: 'pip' | |
- name: Python Install Dependencies | |
run: pip install -r docs/requirements.txt | |
- name: Build Site | |
env: | |
SPHINXOPTS: "-D html_context.commit=${{ github.sha }} -D version=latest -A display_github=true -A github_user=${{ github.repository_owner }} -A github_repo=${{ github.event.repository.name }} -A github_version=${{ github.ref_name }} -A conf_py_path=/docs/source/" | |
run: make -C docs/ html | |
- name: Archive Site | |
uses: actions/upload-artifact@v3 | |
with: | |
name: FTCDOCS-HTML | |
path: 'docs/build/html' | |
if-no-files-found: error | |
spelling-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- uses: reviewdog/action-misspell@v1 | |
with: | |
locale: "US" | |
reporter: "github-check" | |
link-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Python Setup | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
cache: 'pip' | |
- name: Python Install Dependencies | |
run: pip install -r docs/requirements.txt | |
- name: Install additional dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq unzip | |
- name: Download previous artifact | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY/actions/artifacts?per_page=100" > artifacts.json | |
DOWNLOAD_URL=$(jq -r '.artifacts[] | select(.name | startswith("LINKCHECK--1")) | .archive_download_url' artifacts.json | head -n 1) | |
if [ -z "$DOWNLOAD_URL" ]; then | |
echo "No previous LINKCHECK artifact found" | |
exit 0 | |
fi | |
# Print the URL so that it's easier to debug if something goes wrong | |
echo "Downloading $DOWNLOAD_URL" | |
curl -L -o linkcheck.zip "$DOWNLOAD_URL" | |
if [ $? -ne 0 ]; then | |
echo "Failed to download the zip file" | |
exit 1 | |
fi | |
unzip -q linkcheck.zip -d linkcheck_contents | |
if [ $? -ne 0 ]; then | |
echo "Failed to unzip the file" | |
exit 1 | |
fi | |
echo "Successfully downloaded and unzipped previous LINKCHECK artifact" | |
- name: link-check | |
run: make -C docs/ linkcheck SPHINXOPTS="-W --keep-going -n -q" || true | |
- name: Compare outputs | |
run: | | |
if [ -f linkcheck_contents/output.txt ]; then | |
new_errors=$(comm -13 linkcheck_contents/output.txt docs/build/linkcheck/output.txt) | |
if [ -n "$new_errors" ]; then | |
echo "New errors found:" | |
echo "$new_errors" | |
exit 1 | |
else | |
echo "No new errors found." | |
fi | |
else | |
echo "No previous output.txt found. Treating all current errors as new." | |
cat docs/build/linkcheck/output.txt | |
[ -s docs/build/linkcheck/output.txt ] && exit 1 || exit 0 | |
fi | |
- name: Archive Log | |
if: always() | |
uses: actions/upload-artifact@v2 | |
with: | |
name: LINKCHECK-PR | |
path: docs/build/linkcheck/output.txt | |
retention-days: 7 | |
image-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Python Setup | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Python Install Dependencies | |
run: pip install -r docs/requirements.txt | |
- name: image-check | |
run: make -C docs/ imagecheck | |
check-redirect: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Fetch origin/main | |
run: git fetch origin main --depth=1 | |
- name: Python Setup | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
cache: 'pip' | |
- name: Python Install Dependencies | |
run: pip install -r docs/requirements.txt | |
- name: check-redirect | |
run: make -C docs/ rediraffecheckdiff |