Skip to content

Add docs-check-links.yml and docs-check-links.sh files in .github/workflows#3831

Open
slevis-lmwg wants to merge 2 commits intoESCOMP:b4b-devfrom
slevis-lmwg:wkflow_check_links_in_doc
Open

Add docs-check-links.yml and docs-check-links.sh files in .github/workflows#3831
slevis-lmwg wants to merge 2 commits intoESCOMP:b4b-devfrom
slevis-lmwg:wkflow_check_links_in_doc

Conversation

@slevis-lmwg
Copy link
Contributor

Description of changes

Add github workflow to check whether links in the documentation still work.

Specific notes

Contributors other than yourself, if any:
@samsrabin

CTSM Issues Fixed (include github issue #):
Fixes #3218

Are answers expected to change (and if so in what way)?
No

Any User Interface Changes (namelist or namelist defaults changes)?
No

Does this create a need to change or add documentation? Did you do so?
?, no

Testing performed, if any:
None, yet

@slevis-lmwg slevis-lmwg self-assigned this Mar 20, 2026
@slevis-lmwg slevis-lmwg added testing additions or changes to tests bfb bit-for-bit labels Mar 20, 2026
@github-project-automation github-project-automation bot moved this to Ready to start (or start again) in CTSM: Upcoming tags Mar 20, 2026
@slevis-lmwg slevis-lmwg moved this to In review in CLM documentation Mar 20, 2026
@slevis-lmwg slevis-lmwg moved this from Ready to start (or start again) to In progress - b4b-dev in CTSM: Upcoming tags Mar 20, 2026
@slevis-lmwg slevis-lmwg moved this from Todo to In Progress in LMWG: Sprint Planning Board Mar 20, 2026
@slevis-lmwg
Copy link
Contributor Author

@samsrabin I introduced these two files

docs-check-links.sh
docs-check-links.yml

using check-clm6-aliases as a template. I doubt that what I did works so far. When you have a chance:

  • Could you confirm whether I'm on the right track?
  • Could you point out things that I need to correct?
  • Do I need to replace "http_code" with something like https:// or similar? What about $URL?

When I'm ready to test this, would I make a change to an .rst file in the documentation and push to the PR?

@slevis-lmwg slevis-lmwg requested a review from samsrabin March 20, 2026 17:39
@slevis-lmwg slevis-lmwg added docs:infrastructure New features or bug fixes in the documentation infrastructure docs-loc:infrastructure Relates to documentation infrastructure labels Mar 20, 2026
@slevis-lmwg slevis-lmwg linked an issue Mar 20, 2026 that may be closed by this pull request
@samsrabin
Copy link
Member

samsrabin commented Mar 24, 2026

  • Could you confirm whether I'm on the right track?

Yes!

  • Could you point out things that I need to correct?
  1. I think it would be best for your new "Check documentation links" job to be added to the docs.yml Workflow, which has a refined set of triggers.
  2. GITHUB_TOKEN isn't actually used in the docs-check-links.sh script.
  • Do I need to replace "http_code" with something like https:// or similar? What about $URL?

http_code no; that just tells curl to return the code (e.g. 200 for exists and accessible; 301 for permanently moved; 404 for not found).

$URL sort of. This command should be put inside a loop that loops through all the URLs found in the documentation:

for $URL in $list_of_found_urls; do
    link_code="$(curl -s -o /dev/null -w "%{http_code}" $URL)"
    # Add code to save bad links to one or more arrays
    ...
done

# Throw error or success message
...

I leave it to you to figure out how best to find all URLs.

When I'm ready to test this, would I make a change to an .rst file in the documentation and push to the PR?

The first thing to test will be that your docs-check-links.sh script works, which you can do locally or on an NCAR cluster. Once you know that's working, go ahead and push to this PR. I think, if you've moved your new job to docs.yml, it should trigger automatically. Make sure it fails. Then you'll need to fix all the broken links so that the test passes before we can merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bfb bit-for-bit docs:infrastructure New features or bug fixes in the documentation infrastructure docs-loc:infrastructure Relates to documentation infrastructure testing additions or changes to tests

Projects

Status: In review
Status: In progress - b4b-dev
Status: In Progress

Development

Successfully merging this pull request may close these issues.

Add GitHub workflow to check links in documentation

2 participants