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 Broken Link Checker - Github Action #6596

Closed
JuanPabloDiaz opened this issue May 10, 2024 · 9 comments
Closed

Add Broken Link Checker - Github Action #6596

JuanPabloDiaz opened this issue May 10, 2024 · 9 comments
Labels
github_actions Pull requests that update GitHub Actions code

Comments

@JuanPabloDiaz
Copy link
Collaborator

I believe that it will be a great idea to setup a GitHub action that runs periodically and checks for broken links.
It will check all repository links once per day and create an issue in case of errors.

Github action to check for broken links in Markdown, HTML, and text files using Lychee, a fast link checker written in Rust.

Here is a full example of a GitHub workflow file:

It will check all repository links once per day and create an issue in case of errors.

name: Links

on:
  repository_dispatch:
  workflow_dispatch:
  schedule:
    - cron: "00 18 * * *"

jobs:
  linkChecker:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Link Checker
        id: lychee
        uses: lycheeverse/lychee-action@v1

      - name: Create Issue From File
        if: env.lychee_exit_code != 0
        uses: peter-evans/create-issue-from-file@v4
        with:
          title: Link Checker Report
          content-filepath: ./lychee/out.md
          labels: report, automated issue

I'd like to share my experience with Lychee. I came across it yesterday and integrated it into my project. While it was helpful in identifying some broken links, it also generated some false positives (links that appear broken but function correctly). I'm still exploring the tool's functionality to potentially fine-tune its accuracy.

On a separate note, I encountered a permissions issue when trying to open new issues.

Project implementations:

here is an example from my own project:
image

I hope this helps

@cgrail
Copy link
Member

cgrail commented May 13, 2024

Thanks a lot. Sounds like a good idea.

JuanPabloDiaz added a commit to JuanPabloDiaz/conference-data that referenced this issue May 17, 2024
@JuanPabloDiaz JuanPabloDiaz added the github_actions Pull requests that update GitHub Actions code label May 27, 2024
@JuanPabloDiaz
Copy link
Collaborator Author

JuanPabloDiaz commented Jul 4, 2024

This is what I got when I run the script for the entire repo:

 image

I then changed it to run the tests for 2024, 2025 and 2026 folders and got a more reasonable number:

image

After running the workflow, this issue was created

@nimzco
Copy link
Member

nimzco commented Jul 4, 2024

Oh that's really cool!
I think we could even go further and only check upcoming conferences. And if an upcoming conference link is broken we could create a PR that removes the conference or create an issue like you did so we can check and fix the broken URL.

@JuanPabloDiaz
Copy link
Collaborator Author

I just want to make sure we're all aligned. Let me explain what I believe the workflow I've set up is designed to do (please correct me if I'm mistaken).

This workflow is designed to automatically check for broken links in JSON files within specific folders of the repository (conferences/(2024/2025/2026)). It triggers under several conditions: 1. on pull requests to the 'main' branch, 2. on manual triggers, and 3. on a scheduled basis. The Link Checker step reads the .lycheeignore file, specified by the --exclude-file .lycheeignore argument, to determine which links or files should be excluded from the checking process. If any broken links are found, the workflow creates or updates a GitHub issue with the details.

@nimzco
Copy link
Member

nimzco commented Jul 13, 2024

That works for me. We can always tweak if we're unhappy with the results. 👍

@cgrail
Copy link
Member

cgrail commented Aug 15, 2024

Done with:
#7132
#7134

@cgrail cgrail closed this as completed Aug 15, 2024
@JuanPabloDiaz
Copy link
Collaborator Author

Thank you @cgrail, it looks great!

@cgrail
Copy link
Member

cgrail commented Aug 21, 2024

Yeah. However I have the feeling that we can quite some false negatives.

@JuanPabloDiaz
Copy link
Collaborator Author

Yeah, that's the only thing that is annoying at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update GitHub Actions code
Projects
None yet
Development

No branches or pull requests

3 participants