lychee icon indicating copy to clipboard operation
lychee copied to clipboard

Is Excluding Individual Files Broken?

Open sekyondaMeta opened this issue 11 months ago • 4 comments

Running the workflow below does not seem to exclude the .png file. I have tried different permutations and combinations of adding the regex, but nothing seems to work. Any ideas would be greatly appreciated.

Workflow

name: link check on PR

on:
  pull_request:
    branches: [main]

jobs:
  linkChecker:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Get Changed Files
        id: changed-files
        uses: tj-actions/changed-files@v41

      - name: Check for Skip Label
        id: skip-label
        uses: actions/github-script@v6
        with:
          script: |
            const labels = await github.rest.issues.listLabelsOnIssue({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number
            });
            return labels.data.some(label => label.name === 'skip-link-check');
          
      - name: Check Links
        if: steps.skip-label.outputs.result == 'false'
        uses: lycheeverse/lychee-action@v1
        with:
          args: --exclude '\.(pdf|zip|png|jpg)$' --accept=200,403,429 --base . --verbose --no-progress ${{ steps.changed-files.outputs.all_changed_files }}
          token: ${{ secrets.CUSTOM_TOKEN }}
          fail: true
          
      - name: Skip Message
        if: steps.skip-label.outputs.result == 'true'
        run: echo "Link check was skipped due to the presence of the 'skip-link-check' label."
        
      - name: Suggestions
        if: failure()
        run: |
          echo -e "\nPlease review the links reported in the Check links step above."
          echo -e "If a link is valid but fails due to a CAPTCHA challenge, IP blocking, login requirements, etc., consider adding such links to .lycheeignore file to bypass future checks.\n"
          exit 1

Error message

Run lycheeverse/lychee-action@v1
Run # Cleanup artifacts from previous run in case it crashed
lychee
Run /home/runner/work/_actions/lycheeverse/lychee-action/v1/entrypoint.sh
Error: Cannot read input content from file recipes_source/customaddandround.png`

`Caused by:
    stream did not contain valid UTF-8`

sekyondaMeta avatar Jan 30 '25 19:01 sekyondaMeta

The key issue is this:

lychee --exclude '\.(pdf|zip|png|jpg)$' --accept=200,403,429 --base . --verbose --no-progress .

--exclude for URLs, but you want to exclude paths. To be more precise, you want to exclude PNG files from the list of changed files. You can exclude paths with --exclude-path.

lychee --exclude-path "*.png"

However, I think that's broken at the moment. 😕 At least I couldn't get it to work on my local machine.

More info:

  • https://lychee.cli.rs/recipes/excluding-paths/
  • https://lychee.cli.rs/recipes/excluding-links/

mre avatar Feb 03 '25 12:02 mre

@mre That makes sense and thanks for taking a look at this. Will make the change and keep an eye out for any changes if/when the bug is fixed.

sekyondaMeta avatar Feb 03 '25 16:02 sekyondaMeta

Is excluding files broken altogether? I was about to make a similar post that this wasn't skipping files:

exclude_path = [
    "*.mdx",
    "node_modules"
]

andrewvaughan avatar Mar 06 '25 16:03 andrewvaughan

Is excluding files broken altogether? I was about to make a similar post that this wasn't skipping files:

exclude_path = [ "*.mdx", "node_modules" ]

For my use case it seems I can exclude an entire folder using exclude_path but have not been able to target specific file types using exclude_path

sekyondaMeta avatar Mar 06 '25 16:03 sekyondaMeta

Same for me, --exclude-path all_tools_and_resources.html,all_training_resources.html is not excluding those files...

bedroesb avatar Jul 18 '25 14:07 bedroesb

Having the same issue while trying to exclude all .mdx files!

exclude_path = [
"\\.mdx$", # skip .mdx extensions
]

From https://lychee.cli.rs/recipes/excluding-paths/

JReko avatar Aug 19 '25 20:08 JReko

@mre Do you have any timeline when the next release will be, and if #1766 will fix the issue?

bedroesb avatar Aug 20 '25 08:08 bedroesb

Yeah, it should fix the issue.

mre avatar Aug 21 '25 10:08 mre

We'll cut a new release soon.

We're planning to update the dependencies first:

  • [x] https://github.com/lycheeverse/lychee/pull/1811
  • [x] https://github.com/lycheeverse/lychee/pull/1805

mre avatar Aug 21 '25 11:08 mre

Looking forward!

bedroesb avatar Aug 21 '25 11:08 bedroesb

@mre Thanks for the release! Not sure if this fixed the problem for my Jekyll deployment:

_site/  --exclude-path _site/all_tools_and_resources.html,_site/all_training_resources.html

or

_site/  --exclude-path all_tools_and_resources.html,all_training_resources.html

I tried both to skip the files _site/all_tools_and_resources.html and _site/all_training_resources.html but id doens't seem to work. Am I doing something wrong?

bedroesb avatar Aug 22 '25 07:08 bedroesb

does it work, when using the --exclude-path flag multiple times, instead of using a comma?

like

_site/ --exclude-path _site/all_tools_and_resources.html --exclude-path _site/all_training_resources.html

nobkd avatar Aug 22 '25 15:08 nobkd

That did the trick! All working fine for me now.

bedroesb avatar Aug 22 '25 15:08 bedroesb

Awesome. I consider this issue resolved.

mre avatar Aug 23 '25 10:08 mre