Skip to content

Commit 6481816

Browse files
Feature #3247 link check (#3325)
* Per #3247, adding automated link checking in conjunction with new repo dtcenter/metplus-action-linkcheck * Resolving error * Per #3247, add workflow dispatch to the linkcheck PR workflow too * Per #3247, combine workflows into one file * Per #3247, adding documentation for the new custom/composite action. * Per #3247, added documentation for Check Documentation Links (linkcheck.yml) * Per #3247, set install-package: true in linkcheck workflow to resolved ModuleNotFoundError during linkcheck * Trigger fresh linkcheck run to pick up updated action * Per #3247, resolve syntax error in yml file * Trigger fresh linkcheck run to pick up updated action * Trigger fresh linkcheck run to pick up updated action * Remove reference to a specific day of week Co-authored-by: John Halley Gotway <johnhg@ucar.edu> * Per #3247, made suggested updates by reviewer. * Per #3247, udpate name to use camel-case to match naming conventions of other METplus actions per reviewer suggestion. * Per #3247, update checkout version to be 6 from 4 * Per #3247, removed extra whitespace and extra dash. --------- Co-authored-by: John Halley Gotway <johnhg@ucar.edu>
1 parent 0679575 commit 6481816

3 files changed

Lines changed: 91 additions & 0 deletions

File tree

.github/workflows/linkcheck.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Linkcheck
2+
on:
3+
schedule:
4+
- cron: '0 6 * * 1'
5+
pull_request:
6+
paths:
7+
- 'docs/**'
8+
workflow_dispatch: {}
9+
10+
jobs:
11+
linkcheck:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
- uses: dtcenter/metplus-action-linkcheck@v1
16+
with:
17+
fail-on-broken-links: 'true'
18+
upload-artifact: 'true'
19+
install-package: 'true'

docs/Contributors_Guide/continuous_integration.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ METplus utilizes GitHub Actions to run processes automatically when changes
66
are pushed to GitHub. These tasks include:
77

88
* Building documentation to catch warnings/errors
9+
* Checking documentation for broken external links
910
* Building a Docker image to run tests
1011
* Creating/Updating Docker data volumes with new input data used for tests
1112
* Running unit tests
@@ -77,6 +78,42 @@ at the bottom of the workflow summary page when the workflow has completed.
7778

7879
.. figure:: figure/ci-doc-artifacts.png
7980

81+
.. _cg-ci-linkcheck:
82+
83+
Check Documentation Links (linkcheck.yml)
84+
-----------------------------------------
85+
86+
METplus documentation contains many links to external resources, such as
87+
academic papers, related software packages, and other websites. Over time,
88+
these external links can break as pages are moved or removed. This workflow
89+
runs Sphinx's ``linkcheck`` builder to identify broken links in the
90+
documentation.
91+
92+
This workflow is defined in each of the METplus component repositories.
93+
It calls a :ref:`cg-ci-custom-actions` action,
94+
`dtcenter/metplus-action-linkcheck <https://github.com/dtcenter/metplus-action-linkcheck>`_,
95+
so that the logic to install documentation dependencies and run the
96+
``linkcheck`` builder does not need to be duplicated across repositories.
97+
98+
This workflow is triggered by:
99+
100+
* A weekly **schedule**, so that link rot is caught even when
101+
no documentation changes have been made
102+
* A **pull_request** event for changes to files under the **docs** directory,
103+
so that new or edited links are checked before a pull request is merged
104+
* A manual **workflow_dispatch** event, so that a developer can run the check
105+
on demand against any branch
106+
107+
If broken links are found, the workflow job fails, as indicated by a red X,
108+
and the full ``linkcheck`` report is made available for download as a
109+
GitHub Actions artifact so it can be reviewed.
110+
111+
Some links may be intentionally excluded from this check. For example, a link
112+
may be valid but block automated/non-browser requests, or may point to a
113+
resource that is only reachable from an internal network. These exclusions
114+
are configured per repository in the ``linkcheck_ignore`` variable in that
115+
repository's **docs/conf.py** file.
116+
80117
.. _cg-ci-sonarqube:
81118

82119
SonarQube (sonarqube.yml)
@@ -1591,6 +1628,8 @@ the truth data, an artifact is created for the use case group. It contains
15911628
files that differ so that the user can download and examine them. Files that
15921629
are only found in one or the other are also included.
15931630

1631+
.. _cg-ci-custom-actions:
1632+
15941633
Custom GitHub Actions
15951634
=====================
15961635

@@ -1600,6 +1639,11 @@ Each custom action is stored in its own GitHub repository.
16001639
Navigate to the GitHub repository for a custom action to learn more about
16011640
using it.
16021641

1642+
Custom actions in METplus may be implemented as Docker container actions,
1643+
JavaScript actions, or composite actions. Composite actions are the
1644+
preferred approach for new development going forward, since they avoid
1645+
Docker image build/pull overhead and are not restricted to Linux runners.
1646+
16031647
Free Disk Space
16041648
---------------
16051649

@@ -1638,3 +1682,11 @@ Create Checksum for Release
16381682
Add a checksum to a release
16391683

16401684
`dtcenter/metplus-action-release-checksum <https://github.com/dtcenter/metplus-action-release-checksum>`_
1685+
1686+
Check Documentation Links
1687+
-------------------------
1688+
1689+
Runs Sphinx's ``linkcheck`` builder against a METplus component's
1690+
documentation to identify broken external links.
1691+
1692+
`dtcenter/metplus-action-linkcheck <https://github.com/dtcenter/metplus-action-linkcheck>`_

docs/conf.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,26 @@
230230
def setup(app):
231231
app.add_css_file("custom.css")
232232

233+
# -- linkcheck builder configuration ----------------------------------
234+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-the-linkcheck-builder
235+
236+
linkcheck_timeout = 10
237+
linkcheck_retries = 2
238+
linkcheck_workers = 8
239+
240+
linkcheck_ignore = [
241+
# add regex patterns for URLs that should be skipped, e.g.:
242+
# r'https://dtcenter\.org/.*', # verify first — some DTC pages may block
243+
# r'https://www\.weather\.gov/.*', # NWS pages sometimes rate-limit or redirect oddly
244+
]
245+
246+
linkcheck_allowed_redirects = {
247+
# map of regex -> regex for redirects that are fine to follow
248+
}
249+
250+
linkcheck_anchors = True
251+
linkcheck_anchors_ignore = ['^!']
252+
233253
# -- Replace values in docs ------------------------------------------------------------
234254
rst_epilog = f"""
235255
.. |copyright| replace:: {copyright}

0 commit comments

Comments
 (0)