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

Add link-check linter #216

Open
batpigandme opened this issue Sep 28, 2018 · 11 comments
Open

Add link-check linter #216

batpigandme opened this issue Sep 28, 2018 · 11 comments

Comments

@batpigandme
Copy link
Collaborator

@jimhester, did you mention the existence of something like this once?

@jimhester
Copy link
Contributor

jimhester commented Sep 28, 2018

@jimhester
Copy link
Contributor

There is some documentation on using it with travis at https://github.com/gjtorikian/html-proofer/wiki/Using-HTMLProofer-From-Ruby-and-Travis

@jimhester
Copy link
Contributor

If we wanted to do this we could probably just do the 'stupid thing' they have on there

language: ruby
before_install:
 - export NOKOGIRI_USE_SYSTEM_LIBRARIES=true
addons:
  apt:
    packages:
    - libcurl4-openssl-dev # required to avoid SSL errors
script:
 - gem install html-proofer && htmlproofer .

@batpigandme
Copy link
Collaborator Author

Great.

There's also the rakefile option:

desc "Run the HTML-Proofer"
task :run_proofer do
  require 'html-proofer'


  # Ignore platform switcher hash URLs
  platform_hash_urls = ['#platform-mac', '#platform-windows', '#platform-linux', '#platform-all']
  HTMLProofer.check_directory("./output", {
    :url_ignore => platform_hash_urls,
    :typhoeus => { :ssl_verifypeer => false }
  }).run
end

https://github.com/atom/flight-manual.atom.io/blob/e6fa143f745fbd4908933e2ba67615eac8b24cff/Rakefile#L30-L40

@batpigandme
Copy link
Collaborator Author

Rmd link checker?
https://github.com/fmichonneau/checker

@hadley
Copy link
Member

hadley commented Apr 3, 2020

Might be worth looking if there's a pre-made github action for this

@hadley hadley added feature a feature request or enhancement workflow 🤖 and removed feature a feature request or enhancement labels Apr 3, 2020
@jimhester
Copy link
Contributor

There seem to be a few, e.g. https://github.com/marketplace/actions/link-checker, https://github.com/gaurav-nelson/github-action-markdown-link-check,

@jimhester
Copy link
Contributor

After trying them out locally it seems really easy to hit the GitHub rate limits and start getting 429 responses from GitHub. We would probably have to be careful to only check modified files and maybe even find a link checker (or make one) that uses a GITHUB_PAT to up the rate limit.

@maelle
Copy link
Contributor

maelle commented Apr 14, 2020

Sharing my experience in case it can be useful: I've just added two workflows to R-hub docs depending on https://github.com/urlstechie/urlchecker-action that I've found out about on a blog. It's quite new but the maintainers are very responsive. It uses a Python library that uses regex, not commonmark 😢 but that's because it's general to any file (Rd files? 🙂).

@jimhester
Copy link
Contributor

Those are nice @maelle! I think we should be able to

  1. Run a workflow only when posts happen, e.g. files change in a given directory
  2. Run the checks only on the files that have changed

With something like this. (it definitely won't work as-is, but you hopefully get the idea)

on:
  push:
    paths: content/blog/**/*.markdown
  check_links:
     run: |
        files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
        run_checker $files

@steltenpower
Copy link

Can https://validator.w3.org/checklink maybe help?
Good that this issue is being worked on. I looked it up as a link to https://rdrr.io/... just gave a 404 while that site was not down.

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

No branches or pull requests

5 participants