UmbrellaDocs / action-linkspector

Uncover broken links in your content using Linkspector GitHub action.
MIT License
11 stars 2 forks source link

Running with `modifiedFilesOnly` fails with reviewdog parse error #3

Closed Realiserad closed 3 months ago

Realiserad commented 4 months ago

Describe the bug

Running Linkspector GitHub Action with a custom config results containing modifiedFilesOnly: true results in a reviewdog parse error.

To Reproduce

Copy-paste the following into .github/workflows/linkspector.yaml and create a PR:

name: Linkspector
on:
  pull_request:
jobs:
  check-links:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - uses: 1arp/create-a-file-action@0.4.5
      with:
        file: .linkspector.yml
        content: |
          dirs: ['.']
          useGitIgnore: true
          modifiedFilesOnly: true
    - name: Run Linkspector
      uses: UmbrellaDocs/action-linkspector@v1.0.0
      with:
        github_token: ${{ secrets.github_token }}
        reporter: github-pr-review

The error from GitHub Actions is:

reviewdog: parse error: failed to unmarshal rdjson (DiagnosticResult): proto: syntax error (line 1:1): invalid value Skipped

Expected behavior

The workflow should pass without errors.

Realiserad commented 3 months ago

The problem is that when no files have been modified and modifiedFilesOnly: true is used, Linkspector outputs the message "Skipped link checking. Modified files are not specified in the configuration." instead of a valid JSON document. This causes reviewdog to fail.

Actually this current behaviour of Linkspector is well documented:

Also, if no modified files are found in the list of files to check, Linkspector will skip link checking and exit with a message indicating that modified files are not specified in the configuration.

I suppose Linkspector could be patched to always output valid JSON or the linkspector-action can be modified to skip reviewdog if no files were checked by Linkspector.

gaurav-nelson commented 3 months ago

Thank you for the details @Realiserad I'll get this fixed.