Skip to content

Commit

Permalink
Merge pull request #302 from FIRST-Tech-Challenge/linkcheck
Browse files Browse the repository at this point in the history
Diff Linkchecker P2
  • Loading branch information
miriamsr authored Aug 7, 2024
2 parents 38a3d6b + 73c0e1c commit f284279
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 11 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/link-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ jobs:
- name: Arhive Log
if: ${{ failure() }}
uses: actions/upload-artifact@v2
env:
PR_NUMBER: ${{ github.event.number }}
ID: ${{ github.run_attempt }}
with:
name: LINKCHECK-${{ env.PR_NUMBER }}-${{ env.ID }}
name: LINKCHECK--1
path: docs/build/linkcheck/output.txt
retention-days: 7
75 changes: 69 additions & 6 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,80 @@ jobs:
- 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 -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/actions/artifacts?per_page=100" > artifacts.json
DOWNLOAD_URL=$(jq -r '.artifacts[] | select(.name | startswith("LINKCHECK--")) | .archive_download_url' artifacts.json | head -n 1)
if [ -z "$DOWNLOAD_URL" ]; then
echo "No previous LINKCHECK artifact found"
exit 0
fi
curl -L \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-o linkcheck.zip "$DOWNLOAD_URL"
if [ $? -ne 0 ]; then
echo "Failed to download the zip file"
exit 0
fi
if unzip -t linkcheck.zip >/dev/null 2>&1; then
unzip -q linkcheck.zip -d linkcheck_contents
echo "Successfully downloaded and unzipped previous LINKCHECK artifact"
else
echo "Downloaded file is not a valid zip. Skipping unzip."
rm linkcheck.zip
mkdir -p linkcheck_contents
fi
- name: link-check
run: make -C docs/ linkcheck SPHINXOPTS="-W --keep-going -n -q"
run: |
make -C docs/ linkcheck SPHINXOPTS="-W --keep-going -n -q" || true
- name: Compare outputs
run: |
echo "Archived Errors"
cat linkcheck_contents/output.txt
echo "PR Errors"
cat docs/build/linkcheck/output.txt
if [ -f linkcheck_contents/output.txt ]; then
sort linkcheck_contents/output.txt > old_sorted.txt
sort docs/build/linkcheck/output.txt > new_sorted.txt
new_errors=$(comm -13 old_sorted.txt new_sorted.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: ${{ failure() }}
if: always()
uses: actions/upload-artifact@v2
env:
PR_NUMBER: ${{ github.event.number }}
ID: ${{ github.run_attempt }}
with:
name: LINKCHECK
name: LINKCHECK-PR-${{ github.event.number }}-${{ github.run_attempt }}
path: docs/build/linkcheck/output.txt
retention-days: 7

Expand Down
1 change: 1 addition & 0 deletions dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
texlive-xetex
latexmk
jq
unzip
fonts-roboto
1 change: 0 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ git+https://github.com/FIRST-Tech-Challenge/ftcdocs-helper@main#subdirectory=coo
sphinx-sitemap==2.3.0
python-git-info==0.8.3
sphinxcontrib-mermaid==0.9.2
sphinxext-linkcheckdiff==0.1.0
sphinxext-rediraffe==0.2.7

0 comments on commit f284279

Please sign in to comment.