Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enhancement]: Automatically linkcheck in CI #4479

Merged
merged 9 commits into from
Oct 3, 2023
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
43 changes: 43 additions & 0 deletions .github/workflows/linkcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: linkcheck in CI

on:
push:
branches:
- main
pull_request: {}
workflow_dispatch:
inputs:
failOnError:
description: 'Fail job on link check error'
required: false
default: 'false'
Comment on lines +10 to +13
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the constructive workflow_dispatch suggestion here for readability of continue-on-error below.


jobs:
linkcheck:
runs-on: ubuntu-22.04
continue-on-error:${{ github.event_name == 'workflow_dispatch' && github.event.inputs.failOnError == 'true' ? false : true }}

steps:
- name: Checkout Repository
uses: actions/[email protected]

- name: "Install Python 3.10"
uses: actions/setup-python@v4
with:
python-version: '3.10.8'

- name: Install tox
run: pip install tox

- name: Run Sphinx linkcheck
run: tox -e linkcheck | tee output.txt

- name: Check for broken links below threshold 6
run: |
broken_count=$(grep -c "broken" output.txt)
if [[ $broken_count -ge 3 ]]; then
echo "Too many broken links detected: $broken_count"
exit 1
else
echo "Number of broken links is below threshold: $broken_count"
fi
14 changes: 14 additions & 0 deletions doc/rtd/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@
autosectionlabel_prefix_document = True
autosectionlabel_maxdepth = 2

# Sphinx-linkcheck config
linkcheck_ignore = [
r"http://\[fd00:ec2::254.*",
r"http://instance-data.*",
r"https://powersj.io.*",
r"http://169.254.169.254.*",
r"http://10.10.0.1.*",
]

linkcheck_anchors_ignore_for_url = (
r"https://github.com/canonical/cloud-init.*",
r"https://github.com/canonical/ubuntu-pro-client.*",
)

# Sphinx-copybutton config options:
notfound_body = (
"<h1>Page not found</h1><p>Sorry we missed you! Our docs have had a"
Expand Down
1 change: 1 addition & 0 deletions tools/.github-cla-signers
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl
Indrranil
irishgordo
ITJamie
itsaviral2609
ixjhuang
izzyleung
j5awry
Expand Down
Loading